repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
partition
stringclasses
1 value
PunchThrough/bean-sdk-android
sdk/src/main/java/com/punchthrough/bean/sdk/BeanManager.java
BeanManager.scan
private boolean scan() { if (btAdapter.startLeScan(mCallback)) { mScanning = true; Log.i(TAG, "BLE scan started successfully"); if (mHandler.postDelayed(scanTimeoutCallback, scanTimeout * 1000)) { Log.i(TAG, String.format("Cancelling discovery in %d seconds", scanTimeout)); } else { Log.e(TAG, "Failed to schedule discovery complete callback!"); } return true; } else { Log.i(TAG, "BLE scan failed!"); return false; } }
java
private boolean scan() { if (btAdapter.startLeScan(mCallback)) { mScanning = true; Log.i(TAG, "BLE scan started successfully"); if (mHandler.postDelayed(scanTimeoutCallback, scanTimeout * 1000)) { Log.i(TAG, String.format("Cancelling discovery in %d seconds", scanTimeout)); } else { Log.e(TAG, "Failed to schedule discovery complete callback!"); } return true; } else { Log.i(TAG, "BLE scan failed!"); return false; } }
[ "private", "boolean", "scan", "(", ")", "{", "if", "(", "btAdapter", ".", "startLeScan", "(", "mCallback", ")", ")", "{", "mScanning", "=", "true", ";", "Log", ".", "i", "(", "TAG", ",", "\"BLE scan started successfully\"", ")", ";", "if", "(", "mHandler...
Helper function for starting scan and scheduling the scan timeout @return boolean success flag
[ "Helper", "function", "for", "starting", "scan", "and", "scheduling", "the", "scan", "timeout" ]
dc33e8cc9258d6e028e0788d74735c75b54d1133
https://github.com/PunchThrough/bean-sdk-android/blob/dc33e8cc9258d6e028e0788d74735c75b54d1133/sdk/src/main/java/com/punchthrough/bean/sdk/BeanManager.java#L111-L128
train
PunchThrough/bean-sdk-android
sdk/src/main/java/com/punchthrough/bean/sdk/BeanManager.java
BeanManager.setScanTimeout
public void setScanTimeout(int timeout) { scanTimeout = timeout; Log.i(TAG, String.format("New scan timeout set: %d seconds", scanTimeout)); }
java
public void setScanTimeout(int timeout) { scanTimeout = timeout; Log.i(TAG, String.format("New scan timeout set: %d seconds", scanTimeout)); }
[ "public", "void", "setScanTimeout", "(", "int", "timeout", ")", "{", "scanTimeout", "=", "timeout", ";", "Log", ".", "i", "(", "TAG", ",", "String", ".", "format", "(", "\"New scan timeout set: %d seconds\"", ",", "scanTimeout", ")", ")", ";", "}" ]
Set the desired scan timeout in seconds @param timeout seconds
[ "Set", "the", "desired", "scan", "timeout", "in", "seconds" ]
dc33e8cc9258d6e028e0788d74735c75b54d1133
https://github.com/PunchThrough/bean-sdk-android/blob/dc33e8cc9258d6e028e0788d74735c75b54d1133/sdk/src/main/java/com/punchthrough/bean/sdk/BeanManager.java#L135-L138
train
PunchThrough/bean-sdk-android
sdk/src/main/java/com/punchthrough/bean/sdk/BeanManager.java
BeanManager.startDiscovery
public boolean startDiscovery() { if (mScanning) { Log.e(TAG, "Already discovering"); return true; } if (mListener == null) { throw new NullPointerException("Listener cannot be null"); } return scan(); }
java
public boolean startDiscovery() { if (mScanning) { Log.e(TAG, "Already discovering"); return true; } if (mListener == null) { throw new NullPointerException("Listener cannot be null"); } return scan(); }
[ "public", "boolean", "startDiscovery", "(", ")", "{", "if", "(", "mScanning", ")", "{", "Log", ".", "e", "(", "TAG", ",", "\"Already discovering\"", ")", ";", "return", "true", ";", "}", "if", "(", "mListener", "==", "null", ")", "{", "throw", "new", ...
Start discovering nearby Beans using an existing BeanListener. Currently this function is only used by OADProfile to start scanning after the Bean disconnects during the OAD process.
[ "Start", "discovering", "nearby", "Beans", "using", "an", "existing", "BeanListener", "." ]
dc33e8cc9258d6e028e0788d74735c75b54d1133
https://github.com/PunchThrough/bean-sdk-android/blob/dc33e8cc9258d6e028e0788d74735c75b54d1133/sdk/src/main/java/com/punchthrough/bean/sdk/BeanManager.java#L181-L192
train
PunchThrough/bean-sdk-android
sdk/src/main/java/com/punchthrough/bean/sdk/BeanManager.java
BeanManager.cancelDiscovery
public void cancelDiscovery() { mHandler.removeCallbacks(scanTimeoutCallback); if (mScanning) { Log.i(TAG, "Cancelling discovery process"); BluetoothAdapter.getDefaultAdapter().stopLeScan(mCallback); mScanning = false; boolean success = mHandler.post(new Runnable() { @Override public void run() { mListener.onDiscoveryComplete(); } }); if (!success) { Log.e(TAG, "Failed to post Discovery Complete callback!"); } } else { Log.e(TAG, "No discovery in progress"); } }
java
public void cancelDiscovery() { mHandler.removeCallbacks(scanTimeoutCallback); if (mScanning) { Log.i(TAG, "Cancelling discovery process"); BluetoothAdapter.getDefaultAdapter().stopLeScan(mCallback); mScanning = false; boolean success = mHandler.post(new Runnable() { @Override public void run() { mListener.onDiscoveryComplete(); } }); if (!success) { Log.e(TAG, "Failed to post Discovery Complete callback!"); } } else { Log.e(TAG, "No discovery in progress"); } }
[ "public", "void", "cancelDiscovery", "(", ")", "{", "mHandler", ".", "removeCallbacks", "(", "scanTimeoutCallback", ")", ";", "if", "(", "mScanning", ")", "{", "Log", ".", "i", "(", "TAG", ",", "\"Cancelling discovery process\"", ")", ";", "BluetoothAdapter", ...
Cancel a scan currently in progress. If no scan is in progress, this method does nothing.
[ "Cancel", "a", "scan", "currently", "in", "progress", ".", "If", "no", "scan", "is", "in", "progress", "this", "method", "does", "nothing", "." ]
dc33e8cc9258d6e028e0788d74735c75b54d1133
https://github.com/PunchThrough/bean-sdk-android/blob/dc33e8cc9258d6e028e0788d74735c75b54d1133/sdk/src/main/java/com/punchthrough/bean/sdk/BeanManager.java#L197-L216
train
kwon37xi/hibernate4-memcached
hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/Lz4CompressUtils.java
Lz4CompressUtils.decompressSafe
public static byte[] decompressSafe(final byte[] src, int maxDecompressedSize) { if (src == null) { throw new IllegalArgumentException("src must not be null."); } if (maxDecompressedSize <= 0) { throw new IllegalArgumentException("maxDecompressedSize must be larger than 0 but " + maxDecompressedSize); } LZ4SafeDecompressor decompressor = factory.safeDecompressor(); return decompressor.decompress(src, maxDecompressedSize); }
java
public static byte[] decompressSafe(final byte[] src, int maxDecompressedSize) { if (src == null) { throw new IllegalArgumentException("src must not be null."); } if (maxDecompressedSize <= 0) { throw new IllegalArgumentException("maxDecompressedSize must be larger than 0 but " + maxDecompressedSize); } LZ4SafeDecompressor decompressor = factory.safeDecompressor(); return decompressor.decompress(src, maxDecompressedSize); }
[ "public", "static", "byte", "[", "]", "decompressSafe", "(", "final", "byte", "[", "]", "src", ",", "int", "maxDecompressedSize", ")", "{", "if", "(", "src", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"src must not be null.\"", ...
When the exact decompressed size is unknown. Decompress data size cannot be larger then maxDecompressedSize
[ "When", "the", "exact", "decompressed", "size", "is", "unknown", ".", "Decompress", "data", "size", "cannot", "be", "larger", "then", "maxDecompressedSize" ]
e0b2839ab257b2602344f54ca53c564044f3585d
https://github.com/kwon37xi/hibernate4-memcached/blob/e0b2839ab257b2602344f54ca53c564044f3585d/hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/Lz4CompressUtils.java#L32-L44
train
kwon37xi/hibernate4-memcached
hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/Lz4CompressUtils.java
Lz4CompressUtils.decompressFast
public static byte[] decompressFast(byte[] src, int srcOffset, int exactDecompressedSize) { if (src == null) { throw new IllegalArgumentException("src must not be null."); } if (srcOffset < 0) { throw new IllegalArgumentException("srcOffset must equal to or larger than 0 but " + srcOffset); } if (exactDecompressedSize < 0) { throw new IllegalArgumentException("exactDecompressedSize must equal to or larger than 0 but " + exactDecompressedSize); } LZ4FastDecompressor decompressor = factory.fastDecompressor(); return decompressor.decompress(src, srcOffset, exactDecompressedSize); }
java
public static byte[] decompressFast(byte[] src, int srcOffset, int exactDecompressedSize) { if (src == null) { throw new IllegalArgumentException("src must not be null."); } if (srcOffset < 0) { throw new IllegalArgumentException("srcOffset must equal to or larger than 0 but " + srcOffset); } if (exactDecompressedSize < 0) { throw new IllegalArgumentException("exactDecompressedSize must equal to or larger than 0 but " + exactDecompressedSize); } LZ4FastDecompressor decompressor = factory.fastDecompressor(); return decompressor.decompress(src, srcOffset, exactDecompressedSize); }
[ "public", "static", "byte", "[", "]", "decompressFast", "(", "byte", "[", "]", "src", ",", "int", "srcOffset", ",", "int", "exactDecompressedSize", ")", "{", "if", "(", "src", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"src ...
When the exact decompressed size is known, use this method to decompress. It's faster. @see net.jpountz.lz4.LZ4FastDecompressor
[ "When", "the", "exact", "decompressed", "size", "is", "known", "use", "this", "method", "to", "decompress", ".", "It", "s", "faster", "." ]
e0b2839ab257b2602344f54ca53c564044f3585d
https://github.com/kwon37xi/hibernate4-memcached/blob/e0b2839ab257b2602344f54ca53c564044f3585d/hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/Lz4CompressUtils.java#L51-L67
train
PunchThrough/bean-sdk-android
sdk/src/main/java/com/punchthrough/bean/sdk/upload/SketchHex.java
SketchHex.create
public static SketchHex create(String sketchName, String hexString) throws HexParsingException { if (sketchName.length() > Constants.MAX_SKETCH_NAME_LENGTH) { sketchName = sketchName.substring(0, Constants.MAX_SKETCH_NAME_LENGTH); } List<Line> lines = parseHexStringToLines(hexString); byte[] bytes = convertLinesToBytes(lines); return new AutoParcel_SketchHex(sketchName, bytes); }
java
public static SketchHex create(String sketchName, String hexString) throws HexParsingException { if (sketchName.length() > Constants.MAX_SKETCH_NAME_LENGTH) { sketchName = sketchName.substring(0, Constants.MAX_SKETCH_NAME_LENGTH); } List<Line> lines = parseHexStringToLines(hexString); byte[] bytes = convertLinesToBytes(lines); return new AutoParcel_SketchHex(sketchName, bytes); }
[ "public", "static", "SketchHex", "create", "(", "String", "sketchName", ",", "String", "hexString", ")", "throws", "HexParsingException", "{", "if", "(", "sketchName", ".", "length", "(", ")", ">", "Constants", ".", "MAX_SKETCH_NAME_LENGTH", ")", "{", "sketchNam...
Initialize a SketchHex object with a string of Intel Hex data. @param sketchName The name of the sketch. @param hexString The Intel Hex data as a string @return The new SketchHex object @throws com.punchthrough.bean.sdk.internal.exception.HexParsingException if the string data being parsed is not valid Intel Hex
[ "Initialize", "a", "SketchHex", "object", "with", "a", "string", "of", "Intel", "Hex", "data", "." ]
dc33e8cc9258d6e028e0788d74735c75b54d1133
https://github.com/PunchThrough/bean-sdk-android/blob/dc33e8cc9258d6e028e0788d74735c75b54d1133/sdk/src/main/java/com/punchthrough/bean/sdk/upload/SketchHex.java#L56-L65
train
PunchThrough/bean-sdk-android
sdk/src/main/java/com/punchthrough/bean/sdk/internal/utility/Chunk.java
Chunk.bytesFrom
public static <T extends Chunkable> byte[] bytesFrom(T chunkable, int offset, int length) { byte[] data = chunkable.getChunkableData(); if ( offset + length > data.length ) { // Arrays.copyOfRange appends 0s when the array end is exceeded. // Trim length manually to avoid appending extra data. return Arrays.copyOfRange(data, offset, data.length); } else { return Arrays.copyOfRange(data, offset, offset + length); } }
java
public static <T extends Chunkable> byte[] bytesFrom(T chunkable, int offset, int length) { byte[] data = chunkable.getChunkableData(); if ( offset + length > data.length ) { // Arrays.copyOfRange appends 0s when the array end is exceeded. // Trim length manually to avoid appending extra data. return Arrays.copyOfRange(data, offset, data.length); } else { return Arrays.copyOfRange(data, offset, offset + length); } }
[ "public", "static", "<", "T", "extends", "Chunkable", ">", "byte", "[", "]", "bytesFrom", "(", "T", "chunkable", ",", "int", "offset", ",", "int", "length", ")", "{", "byte", "[", "]", "data", "=", "chunkable", ".", "getChunkableData", "(", ")", ";", ...
Retrieve a number of raw bytes at an offset. @param offset The byte at which to start, zero-indexed @param length The number of bytes to return. If this is greater than the number of bytes available after <code>offset</code>, it will return all available bytes, truncated at the end. @return The bytes, starting at <code>offset</code> of length <code>length</code> or less if truncated
[ "Retrieve", "a", "number", "of", "raw", "bytes", "at", "an", "offset", "." ]
dc33e8cc9258d6e028e0788d74735c75b54d1133
https://github.com/PunchThrough/bean-sdk-android/blob/dc33e8cc9258d6e028e0788d74735c75b54d1133/sdk/src/main/java/com/punchthrough/bean/sdk/internal/utility/Chunk.java#L30-L43
train
PunchThrough/bean-sdk-android
sdk/src/main/java/com/punchthrough/bean/sdk/internal/utility/Chunk.java
Chunk.chunkFrom
public static <T extends Chunkable> byte[] chunkFrom(T chunkable, int chunkLength, int chunkNum) { int start = chunkNum * chunkLength; return bytesFrom(chunkable, start, chunkLength); }
java
public static <T extends Chunkable> byte[] chunkFrom(T chunkable, int chunkLength, int chunkNum) { int start = chunkNum * chunkLength; return bytesFrom(chunkable, start, chunkLength); }
[ "public", "static", "<", "T", "extends", "Chunkable", ">", "byte", "[", "]", "chunkFrom", "(", "T", "chunkable", ",", "int", "chunkLength", ",", "int", "chunkNum", ")", "{", "int", "start", "=", "chunkNum", "*", "chunkLength", ";", "return", "bytesFrom", ...
Retrieve a chunk of raw bytes. Chunks are created by slicing the array at even intervals. The final chunk may be shorter than the other chunks if it's been truncated. @param chunkLength The length of each chunk @param chunkNum The chunk at which to start, zero-indexed @return The chunk (array of bytes)
[ "Retrieve", "a", "chunk", "of", "raw", "bytes", ".", "Chunks", "are", "created", "by", "slicing", "the", "array", "at", "even", "intervals", ".", "The", "final", "chunk", "may", "be", "shorter", "than", "the", "other", "chunks", "if", "it", "s", "been", ...
dc33e8cc9258d6e028e0788d74735c75b54d1133
https://github.com/PunchThrough/bean-sdk-android/blob/dc33e8cc9258d6e028e0788d74735c75b54d1133/sdk/src/main/java/com/punchthrough/bean/sdk/internal/utility/Chunk.java#L53-L57
train
PunchThrough/bean-sdk-android
sdk/src/main/java/com/punchthrough/bean/sdk/internal/utility/Chunk.java
Chunk.chunkCountFrom
public static <T extends Chunkable> int chunkCountFrom(T chunkable, int chunkLength) { byte[] data = chunkable.getChunkableData(); return (int) Math.ceil(data.length * 1.0 / chunkLength); }
java
public static <T extends Chunkable> int chunkCountFrom(T chunkable, int chunkLength) { byte[] data = chunkable.getChunkableData(); return (int) Math.ceil(data.length * 1.0 / chunkLength); }
[ "public", "static", "<", "T", "extends", "Chunkable", ">", "int", "chunkCountFrom", "(", "T", "chunkable", ",", "int", "chunkLength", ")", "{", "byte", "[", "]", "data", "=", "chunkable", ".", "getChunkableData", "(", ")", ";", "return", "(", "int", ")",...
Retrieve the count of chunks for a given chunk length. @param chunkLength The length of each chunk @return The number of chunks generated for a given chunk length
[ "Retrieve", "the", "count", "of", "chunks", "for", "a", "given", "chunk", "length", "." ]
dc33e8cc9258d6e028e0788d74735c75b54d1133
https://github.com/PunchThrough/bean-sdk-android/blob/dc33e8cc9258d6e028e0788d74735c75b54d1133/sdk/src/main/java/com/punchthrough/bean/sdk/internal/utility/Chunk.java#L65-L68
train
PunchThrough/bean-sdk-android
sdk/src/main/java/com/punchthrough/bean/sdk/internal/utility/Chunk.java
Chunk.chunksFrom
public static <T extends Chunkable> List<byte[]> chunksFrom(T chunkable, int chunkLength) { List<byte[]> chunks = new ArrayList<>(); int chunkCount = chunkCountFrom(chunkable, chunkLength); for (int i = 0; i < chunkCount; i++) { byte[] chunk = chunkFrom(chunkable, chunkLength, i); chunks.add(chunk); } return chunks; }
java
public static <T extends Chunkable> List<byte[]> chunksFrom(T chunkable, int chunkLength) { List<byte[]> chunks = new ArrayList<>(); int chunkCount = chunkCountFrom(chunkable, chunkLength); for (int i = 0; i < chunkCount; i++) { byte[] chunk = chunkFrom(chunkable, chunkLength, i); chunks.add(chunk); } return chunks; }
[ "public", "static", "<", "T", "extends", "Chunkable", ">", "List", "<", "byte", "[", "]", ">", "chunksFrom", "(", "T", "chunkable", ",", "int", "chunkLength", ")", "{", "List", "<", "byte", "[", "]", ">", "chunks", "=", "new", "ArrayList", "<>", "(",...
Retrieve all chunks for a given chunk length. The final chunk may be shorter than the other chunks if it's been truncated. @param chunkLength The length of each chunk @return A list of chunks (byte arrays)
[ "Retrieve", "all", "chunks", "for", "a", "given", "chunk", "length", ".", "The", "final", "chunk", "may", "be", "shorter", "than", "the", "other", "chunks", "if", "it", "s", "been", "truncated", "." ]
dc33e8cc9258d6e028e0788d74735c75b54d1133
https://github.com/PunchThrough/bean-sdk-android/blob/dc33e8cc9258d6e028e0788d74735c75b54d1133/sdk/src/main/java/com/punchthrough/bean/sdk/internal/utility/Chunk.java#L77-L88
train
PunchThrough/bean-sdk-android
sdk/src/main/java/com/punchthrough/bean/sdk/internal/utility/Convert.java
Convert.twoBytesToInt
public static int twoBytesToInt(byte[] bytes, ByteOrder order) { if (order == ByteOrder.BIG_ENDIAN) { return bytesToInt(bytes[0], bytes[1]); } else if (order == ByteOrder.LITTLE_ENDIAN) { return bytesToInt(bytes[1], bytes[0]); } else { throw new IllegalArgumentException("ByteOrder must be BIG_ENDIAN or LITTLE_ENDIAN"); } }
java
public static int twoBytesToInt(byte[] bytes, ByteOrder order) { if (order == ByteOrder.BIG_ENDIAN) { return bytesToInt(bytes[0], bytes[1]); } else if (order == ByteOrder.LITTLE_ENDIAN) { return bytesToInt(bytes[1], bytes[0]); } else { throw new IllegalArgumentException("ByteOrder must be BIG_ENDIAN or LITTLE_ENDIAN"); } }
[ "public", "static", "int", "twoBytesToInt", "(", "byte", "[", "]", "bytes", ",", "ByteOrder", "order", ")", "{", "if", "(", "order", "==", "ByteOrder", ".", "BIG_ENDIAN", ")", "{", "return", "bytesToInt", "(", "bytes", "[", "0", "]", ",", "bytes", "[",...
Convert an array of two unsigned bytes with the given byte order to one signed int. @param bytes The bytes to be parsed @param order The byte order to be used @return An int representing the bytes in the given order
[ "Convert", "an", "array", "of", "two", "unsigned", "bytes", "with", "the", "given", "byte", "order", "to", "one", "signed", "int", "." ]
dc33e8cc9258d6e028e0788d74735c75b54d1133
https://github.com/PunchThrough/bean-sdk-android/blob/dc33e8cc9258d6e028e0788d74735c75b54d1133/sdk/src/main/java/com/punchthrough/bean/sdk/internal/utility/Convert.java#L61-L73
train
PunchThrough/bean-sdk-android
sdk/src/main/java/com/punchthrough/bean/sdk/internal/utility/Convert.java
Convert.intArrayToByteArray
public static byte[] intArrayToByteArray(int[] intArray) { byte[] byteArray = new byte[intArray.length]; for (int i = 0; i < intArray.length; i++) { byteArray[i] = intToByte(intArray[i]); } return byteArray; }
java
public static byte[] intArrayToByteArray(int[] intArray) { byte[] byteArray = new byte[intArray.length]; for (int i = 0; i < intArray.length; i++) { byteArray[i] = intToByte(intArray[i]); } return byteArray; }
[ "public", "static", "byte", "[", "]", "intArrayToByteArray", "(", "int", "[", "]", "intArray", ")", "{", "byte", "[", "]", "byteArray", "=", "new", "byte", "[", "intArray", ".", "length", "]", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", ...
Convert an array of ints to an array of unsigned bytes. This is useful when you want to construct a literal array of unsigned bytes with values greater than 127. Only the lowest 8 bits of the int values are used. @param intArray The array of ints to be converted @return The corresponding array of unsigned bytes
[ "Convert", "an", "array", "of", "ints", "to", "an", "array", "of", "unsigned", "bytes", ".", "This", "is", "useful", "when", "you", "want", "to", "construct", "a", "literal", "array", "of", "unsigned", "bytes", "with", "values", "greater", "than", "127", ...
dc33e8cc9258d6e028e0788d74735c75b54d1133
https://github.com/PunchThrough/bean-sdk-android/blob/dc33e8cc9258d6e028e0788d74735c75b54d1133/sdk/src/main/java/com/punchthrough/bean/sdk/internal/utility/Convert.java#L109-L119
train
PunchThrough/bean-sdk-android
sdk/src/main/java/com/punchthrough/bean/sdk/internal/utility/Convert.java
Convert.intToUInt32
public static byte[] intToUInt32(int i, ByteOrder endian) { int truncated = (int) ( (long) i ); return ByteBuffer.allocate(4).order(endian).putInt(truncated).array(); }
java
public static byte[] intToUInt32(int i, ByteOrder endian) { int truncated = (int) ( (long) i ); return ByteBuffer.allocate(4).order(endian).putInt(truncated).array(); }
[ "public", "static", "byte", "[", "]", "intToUInt32", "(", "int", "i", ",", "ByteOrder", "endian", ")", "{", "int", "truncated", "=", "(", "int", ")", "(", "(", "long", ")", "i", ")", ";", "return", "ByteBuffer", ".", "allocate", "(", "4", ")", ".",...
Convert an int to a four-byte array of its representation as an unsigned byte. @param i The int to be converted @param endian The {@link java.nio.ByteOrder} endianness of the desired byte array @return The array of bytes representing the 32-bit unsigned integer
[ "Convert", "an", "int", "to", "a", "four", "-", "byte", "array", "of", "its", "representation", "as", "an", "unsigned", "byte", "." ]
dc33e8cc9258d6e028e0788d74735c75b54d1133
https://github.com/PunchThrough/bean-sdk-android/blob/dc33e8cc9258d6e028e0788d74735c75b54d1133/sdk/src/main/java/com/punchthrough/bean/sdk/internal/utility/Convert.java#L128-L131
train
PunchThrough/bean-sdk-android
sdk/src/main/java/com/punchthrough/bean/sdk/internal/serial/GattSerialMessage.java
GattSerialMessage.fromPayload
public static GattSerialMessage fromPayload(byte[] payload) { Buffer buffer = new Buffer(); byte[] header = new byte[2]; header[0] = (byte) (payload.length & 0xff); header[1] = 0; int crc = computeCRC16(header, 0, header.length); crc = computeCRC16(crc, payload, 0, payload.length); buffer.write(header); buffer.write(payload); buffer.writeByte(crc & 0xff); buffer.writeByte((crc >> 8) & 0xff); return new GattSerialMessage(buffer); }
java
public static GattSerialMessage fromPayload(byte[] payload) { Buffer buffer = new Buffer(); byte[] header = new byte[2]; header[0] = (byte) (payload.length & 0xff); header[1] = 0; int crc = computeCRC16(header, 0, header.length); crc = computeCRC16(crc, payload, 0, payload.length); buffer.write(header); buffer.write(payload); buffer.writeByte(crc & 0xff); buffer.writeByte((crc >> 8) & 0xff); return new GattSerialMessage(buffer); }
[ "public", "static", "GattSerialMessage", "fromPayload", "(", "byte", "[", "]", "payload", ")", "{", "Buffer", "buffer", "=", "new", "Buffer", "(", ")", ";", "byte", "[", "]", "header", "=", "new", "byte", "[", "2", "]", ";", "header", "[", "0", "]", ...
Create a GattSerialMessage from a byte array payload In this case, "payload" means the properly packed message ID and message payload. Example: For the message CC_LED_WRITE_ALL (0x2001) GattSerialMessage.fromPayload(new byte[] { 0x20, 0x01, <--- Message ID big endian 0x00, 0x00, 0x00, <--- Payload data little endian }); @param payload Byte array of the message payload
[ "Create", "a", "GattSerialMessage", "from", "a", "byte", "array", "payload" ]
dc33e8cc9258d6e028e0788d74735c75b54d1133
https://github.com/PunchThrough/bean-sdk-android/blob/dc33e8cc9258d6e028e0788d74735c75b54d1133/sdk/src/main/java/com/punchthrough/bean/sdk/internal/serial/GattSerialMessage.java#L54-L66
train
kwon37xi/hibernate4-memcached
hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/IntToBytesUtils.java
IntToBytesUtils.bytesToInt
public static int bytesToInt(byte[] bytes) { int value = ((int) bytes[0] & 0xFF) << 24; value += ((int) bytes[1] & 0xFF) << 16; value += ((int) bytes[2] & 0xFF) << 8; value += (int) bytes[3] & 0xFF; return value; }
java
public static int bytesToInt(byte[] bytes) { int value = ((int) bytes[0] & 0xFF) << 24; value += ((int) bytes[1] & 0xFF) << 16; value += ((int) bytes[2] & 0xFF) << 8; value += (int) bytes[3] & 0xFF; return value; }
[ "public", "static", "int", "bytesToInt", "(", "byte", "[", "]", "bytes", ")", "{", "int", "value", "=", "(", "(", "int", ")", "bytes", "[", "0", "]", "&", "0xFF", ")", "<<", "24", ";", "value", "+=", "(", "(", "int", ")", "bytes", "[", "1", "...
4 bytes array to int
[ "4", "bytes", "array", "to", "int" ]
e0b2839ab257b2602344f54ca53c564044f3585d
https://github.com/kwon37xi/hibernate4-memcached/blob/e0b2839ab257b2602344f54ca53c564044f3585d/hibernate4-memcached-core/src/main/java/kr/pe/kwonnam/hibernate4memcached/util/IntToBytesUtils.java#L20-L26
train
PunchThrough/bean-sdk-android
sdk/src/main/java/com/punchthrough/bean/sdk/internal/ble/SendBuffer.java
SendBuffer.send
public void send(byte[] data, int id) { boolean isFirstPacket = (packets.size() == 0); packets.add(data); ids.add(id); if (isFirstPacket) { scheduleSendTask(true); } Log.d(TAG, "Added packet " + id + " to buffer; " + packets.size() + " packets in buffer"); }
java
public void send(byte[] data, int id) { boolean isFirstPacket = (packets.size() == 0); packets.add(data); ids.add(id); if (isFirstPacket) { scheduleSendTask(true); } Log.d(TAG, "Added packet " + id + " to buffer; " + packets.size() + " packets in buffer"); }
[ "public", "void", "send", "(", "byte", "[", "]", "data", ",", "int", "id", ")", "{", "boolean", "isFirstPacket", "=", "(", "packets", ".", "size", "(", ")", "==", "0", ")", ";", "packets", ".", "add", "(", "data", ")", ";", "ids", ".", "add", "...
Add a packet to the buffer to be sent. If no other packets are in the buffer, it will be sent immediately. @param data The packet to be sent @param id The ID of the packet to be used in debug messages and callbacks
[ "Add", "a", "packet", "to", "the", "buffer", "to", "be", "sent", ".", "If", "no", "other", "packets", "are", "in", "the", "buffer", "it", "will", "be", "sent", "immediately", "." ]
dc33e8cc9258d6e028e0788d74735c75b54d1133
https://github.com/PunchThrough/bean-sdk-android/blob/dc33e8cc9258d6e028e0788d74735c75b54d1133/sdk/src/main/java/com/punchthrough/bean/sdk/internal/ble/SendBuffer.java#L49-L57
train
PunchThrough/bean-sdk-android
sdk/src/main/java/com/punchthrough/bean/sdk/internal/ble/SendBuffer.java
SendBuffer.scheduleSendTask
private void scheduleSendTask(boolean runNow) { TimerTask task = new TimerTask() { @Override public void run() { byte[] packet; try { packet = packets.get(0); } catch (IndexOutOfBoundsException e) { // No packets left; return without scheduling another run return; } charc.setValue(packet); boolean result = gattClient.writeCharacteristic(charc); if (result) { packets.remove(0); int id = ids.remove(0); retries = 0; if (onPacketSent != null) { onPacketSent.onResult(id); } Log.d(TAG, "Packet " + id + " sent after " + retries + " retries"); } else { retries++; } scheduleSendTask(false); } }; if (runNow) { task.run(); } else { sendTimer.schedule(task, SEND_INTERVAL); } }
java
private void scheduleSendTask(boolean runNow) { TimerTask task = new TimerTask() { @Override public void run() { byte[] packet; try { packet = packets.get(0); } catch (IndexOutOfBoundsException e) { // No packets left; return without scheduling another run return; } charc.setValue(packet); boolean result = gattClient.writeCharacteristic(charc); if (result) { packets.remove(0); int id = ids.remove(0); retries = 0; if (onPacketSent != null) { onPacketSent.onResult(id); } Log.d(TAG, "Packet " + id + " sent after " + retries + " retries"); } else { retries++; } scheduleSendTask(false); } }; if (runNow) { task.run(); } else { sendTimer.schedule(task, SEND_INTERVAL); } }
[ "private", "void", "scheduleSendTask", "(", "boolean", "runNow", ")", "{", "TimerTask", "task", "=", "new", "TimerTask", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "byte", "[", "]", "packet", ";", "try", "{", "packet", "=",...
Schedules the send task to run either immediately or at SEND_INTERVAL. @param runNow true runs the task immediately, false schedules it for SEND_INTERVAL ms from now
[ "Schedules", "the", "send", "task", "to", "run", "either", "immediately", "or", "at", "SEND_INTERVAL", "." ]
dc33e8cc9258d6e028e0788d74735c75b54d1133
https://github.com/PunchThrough/bean-sdk-android/blob/dc33e8cc9258d6e028e0788d74735c75b54d1133/sdk/src/main/java/com/punchthrough/bean/sdk/internal/ble/SendBuffer.java#L65-L110
train
RestComm/jain-slee.sip
examples/sip-uas/sbb/src/main/java/org/mobicents/slee/example/sip/SipUASExampleSbb.java
SipUASExampleSbb.setSbbContext
public void setSbbContext(SbbContext context) { sbbContext = (SbbContextExt) context; sipActivityContextInterfaceFactory = (SipActivityContextInterfaceFactory) sbbContext .getActivityContextInterfaceFactory(sipRATypeID); sleeSipProvider = (SleeSipProvider) sbbContext .getResourceAdaptorInterface(sipRATypeID, sipRALink); addressFactory = sleeSipProvider.getAddressFactory(); headerFactory = sleeSipProvider.getHeaderFactory(); messageFactory = sleeSipProvider.getMessageFactory(); timerFacility = sbbContext.getTimerFacility(); }
java
public void setSbbContext(SbbContext context) { sbbContext = (SbbContextExt) context; sipActivityContextInterfaceFactory = (SipActivityContextInterfaceFactory) sbbContext .getActivityContextInterfaceFactory(sipRATypeID); sleeSipProvider = (SleeSipProvider) sbbContext .getResourceAdaptorInterface(sipRATypeID, sipRALink); addressFactory = sleeSipProvider.getAddressFactory(); headerFactory = sleeSipProvider.getHeaderFactory(); messageFactory = sleeSipProvider.getMessageFactory(); timerFacility = sbbContext.getTimerFacility(); }
[ "public", "void", "setSbbContext", "(", "SbbContext", "context", ")", "{", "sbbContext", "=", "(", "SbbContextExt", ")", "context", ";", "sipActivityContextInterfaceFactory", "=", "(", "SipActivityContextInterfaceFactory", ")", "sbbContext", ".", "getActivityContextInterf...
SbbObject lifecycle methods
[ "SbbObject", "lifecycle", "methods" ]
2c173af0a760cb0ea13fe0ffa58c0f82b14731f9
https://github.com/RestComm/jain-slee.sip/blob/2c173af0a760cb0ea13fe0ffa58c0f82b14731f9/examples/sip-uas/sbb/src/main/java/org/mobicents/slee/example/sip/SipUASExampleSbb.java#L75-L85
train
RestComm/jain-slee.sip
examples/sip-uas/sbb/src/main/java/org/mobicents/slee/example/sip/SipUASExampleSbb.java
SipUASExampleSbb.getContactHeader
private ContactHeader getContactHeader() throws ParseException { if (contactHeader == null) { final ListeningPoint listeningPoint = sleeSipProvider .getListeningPoint("udp"); final javax.sip.address.SipURI sipURI = addressFactory .createSipURI(null, listeningPoint.getIPAddress()); sipURI.setPort(listeningPoint.getPort()); sipURI.setTransportParam(listeningPoint.getTransport()); contactHeader = headerFactory.createContactHeader(addressFactory .createAddress(sipURI)); } return contactHeader; }
java
private ContactHeader getContactHeader() throws ParseException { if (contactHeader == null) { final ListeningPoint listeningPoint = sleeSipProvider .getListeningPoint("udp"); final javax.sip.address.SipURI sipURI = addressFactory .createSipURI(null, listeningPoint.getIPAddress()); sipURI.setPort(listeningPoint.getPort()); sipURI.setTransportParam(listeningPoint.getTransport()); contactHeader = headerFactory.createContactHeader(addressFactory .createAddress(sipURI)); } return contactHeader; }
[ "private", "ContactHeader", "getContactHeader", "(", ")", "throws", "ParseException", "{", "if", "(", "contactHeader", "==", "null", ")", "{", "final", "ListeningPoint", "listeningPoint", "=", "sleeSipProvider", ".", "getListeningPoint", "(", "\"udp\"", ")", ";", ...
some helper methods to deal with lazy init of static fields
[ "some", "helper", "methods", "to", "deal", "with", "lazy", "init", "of", "static", "fields" ]
2c173af0a760cb0ea13fe0ffa58c0f82b14731f9
https://github.com/RestComm/jain-slee.sip/blob/2c173af0a760cb0ea13fe0ffa58c0f82b14731f9/examples/sip-uas/sbb/src/main/java/org/mobicents/slee/example/sip/SipUASExampleSbb.java#L121-L133
train
RestComm/jain-slee.sip
examples/sip-uas/sbb/src/main/java/org/mobicents/slee/example/sip/SipUASExampleSbb.java
SipUASExampleSbb.onInviteEvent
public void onInviteEvent(javax.sip.RequestEvent requestEvent, ActivityContextInterface aci) { final ServerTransaction serverTransaction = requestEvent .getServerTransaction(); try { // send "trying" response Response response = messageFactory.createResponse(Response.TRYING, requestEvent.getRequest()); serverTransaction.sendResponse(response); // get local object final SbbLocalObject sbbLocalObject = this.sbbContext .getSbbLocalObject(); // send 180 response = messageFactory.createResponse(Response.RINGING, requestEvent.getRequest()); serverTransaction.sendResponse(response); setFinalReplySent(false); // set timer of 1 secs on the dialog aci to send 200 OK after that timerFacility.setTimer(aci, null, System.currentTimeMillis() + 1000L, getTimerOptions()); } catch (Exception e) { getTracer().severe("failure while processing initial invite", e); } }
java
public void onInviteEvent(javax.sip.RequestEvent requestEvent, ActivityContextInterface aci) { final ServerTransaction serverTransaction = requestEvent .getServerTransaction(); try { // send "trying" response Response response = messageFactory.createResponse(Response.TRYING, requestEvent.getRequest()); serverTransaction.sendResponse(response); // get local object final SbbLocalObject sbbLocalObject = this.sbbContext .getSbbLocalObject(); // send 180 response = messageFactory.createResponse(Response.RINGING, requestEvent.getRequest()); serverTransaction.sendResponse(response); setFinalReplySent(false); // set timer of 1 secs on the dialog aci to send 200 OK after that timerFacility.setTimer(aci, null, System.currentTimeMillis() + 1000L, getTimerOptions()); } catch (Exception e) { getTracer().severe("failure while processing initial invite", e); } }
[ "public", "void", "onInviteEvent", "(", "javax", ".", "sip", ".", "RequestEvent", "requestEvent", ",", "ActivityContextInterface", "aci", ")", "{", "final", "ServerTransaction", "serverTransaction", "=", "requestEvent", ".", "getServerTransaction", "(", ")", ";", "t...
Event handler method for the invite SIP message. @param requestEvent @param aci
[ "Event", "handler", "method", "for", "the", "invite", "SIP", "message", "." ]
2c173af0a760cb0ea13fe0ffa58c0f82b14731f9
https://github.com/RestComm/jain-slee.sip/blob/2c173af0a760cb0ea13fe0ffa58c0f82b14731f9/examples/sip-uas/sbb/src/main/java/org/mobicents/slee/example/sip/SipUASExampleSbb.java#L169-L197
train
RestComm/jain-slee.sip
examples/sip-uas/sbb/src/main/java/org/mobicents/slee/example/sip/SipUASExampleSbb.java
SipUASExampleSbb.onTimerEvent
public void onTimerEvent(TimerEvent event, ActivityContextInterface aci) { if (getFinalReplySent()) { aci.detach(sbbContext.getSbbLocalObject()); final DialogActivity dialog = (DialogActivity) aci.getActivity(); try { dialog.sendRequest(dialog.createRequest(Request.BYE)); } catch (Exception e) { getTracer().severe("failure while processing timer event", e); } } else { // detach from the server tx activity aci.detach(sbbContext.getSbbLocalObject()); final ServerTransaction serverTransaction = (ServerTransaction) aci.getActivity(); try { // create dialog activity and attach to it final DialogActivity dialog = (DialogActivity) sleeSipProvider .getNewDialog(serverTransaction); final ActivityContextInterfaceExt dialogAci = (ActivityContextInterfaceExt) sipActivityContextInterfaceFactory .getActivityContextInterface(dialog); dialogAci.attach(sbbContext.getSbbLocalObject()); // send 200 ok Response response = messageFactory.createResponse(Response.OK,serverTransaction.getRequest()); response.addHeader(getContactHeader()); serverTransaction.sendResponse(response); setFinalReplySent(true); // set timer of 30 secs on the dialog aci to send bye timerFacility.setTimer(dialogAci, null, System.currentTimeMillis() + 60000L, getTimerOptions()); } catch (Exception e) { getTracer().severe("failure while sending 200 OK response", e); } } }
java
public void onTimerEvent(TimerEvent event, ActivityContextInterface aci) { if (getFinalReplySent()) { aci.detach(sbbContext.getSbbLocalObject()); final DialogActivity dialog = (DialogActivity) aci.getActivity(); try { dialog.sendRequest(dialog.createRequest(Request.BYE)); } catch (Exception e) { getTracer().severe("failure while processing timer event", e); } } else { // detach from the server tx activity aci.detach(sbbContext.getSbbLocalObject()); final ServerTransaction serverTransaction = (ServerTransaction) aci.getActivity(); try { // create dialog activity and attach to it final DialogActivity dialog = (DialogActivity) sleeSipProvider .getNewDialog(serverTransaction); final ActivityContextInterfaceExt dialogAci = (ActivityContextInterfaceExt) sipActivityContextInterfaceFactory .getActivityContextInterface(dialog); dialogAci.attach(sbbContext.getSbbLocalObject()); // send 200 ok Response response = messageFactory.createResponse(Response.OK,serverTransaction.getRequest()); response.addHeader(getContactHeader()); serverTransaction.sendResponse(response); setFinalReplySent(true); // set timer of 30 secs on the dialog aci to send bye timerFacility.setTimer(dialogAci, null, System.currentTimeMillis() + 60000L, getTimerOptions()); } catch (Exception e) { getTracer().severe("failure while sending 200 OK response", e); } } }
[ "public", "void", "onTimerEvent", "(", "TimerEvent", "event", ",", "ActivityContextInterface", "aci", ")", "{", "if", "(", "getFinalReplySent", "(", ")", ")", "{", "aci", ".", "detach", "(", "sbbContext", ".", "getSbbLocalObject", "(", ")", ")", ";", "final"...
Event handler method for the timer event. @param event @param aci
[ "Event", "handler", "method", "for", "the", "timer", "event", "." ]
2c173af0a760cb0ea13fe0ffa58c0f82b14731f9
https://github.com/RestComm/jain-slee.sip/blob/2c173af0a760cb0ea13fe0ffa58c0f82b14731f9/examples/sip-uas/sbb/src/main/java/org/mobicents/slee/example/sip/SipUASExampleSbb.java#L205-L246
train
RestComm/jain-slee.sip
examples/sip-jdbc-registrar/sbb/src/main/java/org/mobicents/slee/example/sjr/sip/SIPRegistrarSbb.java
SIPRegistrarSbb.getBindingsResult
@Override public void getBindingsResult(int resultCode, List<RegistrationBinding> bindings) { ServerTransaction serverTransaction = getRegisterTransactionToReply(); if (serverTransaction == null) { tracer.warning("failed to find SIP server tx to send response"); return; } try { if (resultCode < 300) { sendRegisterSuccessResponse(resultCode, bindings, serverTransaction); } else { sendErrorResponse(resultCode, serverTransaction); } } catch (Exception e) { tracer.severe("failed to send SIP response", e); } }
java
@Override public void getBindingsResult(int resultCode, List<RegistrationBinding> bindings) { ServerTransaction serverTransaction = getRegisterTransactionToReply(); if (serverTransaction == null) { tracer.warning("failed to find SIP server tx to send response"); return; } try { if (resultCode < 300) { sendRegisterSuccessResponse(resultCode, bindings, serverTransaction); } else { sendErrorResponse(resultCode, serverTransaction); } } catch (Exception e) { tracer.severe("failed to send SIP response", e); } }
[ "@", "Override", "public", "void", "getBindingsResult", "(", "int", "resultCode", ",", "List", "<", "RegistrationBinding", ">", "bindings", ")", "{", "ServerTransaction", "serverTransaction", "=", "getRegisterTransactionToReply", "(", ")", ";", "if", "(", "serverTra...
call backs from data source child sbb
[ "call", "backs", "from", "data", "source", "child", "sbb" ]
2c173af0a760cb0ea13fe0ffa58c0f82b14731f9
https://github.com/RestComm/jain-slee.sip/blob/2c173af0a760cb0ea13fe0ffa58c0f82b14731f9/examples/sip-jdbc-registrar/sbb/src/main/java/org/mobicents/slee/example/sjr/sip/SIPRegistrarSbb.java#L371-L389
train
RestComm/jain-slee.sip
examples/sip-jdbc-registrar/sbb/src/main/java/org/mobicents/slee/example/sjr/sip/SIPRegistrarSbb.java
SIPRegistrarSbb.cancelTimers
private void cancelTimers( List<org.mobicents.slee.example.sjr.data.RegistrationBinding> removedContacts) { for (RegistrationBinding binding : removedContacts) { ActivityContextInterfaceExt aci = (ActivityContextInterfaceExt) this.activityContextNamingFacility .lookup(getACIName(binding.getContactAddress(), binding.getSipAddress())); // IF exists end the activity, SLEE will cancel timers, remove aci // names, etc. if (aci != null) { ((NullActivity) aci.getActivity()).endActivity(); } } }
java
private void cancelTimers( List<org.mobicents.slee.example.sjr.data.RegistrationBinding> removedContacts) { for (RegistrationBinding binding : removedContacts) { ActivityContextInterfaceExt aci = (ActivityContextInterfaceExt) this.activityContextNamingFacility .lookup(getACIName(binding.getContactAddress(), binding.getSipAddress())); // IF exists end the activity, SLEE will cancel timers, remove aci // names, etc. if (aci != null) { ((NullActivity) aci.getActivity()).endActivity(); } } }
[ "private", "void", "cancelTimers", "(", "List", "<", "org", ".", "mobicents", ".", "slee", ".", "example", ".", "sjr", ".", "data", ".", "RegistrationBinding", ">", "removedContacts", ")", "{", "for", "(", "RegistrationBinding", "binding", ":", "removedContact...
Simple method to cancel pending timers for contacts that have been removed @param removedContacts
[ "Simple", "method", "to", "cancel", "pending", "timers", "for", "contacts", "that", "have", "been", "removed" ]
2c173af0a760cb0ea13fe0ffa58c0f82b14731f9
https://github.com/RestComm/jain-slee.sip/blob/2c173af0a760cb0ea13fe0ffa58c0f82b14731f9/examples/sip-jdbc-registrar/sbb/src/main/java/org/mobicents/slee/example/sjr/sip/SIPRegistrarSbb.java#L543-L555
train
RestComm/jain-slee.sip
examples/sip-jdbc-registrar/sbb/src/main/java/org/mobicents/slee/example/sjr/sip/SIPRegistrarSbb.java
SIPRegistrarSbb.updateTimers
private void updateTimers( List<org.mobicents.slee.example.sjr.data.RegistrationBinding> contacts) { String bindingAciName = null; ActivityContextInterface aci = null; for (RegistrationBinding binding : contacts) { bindingAciName = getACIName(binding.getContactAddress(), binding.getSipAddress()); aci = this.activityContextNamingFacility.lookup(bindingAciName); if (aci != null) { // binding update, cancel old timer for (TimerID timerID : ((ActivityContextInterfaceExt) aci) .getTimers()) { this.timerFacility.cancelTimer(timerID); } // NOTE: DO NOT END activity, we will reuse it. } else { // binding creation, create null aci, bind a name and store the // jdbc task for removal (to run if timer expires) NullActivity nullActivity = this.nullActivityFactory .createNullActivity(); aci = this.nullActivityContextInterfaceFactory .getActivityContextInterface(nullActivity); // NOTE: DO NOT ATTACH to activity, so the sbb entity is // claimed. The timer event is initial! // set name try { this.activityContextNamingFacility .bind(aci, bindingAciName); } catch (Exception e) { this.tracer.severe("Failed to bind aci name " + bindingAciName, e); } SbbActivityContextInterface rgAci = asSbbActivityContextInterface(aci); rgAci.setData(new RegistrationBindingData().setAddress( binding.getSipAddress()).setContact( binding.getContactAddress())); } // set new timer timerFacility.setTimer(aci, null, System.currentTimeMillis() + ((binding.getExpires() + 1) * 1000), defaultTimerOptions); } }
java
private void updateTimers( List<org.mobicents.slee.example.sjr.data.RegistrationBinding> contacts) { String bindingAciName = null; ActivityContextInterface aci = null; for (RegistrationBinding binding : contacts) { bindingAciName = getACIName(binding.getContactAddress(), binding.getSipAddress()); aci = this.activityContextNamingFacility.lookup(bindingAciName); if (aci != null) { // binding update, cancel old timer for (TimerID timerID : ((ActivityContextInterfaceExt) aci) .getTimers()) { this.timerFacility.cancelTimer(timerID); } // NOTE: DO NOT END activity, we will reuse it. } else { // binding creation, create null aci, bind a name and store the // jdbc task for removal (to run if timer expires) NullActivity nullActivity = this.nullActivityFactory .createNullActivity(); aci = this.nullActivityContextInterfaceFactory .getActivityContextInterface(nullActivity); // NOTE: DO NOT ATTACH to activity, so the sbb entity is // claimed. The timer event is initial! // set name try { this.activityContextNamingFacility .bind(aci, bindingAciName); } catch (Exception e) { this.tracer.severe("Failed to bind aci name " + bindingAciName, e); } SbbActivityContextInterface rgAci = asSbbActivityContextInterface(aci); rgAci.setData(new RegistrationBindingData().setAddress( binding.getSipAddress()).setContact( binding.getContactAddress())); } // set new timer timerFacility.setTimer(aci, null, System.currentTimeMillis() + ((binding.getExpires() + 1) * 1000), defaultTimerOptions); } }
[ "private", "void", "updateTimers", "(", "List", "<", "org", ".", "mobicents", ".", "slee", ".", "example", ".", "sjr", ".", "data", ".", "RegistrationBinding", ">", "contacts", ")", "{", "String", "bindingAciName", "=", "null", ";", "ActivityContextInterface",...
Simple method to update timers for passed contacts. If timer exists, it will be reset to new timeout. If it does not exist, it will be create along with NullActivity. @param contacts
[ "Simple", "method", "to", "update", "timers", "for", "passed", "contacts", ".", "If", "timer", "exists", "it", "will", "be", "reset", "to", "new", "timeout", ".", "If", "it", "does", "not", "exist", "it", "will", "be", "create", "along", "with", "NullAct...
2c173af0a760cb0ea13fe0ffa58c0f82b14731f9
https://github.com/RestComm/jain-slee.sip/blob/2c173af0a760cb0ea13fe0ffa58c0f82b14731f9/examples/sip-jdbc-registrar/sbb/src/main/java/org/mobicents/slee/example/sjr/sip/SIPRegistrarSbb.java#L564-L607
train
RestComm/jain-slee.sip
resources/sip11/ra/src/main/java/org/mobicents/slee/resource/sip11/SipResourceAdaptor.java
SipResourceAdaptor.getDialogWrapper
public DialogWrapper getDialogWrapper(Dialog d) { if (d == null) { return null; } DialogWrapper dw = null; DialogWrapperAppData dwad = (DialogWrapperAppData) d.getApplicationData(); if (dwad != null) { dw = dwad.getDialogWrapper(d, this); } return dw; }
java
public DialogWrapper getDialogWrapper(Dialog d) { if (d == null) { return null; } DialogWrapper dw = null; DialogWrapperAppData dwad = (DialogWrapperAppData) d.getApplicationData(); if (dwad != null) { dw = dwad.getDialogWrapper(d, this); } return dw; }
[ "public", "DialogWrapper", "getDialogWrapper", "(", "Dialog", "d", ")", "{", "if", "(", "d", "==", "null", ")", "{", "return", "null", ";", "}", "DialogWrapper", "dw", "=", "null", ";", "DialogWrapperAppData", "dwad", "=", "(", "DialogWrapperAppData", ")", ...
Retrieves the wrapper associated with a dialog, recreating if needed in a cluster env. @param d @return
[ "Retrieves", "the", "wrapper", "associated", "with", "a", "dialog", "recreating", "if", "needed", "in", "a", "cluster", "env", "." ]
2c173af0a760cb0ea13fe0ffa58c0f82b14731f9
https://github.com/RestComm/jain-slee.sip/blob/2c173af0a760cb0ea13fe0ffa58c0f82b14731f9/resources/sip11/ra/src/main/java/org/mobicents/slee/resource/sip11/SipResourceAdaptor.java#L393-L403
train
RestComm/jain-slee.sip
resources/sip11/ra/src/main/java/org/mobicents/slee/resource/sip11/SipResourceAdaptor.java
SipResourceAdaptor.getTransactionWrapper
public TransactionWrapper getTransactionWrapper(Transaction t) { if (t == null) { return null; } final TransactionWrapperAppData twad = (TransactionWrapperAppData) t.getApplicationData(); return twad != null ? twad.getTransactionWrapper(t, this) : null; }
java
public TransactionWrapper getTransactionWrapper(Transaction t) { if (t == null) { return null; } final TransactionWrapperAppData twad = (TransactionWrapperAppData) t.getApplicationData(); return twad != null ? twad.getTransactionWrapper(t, this) : null; }
[ "public", "TransactionWrapper", "getTransactionWrapper", "(", "Transaction", "t", ")", "{", "if", "(", "t", "==", "null", ")", "{", "return", "null", ";", "}", "final", "TransactionWrapperAppData", "twad", "=", "(", "TransactionWrapperAppData", ")", "t", ".", ...
Retrieves the wrapper associated with a tx, recreating if needed in a cluster env. @param t @return
[ "Retrieves", "the", "wrapper", "associated", "with", "a", "tx", "recreating", "if", "needed", "in", "a", "cluster", "env", "." ]
2c173af0a760cb0ea13fe0ffa58c0f82b14731f9
https://github.com/RestComm/jain-slee.sip/blob/2c173af0a760cb0ea13fe0ffa58c0f82b14731f9/resources/sip11/ra/src/main/java/org/mobicents/slee/resource/sip11/SipResourceAdaptor.java#L410-L416
train
RestComm/jain-slee.sip
resources/sip11/ra/src/main/java/org/mobicents/slee/resource/sip11/Utils.java
Utils.getRouteList
public static List<RouteHeader> getRouteList(Response response, HeaderFactory headerFactory) throws ParseException { // we have record route set, as we are client, this is reversed final ArrayList<RouteHeader> routeList = new ArrayList<RouteHeader>(); final ListIterator<?> rrLit = response.getHeaders(RecordRouteHeader.NAME); while (rrLit.hasNext()) { final RecordRouteHeader rrh = (RecordRouteHeader) rrLit.next(); final RouteHeader rh = headerFactory.createRouteHeader(rrh.getAddress()); final Iterator<?> pIt = rrh.getParameterNames(); while (pIt.hasNext()) { final String pName = (String) pIt.next(); rh.setParameter(pName, rrh.getParameter(pName)); } routeList.add(0, rh); } return routeList; }
java
public static List<RouteHeader> getRouteList(Response response, HeaderFactory headerFactory) throws ParseException { // we have record route set, as we are client, this is reversed final ArrayList<RouteHeader> routeList = new ArrayList<RouteHeader>(); final ListIterator<?> rrLit = response.getHeaders(RecordRouteHeader.NAME); while (rrLit.hasNext()) { final RecordRouteHeader rrh = (RecordRouteHeader) rrLit.next(); final RouteHeader rh = headerFactory.createRouteHeader(rrh.getAddress()); final Iterator<?> pIt = rrh.getParameterNames(); while (pIt.hasNext()) { final String pName = (String) pIt.next(); rh.setParameter(pName, rrh.getParameter(pName)); } routeList.add(0, rh); } return routeList; }
[ "public", "static", "List", "<", "RouteHeader", ">", "getRouteList", "(", "Response", "response", ",", "HeaderFactory", "headerFactory", ")", "throws", "ParseException", "{", "// we have record route set, as we are client, this is reversed", "final", "ArrayList", "<", "Rout...
Generates route list the same way dialog does. @param response @return @throws ParseException
[ "Generates", "route", "list", "the", "same", "way", "dialog", "does", "." ]
2c173af0a760cb0ea13fe0ffa58c0f82b14731f9
https://github.com/RestComm/jain-slee.sip/blob/2c173af0a760cb0ea13fe0ffa58c0f82b14731f9/resources/sip11/ra/src/main/java/org/mobicents/slee/resource/sip11/Utils.java#L119-L134
train
RestComm/jain-slee.sip
resources/sip11/ra/src/main/java/org/mobicents/slee/resource/sip11/Utils.java
Utils.getRequestUri
public static URI getRequestUri(Response response, AddressFactory addressFactory) throws ParseException { final ContactHeader contact = ((ContactHeader) response.getHeader(ContactHeader.NAME)); return (contact != null) ? (URI) contact.getAddress().getURI().clone() : null; }
java
public static URI getRequestUri(Response response, AddressFactory addressFactory) throws ParseException { final ContactHeader contact = ((ContactHeader) response.getHeader(ContactHeader.NAME)); return (contact != null) ? (URI) contact.getAddress().getURI().clone() : null; }
[ "public", "static", "URI", "getRequestUri", "(", "Response", "response", ",", "AddressFactory", "addressFactory", ")", "throws", "ParseException", "{", "final", "ContactHeader", "contact", "=", "(", "(", "ContactHeader", ")", "response", ".", "getHeader", "(", "Co...
Forges Request-URI using contact and To name par to address URI, this is required on dialog fork, this is how target is determined @param response @return @throws ParseException
[ "Forges", "Request", "-", "URI", "using", "contact", "and", "To", "name", "par", "to", "address", "URI", "this", "is", "required", "on", "dialog", "fork", "this", "is", "how", "target", "is", "determined" ]
2c173af0a760cb0ea13fe0ffa58c0f82b14731f9
https://github.com/RestComm/jain-slee.sip/blob/2c173af0a760cb0ea13fe0ffa58c0f82b14731f9/resources/sip11/ra/src/main/java/org/mobicents/slee/resource/sip11/Utils.java#L144-L147
train
RestComm/jain-slee.sip
examples/sip-wake-up/sbb/src/main/java/org/mobicents/slee/examples/wakeup/WakeUpSbb.java
WakeUpSbb.onMessageEvent
public void onMessageEvent(javax.sip.RequestEvent event, ActivityContextInterface aci) { final Request request = event.getRequest(); try { // message body should be *FIRST_TOKEN<timer value in // seconds>MIDDLE_TOKEN<msg to send back to UA>LAST_TOKEN* final String body = new String(request.getRawContent()); final int firstTokenStart = body.indexOf(FIRST_TOKEN); final int timerDurationStart = firstTokenStart + FIRST_TOKEN_LENGTH; final int middleTokenStart = body.indexOf(MIDDLE_TOKEN, timerDurationStart); final int bodyMessageStart = middleTokenStart + MIDDLE_TOKEN_LENGTH; final int lastTokenStart = body.indexOf(LAST_TOKEN, bodyMessageStart); if (firstTokenStart > -1 && middleTokenStart > -1 && lastTokenStart > -1) { // extract the timer duration final int timerDuration = Integer.parseInt(body.substring( timerDurationStart, middleTokenStart)); // create a null AC and attach the sbb local object final ActivityContextInterface timerACI = this.nullACIFactory .getActivityContextInterface(this.nullActivityFactory .createNullActivity()); timerACI.attach(sbbContext.getSbbLocalObject()); // set the timer on the null AC, because the one from this event // will end as soon as we send back the 200 ok this.timerFacility.setTimer(timerACI, null, System .currentTimeMillis() + (timerDuration * 1000), new TimerOptions()); // extract the body message final String bodyMessage = body.substring(bodyMessageStart, lastTokenStart); // store it in a cmp field setBody(bodyMessage); // do the same for the call id setCallId((CallIdHeader) request.getHeader(CallIdHeader.NAME)); // also store the sender's address, so we can send the wake up // message final FromHeader fromHeader = (FromHeader) request .getHeader(FromHeader.NAME); if (tracer.isInfoEnabled()) { tracer.info("Received a valid message from " + fromHeader.getAddress() + " requesting a reply containing '" + bodyMessage + "' after " + timerDuration + "s"); } setSender(fromHeader.getAddress()); // finally reply to the SIP message request sendResponse(event, Response.OK); } else { // parsing failed tracer.warning("Invalid msg '" + body + "' received"); sendResponse(event, Response.BAD_REQUEST); } } catch (Throwable e) { // oh oh something wrong happened tracer.severe("Exception while processing MESSAGE", e); try { sendResponse(event, Response.SERVER_INTERNAL_ERROR); } catch (Exception f) { tracer.severe("Exception while sending SERVER INTERNAL ERROR", f); } } }
java
public void onMessageEvent(javax.sip.RequestEvent event, ActivityContextInterface aci) { final Request request = event.getRequest(); try { // message body should be *FIRST_TOKEN<timer value in // seconds>MIDDLE_TOKEN<msg to send back to UA>LAST_TOKEN* final String body = new String(request.getRawContent()); final int firstTokenStart = body.indexOf(FIRST_TOKEN); final int timerDurationStart = firstTokenStart + FIRST_TOKEN_LENGTH; final int middleTokenStart = body.indexOf(MIDDLE_TOKEN, timerDurationStart); final int bodyMessageStart = middleTokenStart + MIDDLE_TOKEN_LENGTH; final int lastTokenStart = body.indexOf(LAST_TOKEN, bodyMessageStart); if (firstTokenStart > -1 && middleTokenStart > -1 && lastTokenStart > -1) { // extract the timer duration final int timerDuration = Integer.parseInt(body.substring( timerDurationStart, middleTokenStart)); // create a null AC and attach the sbb local object final ActivityContextInterface timerACI = this.nullACIFactory .getActivityContextInterface(this.nullActivityFactory .createNullActivity()); timerACI.attach(sbbContext.getSbbLocalObject()); // set the timer on the null AC, because the one from this event // will end as soon as we send back the 200 ok this.timerFacility.setTimer(timerACI, null, System .currentTimeMillis() + (timerDuration * 1000), new TimerOptions()); // extract the body message final String bodyMessage = body.substring(bodyMessageStart, lastTokenStart); // store it in a cmp field setBody(bodyMessage); // do the same for the call id setCallId((CallIdHeader) request.getHeader(CallIdHeader.NAME)); // also store the sender's address, so we can send the wake up // message final FromHeader fromHeader = (FromHeader) request .getHeader(FromHeader.NAME); if (tracer.isInfoEnabled()) { tracer.info("Received a valid message from " + fromHeader.getAddress() + " requesting a reply containing '" + bodyMessage + "' after " + timerDuration + "s"); } setSender(fromHeader.getAddress()); // finally reply to the SIP message request sendResponse(event, Response.OK); } else { // parsing failed tracer.warning("Invalid msg '" + body + "' received"); sendResponse(event, Response.BAD_REQUEST); } } catch (Throwable e) { // oh oh something wrong happened tracer.severe("Exception while processing MESSAGE", e); try { sendResponse(event, Response.SERVER_INTERNAL_ERROR); } catch (Exception f) { tracer.severe("Exception while sending SERVER INTERNAL ERROR", f); } } }
[ "public", "void", "onMessageEvent", "(", "javax", ".", "sip", ".", "RequestEvent", "event", ",", "ActivityContextInterface", "aci", ")", "{", "final", "Request", "request", "=", "event", ".", "getRequest", "(", ")", ";", "try", "{", "// message body should be *F...
Event handler for the SIP MESSAGE from the UA @param event @param aci
[ "Event", "handler", "for", "the", "SIP", "MESSAGE", "from", "the", "UA" ]
2c173af0a760cb0ea13fe0ffa58c0f82b14731f9
https://github.com/RestComm/jain-slee.sip/blob/2c173af0a760cb0ea13fe0ffa58c0f82b14731f9/examples/sip-wake-up/sbb/src/main/java/org/mobicents/slee/examples/wakeup/WakeUpSbb.java#L236-L301
train
RestComm/jain-slee.sip
examples/sip-wake-up/sbb/src/main/java/org/mobicents/slee/examples/wakeup/WakeUpSbb.java
WakeUpSbb.onTimerEvent
public void onTimerEvent(TimerEvent event, ActivityContextInterface aci) { // detaching so the null AC is claimed after the event handling aci.detach(sbbContext.getSbbLocalObject()); try { DataSourceChildSbbLocalInterface child = (DataSourceChildSbbLocalInterface) getLocationChildRelation().create(); child.getBindings(getSender().getURI().toString()); } catch (Exception e) { tracer.severe("failed to create sip registrar child sbb, to lookup the sender's contacts",e); return; } }
java
public void onTimerEvent(TimerEvent event, ActivityContextInterface aci) { // detaching so the null AC is claimed after the event handling aci.detach(sbbContext.getSbbLocalObject()); try { DataSourceChildSbbLocalInterface child = (DataSourceChildSbbLocalInterface) getLocationChildRelation().create(); child.getBindings(getSender().getURI().toString()); } catch (Exception e) { tracer.severe("failed to create sip registrar child sbb, to lookup the sender's contacts",e); return; } }
[ "public", "void", "onTimerEvent", "(", "TimerEvent", "event", ",", "ActivityContextInterface", "aci", ")", "{", "// detaching so the null AC is claimed after the event handling", "aci", ".", "detach", "(", "sbbContext", ".", "getSbbLocalObject", "(", ")", ")", ";", "try...
Event handler from the timer event, which signals that a message must be sent back to the UA @param event @param aci
[ "Event", "handler", "from", "the", "timer", "event", "which", "signals", "that", "a", "message", "must", "be", "sent", "back", "to", "the", "UA" ]
2c173af0a760cb0ea13fe0ffa58c0f82b14731f9
https://github.com/RestComm/jain-slee.sip/blob/2c173af0a760cb0ea13fe0ffa58c0f82b14731f9/examples/sip-wake-up/sbb/src/main/java/org/mobicents/slee/examples/wakeup/WakeUpSbb.java#L310-L320
train
RestComm/jain-slee.sip
resources/sip11/ra/src/main/java/org/mobicents/slee/resource/sip11/EventIDFilter.java
EventIDFilter.serviceActive
public void serviceActive(ReceivableService receivableService) { for (ReceivableEvent receivableEvent : receivableService.getReceivableEvents()) { Set<ServiceID> servicesReceivingEvent = eventID2serviceIDs.get(receivableEvent.getEventType()); if (servicesReceivingEvent == null) { servicesReceivingEvent = new HashSet<ServiceID>(); Set<ServiceID> anotherSet = eventID2serviceIDs.putIfAbsent(receivableEvent.getEventType(), servicesReceivingEvent); if (anotherSet != null) { servicesReceivingEvent = anotherSet; } } synchronized (servicesReceivingEvent) { servicesReceivingEvent.add(receivableService.getService()); } } }
java
public void serviceActive(ReceivableService receivableService) { for (ReceivableEvent receivableEvent : receivableService.getReceivableEvents()) { Set<ServiceID> servicesReceivingEvent = eventID2serviceIDs.get(receivableEvent.getEventType()); if (servicesReceivingEvent == null) { servicesReceivingEvent = new HashSet<ServiceID>(); Set<ServiceID> anotherSet = eventID2serviceIDs.putIfAbsent(receivableEvent.getEventType(), servicesReceivingEvent); if (anotherSet != null) { servicesReceivingEvent = anotherSet; } } synchronized (servicesReceivingEvent) { servicesReceivingEvent.add(receivableService.getService()); } } }
[ "public", "void", "serviceActive", "(", "ReceivableService", "receivableService", ")", "{", "for", "(", "ReceivableEvent", "receivableEvent", ":", "receivableService", ".", "getReceivableEvents", "(", ")", ")", "{", "Set", "<", "ServiceID", ">", "servicesReceivingEven...
Informs the filter that a receivable service is now active. For the events related with the service, and if there are no other services bound, then events of such event type should now not be filtered. @param receivableService
[ "Informs", "the", "filter", "that", "a", "receivable", "service", "is", "now", "active", ".", "For", "the", "events", "related", "with", "the", "service", "and", "if", "there", "are", "no", "other", "services", "bound", "then", "events", "of", "such", "eve...
2c173af0a760cb0ea13fe0ffa58c0f82b14731f9
https://github.com/RestComm/jain-slee.sip/blob/2c173af0a760cb0ea13fe0ffa58c0f82b14731f9/resources/sip11/ra/src/main/java/org/mobicents/slee/resource/sip11/EventIDFilter.java#L59-L73
train
RestComm/jain-slee.sip
resources/sip11/ra/src/main/java/org/mobicents/slee/resource/sip11/EventIDFilter.java
EventIDFilter.serviceInactive
public void serviceInactive(ReceivableService receivableService) { for (ReceivableEvent receivableEvent : receivableService.getReceivableEvents()) { Set<ServiceID> servicesReceivingEvent = eventID2serviceIDs.get(receivableEvent.getEventType()); if (servicesReceivingEvent != null) { synchronized (servicesReceivingEvent) { servicesReceivingEvent.remove(receivableService.getService()); } if(servicesReceivingEvent.isEmpty()) { eventID2serviceIDs.remove(receivableEvent.getEventType()); } } } }
java
public void serviceInactive(ReceivableService receivableService) { for (ReceivableEvent receivableEvent : receivableService.getReceivableEvents()) { Set<ServiceID> servicesReceivingEvent = eventID2serviceIDs.get(receivableEvent.getEventType()); if (servicesReceivingEvent != null) { synchronized (servicesReceivingEvent) { servicesReceivingEvent.remove(receivableService.getService()); } if(servicesReceivingEvent.isEmpty()) { eventID2serviceIDs.remove(receivableEvent.getEventType()); } } } }
[ "public", "void", "serviceInactive", "(", "ReceivableService", "receivableService", ")", "{", "for", "(", "ReceivableEvent", "receivableEvent", ":", "receivableService", ".", "getReceivableEvents", "(", ")", ")", "{", "Set", "<", "ServiceID", ">", "servicesReceivingEv...
Informs the filter that a receivable service is now inactive. For the events related with the service, if there are no other services bound, then events of such event type should be filtered @param receivableService
[ "Informs", "the", "filter", "that", "a", "receivable", "service", "is", "now", "inactive", ".", "For", "the", "events", "related", "with", "the", "service", "if", "there", "are", "no", "other", "services", "bound", "then", "events", "of", "such", "event", ...
2c173af0a760cb0ea13fe0ffa58c0f82b14731f9
https://github.com/RestComm/jain-slee.sip/blob/2c173af0a760cb0ea13fe0ffa58c0f82b14731f9/resources/sip11/ra/src/main/java/org/mobicents/slee/resource/sip11/EventIDFilter.java#L82-L94
train
RestComm/jain-slee.sip
resources/sip11/ra/src/main/java/org/mobicents/slee/resource/sip11/EventIDCache.java
EventIDCache.getEventId
public FireableEventType getEventId(EventLookupFacility eventLookupFacility, Request request, boolean inDialogActivity) { final String requestMethod = request.getMethod(); // Cancel is always the same. if (requestMethod.equals(Request.CANCEL)) inDialogActivity = false; FireableEventType eventID = null; if (inDialogActivity) { eventID = getEventId(eventLookupFacility, new StringBuilder(INDIALOG_REQUEST_EVENT_PREFIX).append(requestMethod).toString()); if (eventID == null) { eventID = getEventId(eventLookupFacility, new StringBuilder(INDIALOG_REQUEST_EVENT_PREFIX).append(SIP_EXTENSION_REQUEST_EVENT_NAME_SUFIX).toString()); } } else { eventID = getEventId(eventLookupFacility, new StringBuilder(OUT_OF_DIALOG_REQUEST_EVENT_PREFIX).append(requestMethod).toString()); if (eventID == null) { eventID = getEventId(eventLookupFacility, new StringBuilder(OUT_OF_DIALOG_REQUEST_EVENT_PREFIX).append(SIP_EXTENSION_REQUEST_EVENT_NAME_SUFIX).toString()); } } return eventID; }
java
public FireableEventType getEventId(EventLookupFacility eventLookupFacility, Request request, boolean inDialogActivity) { final String requestMethod = request.getMethod(); // Cancel is always the same. if (requestMethod.equals(Request.CANCEL)) inDialogActivity = false; FireableEventType eventID = null; if (inDialogActivity) { eventID = getEventId(eventLookupFacility, new StringBuilder(INDIALOG_REQUEST_EVENT_PREFIX).append(requestMethod).toString()); if (eventID == null) { eventID = getEventId(eventLookupFacility, new StringBuilder(INDIALOG_REQUEST_EVENT_PREFIX).append(SIP_EXTENSION_REQUEST_EVENT_NAME_SUFIX).toString()); } } else { eventID = getEventId(eventLookupFacility, new StringBuilder(OUT_OF_DIALOG_REQUEST_EVENT_PREFIX).append(requestMethod).toString()); if (eventID == null) { eventID = getEventId(eventLookupFacility, new StringBuilder(OUT_OF_DIALOG_REQUEST_EVENT_PREFIX).append(SIP_EXTENSION_REQUEST_EVENT_NAME_SUFIX).toString()); } } return eventID; }
[ "public", "FireableEventType", "getEventId", "(", "EventLookupFacility", "eventLookupFacility", ",", "Request", "request", ",", "boolean", "inDialogActivity", ")", "{", "final", "String", "requestMethod", "=", "request", ".", "getMethod", "(", ")", ";", "// Cancel is ...
Retrieves the event id for a SIP Request event. @param eventLookupFacility @param request @param inDialogActivity if the event occurred in a dialog activity or not @return
[ "Retrieves", "the", "event", "id", "for", "a", "SIP", "Request", "event", "." ]
2c173af0a760cb0ea13fe0ffa58c0f82b14731f9
https://github.com/RestComm/jain-slee.sip/blob/2c173af0a760cb0ea13fe0ffa58c0f82b14731f9/resources/sip11/ra/src/main/java/org/mobicents/slee/resource/sip11/EventIDCache.java#L73-L99
train
RestComm/jain-slee.sip
resources/sip11/ra/src/main/java/org/mobicents/slee/resource/sip11/EventIDCache.java
EventIDCache.getEventId
public FireableEventType getEventId(EventLookupFacility eventLookupFacility, Response response) { String statusCodeName = null; final int responseStatus = response.getStatusCode(); if (responseStatus == 100) { statusCodeName = "TRYING"; } else if (100 < responseStatus && responseStatus < 200) { statusCodeName = "PROVISIONAL"; } else if (responseStatus < 300) { statusCodeName = "SUCCESS"; } else if (responseStatus < 400) { statusCodeName = "REDIRECT"; } else if (responseStatus < 500) { statusCodeName = "CLIENT_ERROR"; } else if (responseStatus < 600) { statusCodeName = "SERVER_ERROR"; } else { statusCodeName = "GLOBAL_FAILURE"; } // in dialog responses use the 1.1 event id prefix return getEventId(eventLookupFacility, new StringBuilder(RESPONSE_EVENT_PREFIX).append(statusCodeName).toString()); }
java
public FireableEventType getEventId(EventLookupFacility eventLookupFacility, Response response) { String statusCodeName = null; final int responseStatus = response.getStatusCode(); if (responseStatus == 100) { statusCodeName = "TRYING"; } else if (100 < responseStatus && responseStatus < 200) { statusCodeName = "PROVISIONAL"; } else if (responseStatus < 300) { statusCodeName = "SUCCESS"; } else if (responseStatus < 400) { statusCodeName = "REDIRECT"; } else if (responseStatus < 500) { statusCodeName = "CLIENT_ERROR"; } else if (responseStatus < 600) { statusCodeName = "SERVER_ERROR"; } else { statusCodeName = "GLOBAL_FAILURE"; } // in dialog responses use the 1.1 event id prefix return getEventId(eventLookupFacility, new StringBuilder(RESPONSE_EVENT_PREFIX).append(statusCodeName).toString()); }
[ "public", "FireableEventType", "getEventId", "(", "EventLookupFacility", "eventLookupFacility", ",", "Response", "response", ")", "{", "String", "statusCodeName", "=", "null", ";", "final", "int", "responseStatus", "=", "response", ".", "getStatusCode", "(", ")", ";...
Retrieves the event id for a SIP Response event. @param eventLookupFacility @param response @return
[ "Retrieves", "the", "event", "id", "for", "a", "SIP", "Response", "event", "." ]
2c173af0a760cb0ea13fe0ffa58c0f82b14731f9
https://github.com/RestComm/jain-slee.sip/blob/2c173af0a760cb0ea13fe0ffa58c0f82b14731f9/resources/sip11/ra/src/main/java/org/mobicents/slee/resource/sip11/EventIDCache.java#L108-L131
train
RestComm/jain-slee.sip
examples/sip-jdbc-registrar/sbb/src/main/java/org/mobicents/slee/example/sjr/data/jdbc/DataSourceChildSbb.java
DataSourceChildSbb.executeTask
private void executeTask(DataSourceJdbcTask jdbcTask) { JdbcActivity jdbcActivity = jdbcRA.createActivity(); ActivityContextInterface jdbcACI = jdbcACIF .getActivityContextInterface(jdbcActivity); jdbcACI.attach(sbbContextExt.getSbbLocalObject()); jdbcActivity.execute(jdbcTask); }
java
private void executeTask(DataSourceJdbcTask jdbcTask) { JdbcActivity jdbcActivity = jdbcRA.createActivity(); ActivityContextInterface jdbcACI = jdbcACIF .getActivityContextInterface(jdbcActivity); jdbcACI.attach(sbbContextExt.getSbbLocalObject()); jdbcActivity.execute(jdbcTask); }
[ "private", "void", "executeTask", "(", "DataSourceJdbcTask", "jdbcTask", ")", "{", "JdbcActivity", "jdbcActivity", "=", "jdbcRA", ".", "createActivity", "(", ")", ";", "ActivityContextInterface", "jdbcACI", "=", "jdbcACIF", ".", "getActivityContextInterface", "(", "jd...
Simple method to create JDBC activity and execute given task. @param queryJDBCTask
[ "Simple", "method", "to", "create", "JDBC", "activity", "and", "execute", "given", "task", "." ]
2c173af0a760cb0ea13fe0ffa58c0f82b14731f9
https://github.com/RestComm/jain-slee.sip/blob/2c173af0a760cb0ea13fe0ffa58c0f82b14731f9/examples/sip-jdbc-registrar/sbb/src/main/java/org/mobicents/slee/example/sjr/data/jdbc/DataSourceChildSbb.java#L122-L128
train
derari/cthul
matchers/src/main/java/org/cthul/proc/ProcBase.java
ProcBase.args
protected final void args(Object... args) { if (args == null) args = NO_ARGS; this.args = args; retry(); }
java
protected final void args(Object... args) { if (args == null) args = NO_ARGS; this.args = args; retry(); }
[ "protected", "final", "void", "args", "(", "Object", "...", "args", ")", "{", "if", "(", "args", "==", "null", ")", "args", "=", "NO_ARGS", ";", "this", ".", "args", "=", "args", ";", "retry", "(", ")", ";", "}" ]
Sets the arguments, for internal use only. @param args
[ "Sets", "the", "arguments", "for", "internal", "use", "only", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/matchers/src/main/java/org/cthul/proc/ProcBase.java#L60-L64
train
derari/cthul
matchers/src/main/java/org/cthul/proc/ProcBase.java
ProcBase.ensureIsRun
private synchronized void ensureIsRun() { if (!isRun) { isRun = true; try { result = executeProc(args); exception = null; } catch (ProcError e) { throw e.asRuntimeException(); } catch (Throwable t) { exception = t; result = null; } } }
java
private synchronized void ensureIsRun() { if (!isRun) { isRun = true; try { result = executeProc(args); exception = null; } catch (ProcError e) { throw e.asRuntimeException(); } catch (Throwable t) { exception = t; result = null; } } }
[ "private", "synchronized", "void", "ensureIsRun", "(", ")", "{", "if", "(", "!", "isRun", ")", "{", "isRun", "=", "true", ";", "try", "{", "result", "=", "executeProc", "(", "args", ")", ";", "exception", "=", "null", ";", "}", "catch", "(", "ProcErr...
Execute the proc if not done so already.
[ "Execute", "the", "proc", "if", "not", "done", "so", "already", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/matchers/src/main/java/org/cthul/proc/ProcBase.java#L127-L140
train
derari/cthul
matchers/src/main/java/org/cthul/proc/ProcBase.java
ProcBase.describeArgsTo
protected int describeArgsTo(Description description) { for (int i = 0; i < args.length; i++) { if (i > 0) description.appendText(", "); description.appendValue(args[i]); } return args.length; }
java
protected int describeArgsTo(Description description) { for (int i = 0; i < args.length; i++) { if (i > 0) description.appendText(", "); description.appendValue(args[i]); } return args.length; }
[ "protected", "int", "describeArgsTo", "(", "Description", "description", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "args", ".", "length", ";", "i", "++", ")", "{", "if", "(", "i", ">", "0", ")", "description", ".", "appendText", "(...
Describes the arguments that are used for execution this asProc. @param description
[ "Describes", "the", "arguments", "that", "are", "used", "for", "execution", "this", "asProc", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/matchers/src/main/java/org/cthul/proc/ProcBase.java#L263-L269
train
derari/cthul
strings/src/main/java/org/cthul/strings/AlphaIndex.java
AlphaIndex.fromAlpha1
public static long fromAlpha1(String s) { s = s.trim(); if (s.isEmpty()) return 0; return fromAlpha(s) + 1; }
java
public static long fromAlpha1(String s) { s = s.trim(); if (s.isEmpty()) return 0; return fromAlpha(s) + 1; }
[ "public", "static", "long", "fromAlpha1", "(", "String", "s", ")", "{", "s", "=", "s", ".", "trim", "(", ")", ";", "if", "(", "s", ".", "isEmpty", "(", ")", ")", "return", "0", ";", "return", "fromAlpha", "(", "s", ")", "+", "1", ";", "}" ]
Parses a one-based alpha-index. An empty string will be parsed as zero. @see #fromAlpha(java.lang.String)
[ "Parses", "a", "one", "-", "based", "alpha", "-", "index", ".", "An", "empty", "string", "will", "be", "parsed", "as", "zero", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/strings/src/main/java/org/cthul/strings/AlphaIndex.java#L123-L127
train
derari/cthul
matchers/src/main/java/org/cthul/proc/P4.java
P4.run
protected Object run(A a, B b, C c, D d) throws Throwable { throw notImplemented("run(A, B, C, D)"); }
java
protected Object run(A a, B b, C c, D d) throws Throwable { throw notImplemented("run(A, B, C, D)"); }
[ "protected", "Object", "run", "(", "A", "a", ",", "B", "b", ",", "C", "c", ",", "D", "d", ")", "throws", "Throwable", "{", "throw", "notImplemented", "(", "\"run(A, B, C, D)\"", ")", ";", "}" ]
Executes the proc. @param a @param b @param c @param d @return result @throws Throwable
[ "Executes", "the", "proc", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/matchers/src/main/java/org/cthul/proc/P4.java#L54-L56
train
derari/cthul
objects/src/main/java/org/cthul/objects/Boxing.java
Boxing.boxAllAs
public static <T> T boxAllAs(Object src, Class<T> type) { return (T) boxAll(type, src, 0, -1); }
java
public static <T> T boxAllAs(Object src, Class<T> type) { return (T) boxAll(type, src, 0, -1); }
[ "public", "static", "<", "T", ">", "T", "boxAllAs", "(", "Object", "src", ",", "Class", "<", "T", ">", "type", ")", "{", "return", "(", "T", ")", "boxAll", "(", "type", ",", "src", ",", "0", ",", "-", "1", ")", ";", "}" ]
Transforms any array into an array of boxed values. @param <T> @param type target type @param src source array @return array
[ "Transforms", "any", "array", "into", "an", "array", "of", "boxed", "values", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/Boxing.java#L491-L493
train
derari/cthul
log-cal10n/src/main/java/org/cthul/log/util/CLocMessageConveyor.java
CLocMessageConveyor.getMessage
@Override public <E extends Enum<?>> String getMessage(E key, Object... args) throws MessageConveyorException { String declararingClassName = key.getDeclaringClass().getName(); CAL10NResourceBundle rb = cache.get(declararingClassName); if (rb == null || rb.hasChanged()) { rb = lookup(key); cache.put(declararingClassName, rb); } String keyAsStr = key.toString(); String value = rb.getString(keyAsStr); if (value == null) { return "?" + keyAsStr + "?"; } else { if (args == null || args.length == 0) { return value; } else { return format(value, args); } } }
java
@Override public <E extends Enum<?>> String getMessage(E key, Object... args) throws MessageConveyorException { String declararingClassName = key.getDeclaringClass().getName(); CAL10NResourceBundle rb = cache.get(declararingClassName); if (rb == null || rb.hasChanged()) { rb = lookup(key); cache.put(declararingClassName, rb); } String keyAsStr = key.toString(); String value = rb.getString(keyAsStr); if (value == null) { return "?" + keyAsStr + "?"; } else { if (args == null || args.length == 0) { return value; } else { return format(value, args); } } }
[ "@", "Override", "public", "<", "E", "extends", "Enum", "<", "?", ">", ">", "String", "getMessage", "(", "E", "key", ",", "Object", "...", "args", ")", "throws", "MessageConveyorException", "{", "String", "declararingClassName", "=", "key", ".", "getDeclarin...
Given an enum as key, find the corresponding resource bundle and return the corresponding internationalized. <p> The name of the resource bundle is defined via the {@link BaseName} annotation whereas the locale is specified in this MessageConveyor instance's constructor. @param key an enum instance used as message key
[ "Given", "an", "enum", "as", "key", "find", "the", "corresponding", "resource", "bundle", "and", "return", "the", "corresponding", "internationalized", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/log-cal10n/src/main/java/org/cthul/log/util/CLocMessageConveyor.java#L85-L107
train
derari/cthul
parser/src/main/java/org/cthul/parser/util/IntMap.java
IntMap.findHighestKey
public int findHighestKey(int max) { int highest = Integer.MIN_VALUE; int index = index(hash(max)); final int maxTry = capacity; for (int i = 0; i < maxTry; i++) { if (!slotIsFree(index)) { int k = keys[index]; if (k == max) return max; if (max > k && k > highest) highest = k; } index = nextIndex(index); } return highest; }
java
public int findHighestKey(int max) { int highest = Integer.MIN_VALUE; int index = index(hash(max)); final int maxTry = capacity; for (int i = 0; i < maxTry; i++) { if (!slotIsFree(index)) { int k = keys[index]; if (k == max) return max; if (max > k && k > highest) highest = k; } index = nextIndex(index); } return highest; }
[ "public", "int", "findHighestKey", "(", "int", "max", ")", "{", "int", "highest", "=", "Integer", ".", "MIN_VALUE", ";", "int", "index", "=", "index", "(", "hash", "(", "max", ")", ")", ";", "final", "int", "maxTry", "=", "capacity", ";", "for", "(",...
Finds the highest key LE `max`, for which there is a value.
[ "Finds", "the", "highest", "key", "LE", "max", "for", "which", "there", "is", "a", "value", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/parser/src/main/java/org/cthul/parser/util/IntMap.java#L76-L89
train
derari/cthul
parser/src/main/java/org/cthul/parser/util/IntMap.java
IntMap.findLowestKey
public int findLowestKey(int min) { int lowest = Integer.MAX_VALUE; int index = index(hash(min)); final int maxTry = capacity; for (int i = 0; i < maxTry; i++) { if (!slotIsFree(index)) { int k = keys[index]; if (k == min) return min; if (min < k && k < lowest) lowest = k; } index = nextIndex(index); } return lowest; }
java
public int findLowestKey(int min) { int lowest = Integer.MAX_VALUE; int index = index(hash(min)); final int maxTry = capacity; for (int i = 0; i < maxTry; i++) { if (!slotIsFree(index)) { int k = keys[index]; if (k == min) return min; if (min < k && k < lowest) lowest = k; } index = nextIndex(index); } return lowest; }
[ "public", "int", "findLowestKey", "(", "int", "min", ")", "{", "int", "lowest", "=", "Integer", ".", "MAX_VALUE", ";", "int", "index", "=", "index", "(", "hash", "(", "min", ")", ")", ";", "final", "int", "maxTry", "=", "capacity", ";", "for", "(", ...
Finds the highest key GE `min`, for which there is a value.
[ "Finds", "the", "highest", "key", "GE", "min", "for", "which", "there", "is", "a", "value", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/parser/src/main/java/org/cthul/parser/util/IntMap.java#L95-L108
train
derari/cthul
parser/src/main/java/org/cthul/parser/util/IntMap.java
IntMap.find
private int find(int key, int hash) { int index = index(hash); final int maxTry = capacity; for (int i = 0; i < maxTry; i++) { Object slot = values[index]; if (slot == null) return -1; if (slot != GUARD) return keys[index] == key ? index : -1; index = nextIndex(index); } return -1; }
java
private int find(int key, int hash) { int index = index(hash); final int maxTry = capacity; for (int i = 0; i < maxTry; i++) { Object slot = values[index]; if (slot == null) return -1; if (slot != GUARD) return keys[index] == key ? index : -1; index = nextIndex(index); } return -1; }
[ "private", "int", "find", "(", "int", "key", ",", "int", "hash", ")", "{", "int", "index", "=", "index", "(", "hash", ")", ";", "final", "int", "maxTry", "=", "capacity", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "maxTry", ";", "i",...
Finds the slot of an existing value for `key`;
[ "Finds", "the", "slot", "of", "an", "existing", "value", "for", "key", ";" ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/parser/src/main/java/org/cthul/parser/util/IntMap.java#L134-L144
train
derari/cthul
parser/src/main/java/org/cthul/parser/util/IntMap.java
IntMap.findInsertIndex
private int findInsertIndex(int key, int hash) { int index = index(hash); final int maxTry = capacity; for (int i = 0; i < maxTry; i++) { if (slotIsFree(index)) return index; index = nextIndex(index); } throw new IllegalStateException("Free slots expected"); }
java
private int findInsertIndex(int key, int hash) { int index = index(hash); final int maxTry = capacity; for (int i = 0; i < maxTry; i++) { if (slotIsFree(index)) return index; index = nextIndex(index); } throw new IllegalStateException("Free slots expected"); }
[ "private", "int", "findInsertIndex", "(", "int", "key", ",", "int", "hash", ")", "{", "int", "index", "=", "index", "(", "hash", ")", ";", "final", "int", "maxTry", "=", "capacity", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "maxTry", ...
Find slot to inser key-value
[ "Find", "slot", "to", "inser", "key", "-", "value" ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/parser/src/main/java/org/cthul/parser/util/IntMap.java#L149-L157
train
derari/cthul
xml/src/main/java/org/cthul/resolve/UriMappingResolver.java
UriMappingResolver.addResource
public UriMappingResolver addResource(String uri, String resource) { uriMap.put(uri, resource); return this; }
java
public UriMappingResolver addResource(String uri, String resource) { uriMap.put(uri, resource); return this; }
[ "public", "UriMappingResolver", "addResource", "(", "String", "uri", ",", "String", "resource", ")", "{", "uriMap", ".", "put", "(", "uri", ",", "resource", ")", ";", "return", "this", ";", "}" ]
Adds a single resource that can be looked-up by its uri. @param uri @param resource @return this
[ "Adds", "a", "single", "resource", "that", "can", "be", "looked", "-", "up", "by", "its", "uri", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/xml/src/main/java/org/cthul/resolve/UriMappingResolver.java#L86-L89
train
derari/cthul
xml/src/main/java/org/cthul/resolve/UriMappingResolver.java
UriMappingResolver.getMappingString
protected String getMappingString() { StringBuilder sb = new StringBuilder(); final int schemaSize = uriMap.size(); final int domainSize = patternMap.size(); int s = 0, d = 0; for (String schema: uriMap.keySet()) { if (s > 0) sb.append(", "); sb.append(schema); s++; if (s > 2 && schemaSize > 3) { sb.append(", "); sb.append(schemaSize - s); sb.append(" more"); break; } } if (schemaSize > 0 && domainSize > 0) sb.append("; "); for (Pattern domain: patternMap.keySet()) { if (d > 0) sb.append(", "); sb.append(domain.pattern()); d++; if (d > 2 && domainSize > 3) { sb.append(", "); sb.append(domainSize - s); sb.append(" more"); break; } } return sb.toString(); }
java
protected String getMappingString() { StringBuilder sb = new StringBuilder(); final int schemaSize = uriMap.size(); final int domainSize = patternMap.size(); int s = 0, d = 0; for (String schema: uriMap.keySet()) { if (s > 0) sb.append(", "); sb.append(schema); s++; if (s > 2 && schemaSize > 3) { sb.append(", "); sb.append(schemaSize - s); sb.append(" more"); break; } } if (schemaSize > 0 && domainSize > 0) sb.append("; "); for (Pattern domain: patternMap.keySet()) { if (d > 0) sb.append(", "); sb.append(domain.pattern()); d++; if (d > 2 && domainSize > 3) { sb.append(", "); sb.append(domainSize - s); sb.append(" more"); break; } } return sb.toString(); }
[ "protected", "String", "getMappingString", "(", ")", "{", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "final", "int", "schemaSize", "=", "uriMap", ".", "size", "(", ")", ";", "final", "int", "domainSize", "=", "patternMap", ".", "siz...
string representation for debugging purposes
[ "string", "representation", "for", "debugging", "purposes" ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/xml/src/main/java/org/cthul/resolve/UriMappingResolver.java#L314-L343
train
derari/cthul
xml/src/main/java/org/cthul/resolve/RResult.java
RResult.expandSystemId
protected String expandSystemId(String baseId, String systemId) { return getRequest().expandSystemId(baseId, systemId); }
java
protected String expandSystemId(String baseId, String systemId) { return getRequest().expandSystemId(baseId, systemId); }
[ "protected", "String", "expandSystemId", "(", "String", "baseId", ",", "String", "systemId", ")", "{", "return", "getRequest", "(", ")", ".", "expandSystemId", "(", "baseId", ",", "systemId", ")", ";", "}" ]
Calculates the resource location. @param baseId @param systemId @return schema file path
[ "Calculates", "the", "resource", "location", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/xml/src/main/java/org/cthul/resolve/RResult.java#L169-L171
train
derari/cthul
strings/src/main/java/org/cthul/strings/RegEx.java
RegEx.quoteSingle
private static int quoteSingle(final StringBuilder sb, final String string, final int start) { int i = start+1; if (needsBlockQuoting(string.charAt(start))) return -i; int unquoteLen = 0; int quotedMap = 1; for (int j = 1; i < string.length(); i++, j++) { char c = string.charAt(i); if (needsQuoting(c)) { if (j > MAX_SINGLE_QUOTE_LEN || needsBlockQuoting(c)) return -i-1; quotedMap |= 1 << j; unquoteLen = 0; } else { if (unquoteLen == MAX_UNQUOTE_LEN || (quotedMap == 1 && unquoteLen == MAX_SINGLE_UNQUOTE_LEN)) { break; } unquoteLen++; } } appendSingleQuoted(sb, string, start, i - unquoteLen, quotedMap); sb.append(string, i - unquoteLen, i); return i; }
java
private static int quoteSingle(final StringBuilder sb, final String string, final int start) { int i = start+1; if (needsBlockQuoting(string.charAt(start))) return -i; int unquoteLen = 0; int quotedMap = 1; for (int j = 1; i < string.length(); i++, j++) { char c = string.charAt(i); if (needsQuoting(c)) { if (j > MAX_SINGLE_QUOTE_LEN || needsBlockQuoting(c)) return -i-1; quotedMap |= 1 << j; unquoteLen = 0; } else { if (unquoteLen == MAX_UNQUOTE_LEN || (quotedMap == 1 && unquoteLen == MAX_SINGLE_UNQUOTE_LEN)) { break; } unquoteLen++; } } appendSingleQuoted(sb, string, start, i - unquoteLen, quotedMap); sb.append(string, i - unquoteLen, i); return i; }
[ "private", "static", "int", "quoteSingle", "(", "final", "StringBuilder", "sb", ",", "final", "String", "string", ",", "final", "int", "start", ")", "{", "int", "i", "=", "start", "+", "1", ";", "if", "(", "needsBlockQuoting", "(", "string", ".", "charAt...
Tries to quote each character with a backslash.
[ "Tries", "to", "quote", "each", "character", "with", "a", "backslash", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/strings/src/main/java/org/cthul/strings/RegEx.java#L67-L90
train
derari/cthul
matchers/src/main/java/org/cthul/matchers/diagnose/nested/Nested.java
Nested.useParentheses
public static boolean useParentheses(int pSelf, int pNested) { if (pSelf == PrecedencedSelfDescribing.P_NONE || pSelf == PrecedencedSelfDescribing.P_UNARY_NO_PAREN) { return false; } if (pNested < PrecedencedSelfDescribing.P_UNARY) { return pNested <= pSelf; } else { return pNested < pSelf; } }
java
public static boolean useParentheses(int pSelf, int pNested) { if (pSelf == PrecedencedSelfDescribing.P_NONE || pSelf == PrecedencedSelfDescribing.P_UNARY_NO_PAREN) { return false; } if (pNested < PrecedencedSelfDescribing.P_UNARY) { return pNested <= pSelf; } else { return pNested < pSelf; } }
[ "public", "static", "boolean", "useParentheses", "(", "int", "pSelf", ",", "int", "pNested", ")", "{", "if", "(", "pSelf", "==", "PrecedencedSelfDescribing", ".", "P_NONE", "||", "pSelf", "==", "PrecedencedSelfDescribing", ".", "P_UNARY_NO_PAREN", ")", "{", "ret...
Compares own precedence against nested and return @param pSelf @param pNested @return true iff parentheses should be used
[ "Compares", "own", "precedence", "against", "nested", "and", "return" ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/matchers/src/main/java/org/cthul/matchers/diagnose/nested/Nested.java#L133-L143
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/JavaSignatureComparator.java
JavaSignatureComparator.compareParameter
private int compareParameter(Class<?> a, Class<?> b) { final int a_preferred = -1; if (a.equals(b)) { return 0; } else if (b.isAssignableFrom(a)) { // a is more specific return a_preferred; } else if (a.isAssignableFrom(b)) { // b is more specific return -a_preferred; } else { return 0; // not compatible } }
java
private int compareParameter(Class<?> a, Class<?> b) { final int a_preferred = -1; if (a.equals(b)) { return 0; } else if (b.isAssignableFrom(a)) { // a is more specific return a_preferred; } else if (a.isAssignableFrom(b)) { // b is more specific return -a_preferred; } else { return 0; // not compatible } }
[ "private", "int", "compareParameter", "(", "Class", "<", "?", ">", "a", ",", "Class", "<", "?", ">", "b", ")", "{", "final", "int", "a_preferred", "=", "-", "1", ";", "if", "(", "a", ".", "equals", "(", "b", ")", ")", "{", "return", "0", ";", ...
Compares two parameter types. @param a @param b @return
[ "Compares", "two", "parameter", "types", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/JavaSignatureComparator.java#L102-L115
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/JavaSignatureComparator.java
JavaSignatureComparator.applicability
public int applicability(final Class<?>[] paramTypes, boolean varArgs) { if (argTypes == null) { return MATCH_WILDCARD; } int level = MATCH; final int fixArgs = paramTypes.length - (varArgs ? 1 : 0); if (fixArgs > argTypes.length || (!varArgs && fixArgs != argTypes.length)) { return NO_MATCH; } // match fix args for (int i = 0; i < fixArgs; i++) { int m = applicable(argTypes[i], paramTypes[i]); if (m == NO_MATCH) return NO_MATCH; if (m < level) level = m; } if (varArgs) { // try if last arg matches varargs parameter directly Class<?> varArgType = paramTypes[fixArgs]; if (paramTypes.length == argTypes.length) { int m = applicable(argTypes[fixArgs], varArgType); if (m != NO_MATCH) { return Math.min(m, level); } } // match remaining args against vararg component type level = MATCH_VARARGS; Class<?> comp = varArgType.getComponentType(); for (int i = fixArgs; i < argTypes.length; i++) { int m = applicable(argTypes[i], comp); if (m == NO_MATCH) return NO_MATCH; } } return level; }
java
public int applicability(final Class<?>[] paramTypes, boolean varArgs) { if (argTypes == null) { return MATCH_WILDCARD; } int level = MATCH; final int fixArgs = paramTypes.length - (varArgs ? 1 : 0); if (fixArgs > argTypes.length || (!varArgs && fixArgs != argTypes.length)) { return NO_MATCH; } // match fix args for (int i = 0; i < fixArgs; i++) { int m = applicable(argTypes[i], paramTypes[i]); if (m == NO_MATCH) return NO_MATCH; if (m < level) level = m; } if (varArgs) { // try if last arg matches varargs parameter directly Class<?> varArgType = paramTypes[fixArgs]; if (paramTypes.length == argTypes.length) { int m = applicable(argTypes[fixArgs], varArgType); if (m != NO_MATCH) { return Math.min(m, level); } } // match remaining args against vararg component type level = MATCH_VARARGS; Class<?> comp = varArgType.getComponentType(); for (int i = fixArgs; i < argTypes.length; i++) { int m = applicable(argTypes[i], comp); if (m == NO_MATCH) return NO_MATCH; } } return level; }
[ "public", "int", "applicability", "(", "final", "Class", "<", "?", ">", "[", "]", "paramTypes", ",", "boolean", "varArgs", ")", "{", "if", "(", "argTypes", "==", "null", ")", "{", "return", "MATCH_WILDCARD", ";", "}", "int", "level", "=", "MATCH", ";",...
Returns the applicabilty of a signature. A signature with higher applicability is always preferred, even if the other is more specific. @param paramTypes @param varArgs @return applicability level
[ "Returns", "the", "applicabilty", "of", "a", "signature", ".", "A", "signature", "with", "higher", "applicability", "is", "always", "preferred", "even", "if", "the", "other", "is", "more", "specific", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/JavaSignatureComparator.java#L124-L158
train
derari/cthul
strings/src/main/java/org/cthul/strings/Romans.java
Romans.maxLetterValue
public static int maxLetterValue(final int numberOfLetters) { int v = 1; for (int i = 1; i < numberOfLetters; i++) { v *= i%2==0 ? 2 : 5; } return v; }
java
public static int maxLetterValue(final int numberOfLetters) { int v = 1; for (int i = 1; i < numberOfLetters; i++) { v *= i%2==0 ? 2 : 5; } return v; }
[ "public", "static", "int", "maxLetterValue", "(", "final", "int", "numberOfLetters", ")", "{", "int", "v", "=", "1", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<", "numberOfLetters", ";", "i", "++", ")", "{", "v", "*=", "i", "%", "2", "=="...
Given an array of letters, returns the value of the highest letter. @param numberOfLetters @return value of highest
[ "Given", "an", "array", "of", "letters", "returns", "the", "value", "of", "the", "highest", "letter", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/strings/src/main/java/org/cthul/strings/Romans.java#L82-L88
train
derari/cthul
strings/src/main/java/org/cthul/strings/Romans.java
Romans.toRoman
public static String toRoman(final int number, final int[][] digits, final String zero, final String[] letters) { int maxVal = maxLetterValue(letters); return toRoman(new StringBuilder(), number, digits, zero, letters, maxVal).toString(); }
java
public static String toRoman(final int number, final int[][] digits, final String zero, final String[] letters) { int maxVal = maxLetterValue(letters); return toRoman(new StringBuilder(), number, digits, zero, letters, maxVal).toString(); }
[ "public", "static", "String", "toRoman", "(", "final", "int", "number", ",", "final", "int", "[", "]", "[", "]", "digits", ",", "final", "String", "zero", ",", "final", "String", "[", "]", "letters", ")", "{", "int", "maxVal", "=", "maxLetterValue", "(...
Converts an integer into a roman number. @param number the value to convert @param digits digit codes, i.e. {@link Romans#DIGITS DIGITS} or {@link Romans#DIGITS_SIMPLE DIGITS_SIMPLE} @param zero representation of zero or {@code null} @param letters letters to use for roman number @throws IllegalArgumentException if {@code number} is negative or too large to be represented with the given letters or if {@code number} is 0 and {@code zero} is null.
[ "Converts", "an", "integer", "into", "a", "roman", "number", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/strings/src/main/java/org/cthul/strings/Romans.java#L130-L134
train
derari/cthul
strings/src/main/java/org/cthul/strings/FormatMatcher.java
FormatMatcher.match
public List<Object> match() { final IntMatchResults result = new IntMatchResults(); if (matches(result)) { return result.getIntResultList(); } else { return null; } }
java
public List<Object> match() { final IntMatchResults result = new IntMatchResults(); if (matches(result)) { return result.getIntResultList(); } else { return null; } }
[ "public", "List", "<", "Object", ">", "match", "(", ")", "{", "final", "IntMatchResults", "result", "=", "new", "IntMatchResults", "(", ")", ";", "if", "(", "matches", "(", "result", ")", ")", "{", "return", "result", ".", "getIntResultList", "(", ")", ...
Matches the entire input and returns a list of extracted values. @return list of values, or null if match failed
[ "Matches", "the", "entire", "input", "and", "returns", "a", "list", "of", "extracted", "values", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/strings/src/main/java/org/cthul/strings/FormatMatcher.java#L32-L39
train
derari/cthul
strings/src/main/java/org/cthul/strings/FormatMatcher.java
FormatMatcher.find
public boolean find(int start, MatchResults result) { if (!matcher.find(start)) return false; applyMatch(result); return true; }
java
public boolean find(int start, MatchResults result) { if (!matcher.find(start)) return false; applyMatch(result); return true; }
[ "public", "boolean", "find", "(", "int", "start", ",", "MatchResults", "result", ")", "{", "if", "(", "!", "matcher", ".", "find", "(", "start", ")", ")", "return", "false", ";", "applyMatch", "(", "result", ")", ";", "return", "true", ";", "}" ]
Finds the next match and fills the result @param start @param result @return true iff match was found
[ "Finds", "the", "next", "match", "and", "fills", "the", "result" ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/strings/src/main/java/org/cthul/strings/FormatMatcher.java#L69-L73
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.bestConstructor
public static <T> Constructor<T> bestConstructor(Class<T> clazz, Object[] args) throws AmbiguousConstructorMatchException { return bestConstructor(collectConstructors(clazz), args); }
java
public static <T> Constructor<T> bestConstructor(Class<T> clazz, Object[] args) throws AmbiguousConstructorMatchException { return bestConstructor(collectConstructors(clazz), args); }
[ "public", "static", "<", "T", ">", "Constructor", "<", "T", ">", "bestConstructor", "(", "Class", "<", "T", ">", "clazz", ",", "Object", "[", "]", "args", ")", "throws", "AmbiguousConstructorMatchException", "{", "return", "bestConstructor", "(", "collectConst...
Finds the best constructor for the given arguments. @param <T> @param clazz @param args @return constructor, or {@code null} @throws AmbiguousSignatureMatchException if multiple constructors match equally
[ "Finds", "the", "best", "constructor", "for", "the", "given", "arguments", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L31-L33
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.bestConstructor
public static <T> Constructor<T> bestConstructor(Class<T> clazz, Class<?>[] argTypes) throws AmbiguousConstructorMatchException { return bestConstructor(collectConstructors(clazz), argTypes); }
java
public static <T> Constructor<T> bestConstructor(Class<T> clazz, Class<?>[] argTypes) throws AmbiguousConstructorMatchException { return bestConstructor(collectConstructors(clazz), argTypes); }
[ "public", "static", "<", "T", ">", "Constructor", "<", "T", ">", "bestConstructor", "(", "Class", "<", "T", ">", "clazz", ",", "Class", "<", "?", ">", "[", "]", "argTypes", ")", "throws", "AmbiguousConstructorMatchException", "{", "return", "bestConstructor"...
Finds the best constructor for the given arguments types. @param <T> @param clazz @param argTypes @return constructor, or {@code null} @throws AmbiguousSignatureMatchException if multiple constructors match equally
[ "Finds", "the", "best", "constructor", "for", "the", "given", "arguments", "types", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L43-L45
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.bestConstructor
public static <T> Constructor<T> bestConstructor(Constructor<T>[] constructors, Object[] args) throws AmbiguousConstructorMatchException { return bestConstructor(constructors, collectArgTypes(args)); }
java
public static <T> Constructor<T> bestConstructor(Constructor<T>[] constructors, Object[] args) throws AmbiguousConstructorMatchException { return bestConstructor(constructors, collectArgTypes(args)); }
[ "public", "static", "<", "T", ">", "Constructor", "<", "T", ">", "bestConstructor", "(", "Constructor", "<", "T", ">", "[", "]", "constructors", ",", "Object", "[", "]", "args", ")", "throws", "AmbiguousConstructorMatchException", "{", "return", "bestConstruct...
Selects the best constructor for the given arguments. @param <T> @param constructors @param args @return constructor, or {@code null} @throws AmbiguousSignatureMatchException if multiple constructors match equally
[ "Selects", "the", "best", "constructor", "for", "the", "given", "arguments", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L55-L57
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.bestConstructor
public static <T> Constructor<T> bestConstructor(Constructor<T>[] constructors, Class<?>[] argTypes) throws AmbiguousConstructorMatchException { try { return best(constructors, collectSignatures(constructors), collectVarArgs(constructors), argTypes); } catch (AmbiguousSignatureMatchException e) { throw new AmbiguousConstructorMatchException(e, constructors); } }
java
public static <T> Constructor<T> bestConstructor(Constructor<T>[] constructors, Class<?>[] argTypes) throws AmbiguousConstructorMatchException { try { return best(constructors, collectSignatures(constructors), collectVarArgs(constructors), argTypes); } catch (AmbiguousSignatureMatchException e) { throw new AmbiguousConstructorMatchException(e, constructors); } }
[ "public", "static", "<", "T", ">", "Constructor", "<", "T", ">", "bestConstructor", "(", "Constructor", "<", "T", ">", "[", "]", "constructors", ",", "Class", "<", "?", ">", "[", "]", "argTypes", ")", "throws", "AmbiguousConstructorMatchException", "{", "t...
Selects the best constructor for the given argument types. @param <T> @param constructors @param argTypes @return constructor, or {@code null} @throws AmbiguousSignatureMatchException if multiple constructors match equally
[ "Selects", "the", "best", "constructor", "for", "the", "given", "argument", "types", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L67-L73
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.candidateConstructors
public static <T> Constructor<T>[] candidateConstructors(Class<T> clazz, Object[] args) { return candidateConstructors(collectConstructors(clazz), args); }
java
public static <T> Constructor<T>[] candidateConstructors(Class<T> clazz, Object[] args) { return candidateConstructors(collectConstructors(clazz), args); }
[ "public", "static", "<", "T", ">", "Constructor", "<", "T", ">", "[", "]", "candidateConstructors", "(", "Class", "<", "T", ">", "clazz", ",", "Object", "[", "]", "args", ")", "{", "return", "candidateConstructors", "(", "collectConstructors", "(", "clazz"...
Finds the best equally-matching constructors for the given arguments. @param <T> @param clazz @param args @return constructors
[ "Finds", "the", "best", "equally", "-", "matching", "constructors", "for", "the", "given", "arguments", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L82-L84
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.candidateConstructors
public static <T> Constructor<T>[] candidateConstructors(Class<T> clazz, Class<?>[] argTypes) { return candidateConstructors(collectConstructors(clazz), argTypes); }
java
public static <T> Constructor<T>[] candidateConstructors(Class<T> clazz, Class<?>[] argTypes) { return candidateConstructors(collectConstructors(clazz), argTypes); }
[ "public", "static", "<", "T", ">", "Constructor", "<", "T", ">", "[", "]", "candidateConstructors", "(", "Class", "<", "T", ">", "clazz", ",", "Class", "<", "?", ">", "[", "]", "argTypes", ")", "{", "return", "candidateConstructors", "(", "collectConstru...
Finds the best equally-matching constructors for the given argument types. @param <T> @param clazz @param argTypes @return constructors
[ "Finds", "the", "best", "equally", "-", "matching", "constructors", "for", "the", "given", "argument", "types", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L93-L95
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.candidateConstructors
public static <T> Constructor<T>[] candidateConstructors(Constructor<T>[] constructors, Object[] args) { return candidateConstructors(constructors, collectArgTypes(args)); }
java
public static <T> Constructor<T>[] candidateConstructors(Constructor<T>[] constructors, Object[] args) { return candidateConstructors(constructors, collectArgTypes(args)); }
[ "public", "static", "<", "T", ">", "Constructor", "<", "T", ">", "[", "]", "candidateConstructors", "(", "Constructor", "<", "T", ">", "[", "]", "constructors", ",", "Object", "[", "]", "args", ")", "{", "return", "candidateConstructors", "(", "constructor...
Selects the best equally-matching constructors for the given arguments. @param <T> @param constructors @param args @return constructors
[ "Selects", "the", "best", "equally", "-", "matching", "constructors", "for", "the", "given", "arguments", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L104-L106
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.candidateConstructors
public static <T> Constructor<T>[] candidateConstructors(Constructor<T>[] constructors, Class<?>[] argTypes) { return candidates(constructors, collectSignatures(constructors), collectVarArgs(constructors), argTypes); }
java
public static <T> Constructor<T>[] candidateConstructors(Constructor<T>[] constructors, Class<?>[] argTypes) { return candidates(constructors, collectSignatures(constructors), collectVarArgs(constructors), argTypes); }
[ "public", "static", "<", "T", ">", "Constructor", "<", "T", ">", "[", "]", "candidateConstructors", "(", "Constructor", "<", "T", ">", "[", "]", "constructors", ",", "Class", "<", "?", ">", "[", "]", "argTypes", ")", "{", "return", "candidates", "(", ...
Selects the best equally-matching constructors for the given argument types. @param <T> @param constructors @param argTypes @return constructors
[ "Selects", "the", "best", "equally", "-", "matching", "constructors", "for", "the", "given", "argument", "types", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L115-L117
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.bestMethod
public static Method bestMethod(Class<?> clazz, String name, Object[] args) throws AmbiguousMethodMatchException { return bestMethod(collectMethods(clazz, name), args); }
java
public static Method bestMethod(Class<?> clazz, String name, Object[] args) throws AmbiguousMethodMatchException { return bestMethod(collectMethods(clazz, name), args); }
[ "public", "static", "Method", "bestMethod", "(", "Class", "<", "?", ">", "clazz", ",", "String", "name", ",", "Object", "[", "]", "args", ")", "throws", "AmbiguousMethodMatchException", "{", "return", "bestMethod", "(", "collectMethods", "(", "clazz", ",", "...
Finds the best method for the given arguments. @param clazz @param name @param args @return method @throws AmbiguousSignatureMatchException if multiple methods match equally
[ "Finds", "the", "best", "method", "for", "the", "given", "arguments", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L127-L129
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.bestMethod
public static Method bestMethod(Class<?> clazz, String name, Class<?>[] argTypes) throws AmbiguousMethodMatchException { return bestMethod(collectMethods(clazz, name), argTypes); }
java
public static Method bestMethod(Class<?> clazz, String name, Class<?>[] argTypes) throws AmbiguousMethodMatchException { return bestMethod(collectMethods(clazz, name), argTypes); }
[ "public", "static", "Method", "bestMethod", "(", "Class", "<", "?", ">", "clazz", ",", "String", "name", ",", "Class", "<", "?", ">", "[", "]", "argTypes", ")", "throws", "AmbiguousMethodMatchException", "{", "return", "bestMethod", "(", "collectMethods", "(...
Finds the best method for the given argument types. @param clazz @param name @param argTypes @return method @throws AmbiguousSignatureMatchException if multiple methods match equally
[ "Finds", "the", "best", "method", "for", "the", "given", "argument", "types", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L139-L141
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.bestMethod
public static Method bestMethod(Method[] methods, Object[] args) throws AmbiguousMethodMatchException { return bestMethod(methods, collectArgTypes(args)); }
java
public static Method bestMethod(Method[] methods, Object[] args) throws AmbiguousMethodMatchException { return bestMethod(methods, collectArgTypes(args)); }
[ "public", "static", "Method", "bestMethod", "(", "Method", "[", "]", "methods", ",", "Object", "[", "]", "args", ")", "throws", "AmbiguousMethodMatchException", "{", "return", "bestMethod", "(", "methods", ",", "collectArgTypes", "(", "args", ")", ")", ";", ...
Selects the best method for the given arguments. @param methods @param args @return method @throws AmbiguousSignatureMatchException if multiple methods match equally
[ "Selects", "the", "best", "method", "for", "the", "given", "arguments", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L150-L152
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.bestMethod
public static Method bestMethod(Method[] methods, Class<?>[] argTypes) throws AmbiguousMethodMatchException { try { return best(methods, collectSignatures(methods), collectVarArgs(methods), argTypes); } catch (AmbiguousSignatureMatchException e) { throw new AmbiguousMethodMatchException(e, methods); } }
java
public static Method bestMethod(Method[] methods, Class<?>[] argTypes) throws AmbiguousMethodMatchException { try { return best(methods, collectSignatures(methods), collectVarArgs(methods), argTypes); } catch (AmbiguousSignatureMatchException e) { throw new AmbiguousMethodMatchException(e, methods); } }
[ "public", "static", "Method", "bestMethod", "(", "Method", "[", "]", "methods", ",", "Class", "<", "?", ">", "[", "]", "argTypes", ")", "throws", "AmbiguousMethodMatchException", "{", "try", "{", "return", "best", "(", "methods", ",", "collectSignatures", "(...
Selects the best method for the given argument types. @param methods @param argTypes @return method @throws AmbiguousSignatureMatchException if multiple methods match equally
[ "Selects", "the", "best", "method", "for", "the", "given", "argument", "types", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L161-L167
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.candidateMethods
public static Method[] candidateMethods(Class<?> clazz, String name, Object[] args) { return candidateMethods(collectMethods(clazz, name), args); }
java
public static Method[] candidateMethods(Class<?> clazz, String name, Object[] args) { return candidateMethods(collectMethods(clazz, name), args); }
[ "public", "static", "Method", "[", "]", "candidateMethods", "(", "Class", "<", "?", ">", "clazz", ",", "String", "name", ",", "Object", "[", "]", "args", ")", "{", "return", "candidateMethods", "(", "collectMethods", "(", "clazz", ",", "name", ")", ",", ...
Finds the best equally-matching methods for the given arguments. @param clazz @param name @param args @return methods
[ "Finds", "the", "best", "equally", "-", "matching", "methods", "for", "the", "given", "arguments", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L176-L178
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.candidateMethods
public static Method[] candidateMethods(Class<?> clazz, String name, Class<?>[] argTypes) { return candidateMethods(collectMethods(clazz, name), argTypes); }
java
public static Method[] candidateMethods(Class<?> clazz, String name, Class<?>[] argTypes) { return candidateMethods(collectMethods(clazz, name), argTypes); }
[ "public", "static", "Method", "[", "]", "candidateMethods", "(", "Class", "<", "?", ">", "clazz", ",", "String", "name", ",", "Class", "<", "?", ">", "[", "]", "argTypes", ")", "{", "return", "candidateMethods", "(", "collectMethods", "(", "clazz", ",", ...
Finds the best equally-matching methods for the given argument types. @param clazz @param name @param argTypes @return methods
[ "Finds", "the", "best", "equally", "-", "matching", "methods", "for", "the", "given", "argument", "types", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L187-L189
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.candidateMethods
public static Method[] candidateMethods(Method[] methods, Object[] args) { return candidateMethods(methods, collectArgTypes(args)); }
java
public static Method[] candidateMethods(Method[] methods, Object[] args) { return candidateMethods(methods, collectArgTypes(args)); }
[ "public", "static", "Method", "[", "]", "candidateMethods", "(", "Method", "[", "]", "methods", ",", "Object", "[", "]", "args", ")", "{", "return", "candidateMethods", "(", "methods", ",", "collectArgTypes", "(", "args", ")", ")", ";", "}" ]
Selects the best equally-matching methods for the given arguments. @param methods @param args @return methods
[ "Selects", "the", "best", "equally", "-", "matching", "methods", "for", "the", "given", "arguments", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L197-L199
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.candidateMethods
public static Method[] candidateMethods(Method[] methods, Class<?>[] argTypes) { return candidates(methods, collectSignatures(methods), collectVarArgs(methods), argTypes); }
java
public static Method[] candidateMethods(Method[] methods, Class<?>[] argTypes) { return candidates(methods, collectSignatures(methods), collectVarArgs(methods), argTypes); }
[ "public", "static", "Method", "[", "]", "candidateMethods", "(", "Method", "[", "]", "methods", ",", "Class", "<", "?", ">", "[", "]", "argTypes", ")", "{", "return", "candidates", "(", "methods", ",", "collectSignatures", "(", "methods", ")", ",", "coll...
Selects the best equally-matching methods for the given argument types. @param methods @param argTypes @return methods
[ "Selects", "the", "best", "equally", "-", "matching", "methods", "for", "the", "given", "argument", "types", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L207-L209
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.best
public static <T> T best(T[] items, Class<?>[][] signatures, boolean[] varArgs, Class<?>[] argTypes) throws AmbiguousSignatureMatchException { int i = bestMatch(signatures, varArgs, argTypes); if (i < 0) return null; return items[i]; }
java
public static <T> T best(T[] items, Class<?>[][] signatures, boolean[] varArgs, Class<?>[] argTypes) throws AmbiguousSignatureMatchException { int i = bestMatch(signatures, varArgs, argTypes); if (i < 0) return null; return items[i]; }
[ "public", "static", "<", "T", ">", "T", "best", "(", "T", "[", "]", "items", ",", "Class", "<", "?", ">", "[", "]", "[", "]", "signatures", ",", "boolean", "[", "]", "varArgs", ",", "Class", "<", "?", ">", "[", "]", "argTypes", ")", "throws", ...
Selects the best item for the given argument types. @param <T> @param items @param signatures @param varArgs @param argTypes @return item @throws AmbiguousSignatureMatchException if multiple methods match equally
[ "Selects", "the", "best", "item", "for", "the", "given", "argument", "types", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L221-L225
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.candidates
public static <T> T[] candidates(T[] items, Class<?>[][] signatures, boolean[] varArgs, Class<?>[] argTypes) { final int[] indices = candidateMatches(signatures, varArgs, argTypes); T[] result = newArray(items.getClass().getComponentType(), indices.length); for (int i = 0; i < indices.length; i++) { result[i] = items[indices[i]]; } return result; }
java
public static <T> T[] candidates(T[] items, Class<?>[][] signatures, boolean[] varArgs, Class<?>[] argTypes) { final int[] indices = candidateMatches(signatures, varArgs, argTypes); T[] result = newArray(items.getClass().getComponentType(), indices.length); for (int i = 0; i < indices.length; i++) { result[i] = items[indices[i]]; } return result; }
[ "public", "static", "<", "T", ">", "T", "[", "]", "candidates", "(", "T", "[", "]", "items", ",", "Class", "<", "?", ">", "[", "]", "[", "]", "signatures", ",", "boolean", "[", "]", "varArgs", ",", "Class", "<", "?", ">", "[", "]", "argTypes", ...
Selects the best equally-matching item for the given argument types. @param <T> @param items @param signatures @param varArgs @param argTypes @return item
[ "Selects", "the", "best", "equally", "-", "matching", "item", "for", "the", "given", "argument", "types", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L236-L243
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.bestMatch
public static int bestMatch(Class<?>[][] signatures, boolean[] varArgs, Class<?>[] argTypes) throws AmbiguousSignatureMatchException { return bestMatch(signatures, varArgs, new JavaSignatureComparator(argTypes)); }
java
public static int bestMatch(Class<?>[][] signatures, boolean[] varArgs, Class<?>[] argTypes) throws AmbiguousSignatureMatchException { return bestMatch(signatures, varArgs, new JavaSignatureComparator(argTypes)); }
[ "public", "static", "int", "bestMatch", "(", "Class", "<", "?", ">", "[", "]", "[", "]", "signatures", ",", "boolean", "[", "]", "varArgs", ",", "Class", "<", "?", ">", "[", "]", "argTypes", ")", "throws", "AmbiguousSignatureMatchException", "{", "return...
Selects the best match in signatures for the given argument types. @param signatures @param varArgs @param argTypes @return index of best signature, -1 if nothing matched @throws AmbiguousSignatureMatchException if two signatures matched equally
[ "Selects", "the", "best", "match", "in", "signatures", "for", "the", "given", "argument", "types", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L421-L423
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.candidateMatches
public static int[] candidateMatches(Class<?>[][] signatures, boolean[] varArgs, Class<?>[] argTypes) { return candidateMatches(signatures, varArgs, new JavaSignatureComparator(argTypes)); }
java
public static int[] candidateMatches(Class<?>[][] signatures, boolean[] varArgs, Class<?>[] argTypes) { return candidateMatches(signatures, varArgs, new JavaSignatureComparator(argTypes)); }
[ "public", "static", "int", "[", "]", "candidateMatches", "(", "Class", "<", "?", ">", "[", "]", "[", "]", "signatures", ",", "boolean", "[", "]", "varArgs", ",", "Class", "<", "?", ">", "[", "]", "argTypes", ")", "{", "return", "candidateMatches", "(...
Returns indices of all signatures that are a best match for the given argument types. @param signatures @param varArgs @param argTypes @return signature indices
[ "Returns", "indices", "of", "all", "signatures", "that", "are", "a", "best", "match", "for", "the", "given", "argument", "types", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L494-L496
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.fixVarArgs
public static Object[] fixVarArgs(Class<?>[] paramsWithVarArgs, Object[] arguments) { int n = paramsWithVarArgs.length; return fixVarArgs(n, paramsWithVarArgs[n-1], arguments); }
java
public static Object[] fixVarArgs(Class<?>[] paramsWithVarArgs, Object[] arguments) { int n = paramsWithVarArgs.length; return fixVarArgs(n, paramsWithVarArgs[n-1], arguments); }
[ "public", "static", "Object", "[", "]", "fixVarArgs", "(", "Class", "<", "?", ">", "[", "]", "paramsWithVarArgs", ",", "Object", "[", "]", "arguments", ")", "{", "int", "n", "=", "paramsWithVarArgs", ".", "length", ";", "return", "fixVarArgs", "(", "n", ...
Fixes an arguments array to fit parameter types, where the last parameter is an varargs array. @param paramsWithVarArgs @param arguments @return fixed arguments array
[ "Fixes", "an", "arguments", "array", "to", "fit", "parameter", "types", "where", "the", "last", "parameter", "is", "an", "varargs", "array", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L542-L545
train
derari/cthul
objects/src/main/java/org/cthul/objects/reflection/Signatures.java
Signatures.fixVarArgs
@SuppressWarnings("SuspiciousSystemArraycopy") public static Object[] fixVarArgs(int length, Class<?> varArgType, Object[] arguments) { final Object[] result; if (arguments.length == length && varArgType.isInstance(arguments[length-1])) { return arguments; } else { result = Arrays.copyOf(arguments, length, Object[].class); } final Object varArgs; Class<?> varArgElementType = varArgType.getComponentType(); if (varArgElementType.isPrimitive()) { varArgs = Boxing.unboxAll(varArgElementType, arguments, length-1, -1); } else { int varLen = arguments.length - length + 1; varArgs = Array.newInstance(varArgElementType, varLen); System.arraycopy(arguments, length-1, varArgs, 0, varLen); } result[length-1] = varArgs; return result; }
java
@SuppressWarnings("SuspiciousSystemArraycopy") public static Object[] fixVarArgs(int length, Class<?> varArgType, Object[] arguments) { final Object[] result; if (arguments.length == length && varArgType.isInstance(arguments[length-1])) { return arguments; } else { result = Arrays.copyOf(arguments, length, Object[].class); } final Object varArgs; Class<?> varArgElementType = varArgType.getComponentType(); if (varArgElementType.isPrimitive()) { varArgs = Boxing.unboxAll(varArgElementType, arguments, length-1, -1); } else { int varLen = arguments.length - length + 1; varArgs = Array.newInstance(varArgElementType, varLen); System.arraycopy(arguments, length-1, varArgs, 0, varLen); } result[length-1] = varArgs; return result; }
[ "@", "SuppressWarnings", "(", "\"SuspiciousSystemArraycopy\"", ")", "public", "static", "Object", "[", "]", "fixVarArgs", "(", "int", "length", ",", "Class", "<", "?", ">", "varArgType", ",", "Object", "[", "]", "arguments", ")", "{", "final", "Object", "[",...
Fixes an arguments array to fit a given length, the last value is an array filled with varargs. @param length @param varArgType @param arguments @return fixed arguments array
[ "Fixes", "an", "arguments", "array", "to", "fit", "a", "given", "length", "the", "last", "value", "is", "an", "array", "filled", "with", "varargs", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/objects/src/main/java/org/cthul/objects/reflection/Signatures.java#L555-L574
train
derari/cthul
strings/src/main/java/org/cthul/strings/plural/RulePluralizer.java
RulePluralizer.uncountable
protected void uncountable(String word) { Rule r = new UncountableRule(lower(word)); plural(r); singular(r); }
java
protected void uncountable(String word) { Rule r = new UncountableRule(lower(word)); plural(r); singular(r); }
[ "protected", "void", "uncountable", "(", "String", "word", ")", "{", "Rule", "r", "=", "new", "UncountableRule", "(", "lower", "(", "word", ")", ")", ";", "plural", "(", "r", ")", ";", "singular", "(", "r", ")", ";", "}" ]
Declares a word as uncountable, which means that singular and plural are identical. @param word
[ "Declares", "a", "word", "as", "uncountable", "which", "means", "that", "singular", "and", "plural", "are", "identical", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/strings/src/main/java/org/cthul/strings/plural/RulePluralizer.java#L102-L106
train
derari/cthul
strings/src/main/java/org/cthul/strings/plural/PluralizerRegistry.java
PluralizerRegistry.register
public synchronized Pluralizer register(Locale l, Pluralizer p) { return pluralizers.put(l, p); }
java
public synchronized Pluralizer register(Locale l, Pluralizer p) { return pluralizers.put(l, p); }
[ "public", "synchronized", "Pluralizer", "register", "(", "Locale", "l", ",", "Pluralizer", "p", ")", "{", "return", "pluralizers", ".", "put", "(", "l", ",", "p", ")", ";", "}" ]
Registers a pluralizer @param l @param p @return the pluralizer previously registered for that locale, or {@code null}
[ "Registers", "a", "pluralizer" ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/strings/src/main/java/org/cthul/strings/plural/PluralizerRegistry.java#L52-L54
train
derari/cthul
strings/src/main/java/org/cthul/strings/plural/PluralizerRegistry.java
PluralizerRegistry.find
public synchronized Pluralizer find(Locale l) { while (l != null) { List<Locale> candidates = control .getCandidateLocales(PLURALIZER_CLASS, l); for (Locale c: candidates) { Pluralizer p = pluralizers.get(c); if (p != null) return p; } l = control.getFallbackLocale(PLURALIZER_CLASS, l); } return null; }
java
public synchronized Pluralizer find(Locale l) { while (l != null) { List<Locale> candidates = control .getCandidateLocales(PLURALIZER_CLASS, l); for (Locale c: candidates) { Pluralizer p = pluralizers.get(c); if (p != null) return p; } l = control.getFallbackLocale(PLURALIZER_CLASS, l); } return null; }
[ "public", "synchronized", "Pluralizer", "find", "(", "Locale", "l", ")", "{", "while", "(", "l", "!=", "null", ")", "{", "List", "<", "Locale", ">", "candidates", "=", "control", ".", "getCandidateLocales", "(", "PLURALIZER_CLASS", ",", "l", ")", ";", "f...
Finds the best pluralizer for a locale. @param l @return a pluralizer @see #getRegistered(java.util.Locale)
[ "Finds", "the", "best", "pluralizer", "for", "a", "locale", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/strings/src/main/java/org/cthul/strings/plural/PluralizerRegistry.java#L62-L73
train
derari/cthul
strings/src/main/java/org/cthul/strings/plural/PluralizerRegistry.java
PluralizerRegistry.copy
public synchronized PluralizerRegistry copy() { PluralizerRegistry r = new PluralizerRegistry(control); r.pluralizers.putAll(pluralizers); return r; }
java
public synchronized PluralizerRegistry copy() { PluralizerRegistry r = new PluralizerRegistry(control); r.pluralizers.putAll(pluralizers); return r; }
[ "public", "synchronized", "PluralizerRegistry", "copy", "(", ")", "{", "PluralizerRegistry", "r", "=", "new", "PluralizerRegistry", "(", "control", ")", ";", "r", ".", "pluralizers", ".", "putAll", "(", "pluralizers", ")", ";", "return", "r", ";", "}" ]
Creates a shallow copy of this registry. @return a new registry
[ "Creates", "a", "shallow", "copy", "of", "this", "registry", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/strings/src/main/java/org/cthul/strings/plural/PluralizerRegistry.java#L89-L93
train
derari/cthul
matchers/src/main/java/org/cthul/matchers/diagnose/result/MatchResultProxy.java
MatchResultProxy.match
protected Match<?> match() { Match<?> m = result().getMatch(); if (m == null) { throw new IllegalStateException("Match failed"); } return m; }
java
protected Match<?> match() { Match<?> m = result().getMatch(); if (m == null) { throw new IllegalStateException("Match failed"); } return m; }
[ "protected", "Match", "<", "?", ">", "match", "(", ")", "{", "Match", "<", "?", ">", "m", "=", "result", "(", ")", ".", "getMatch", "(", ")", ";", "if", "(", "m", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Match failed...
For internal use. Fails if this is a mismatch. @return this
[ "For", "internal", "use", ".", "Fails", "if", "this", "is", "a", "mismatch", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/matchers/src/main/java/org/cthul/matchers/diagnose/result/MatchResultProxy.java#L39-L45
train
derari/cthul
matchers/src/main/java/org/cthul/matchers/diagnose/result/MatchResultProxy.java
MatchResultProxy.mismatch
protected Mismatch<?> mismatch() { Mismatch<?> m = result().getMismatch(); if (m == null) { throw new IllegalStateException("Match succeded"); } return m; }
java
protected Mismatch<?> mismatch() { Mismatch<?> m = result().getMismatch(); if (m == null) { throw new IllegalStateException("Match succeded"); } return m; }
[ "protected", "Mismatch", "<", "?", ">", "mismatch", "(", ")", "{", "Mismatch", "<", "?", ">", "m", "=", "result", "(", ")", ".", "getMismatch", "(", ")", ";", "if", "(", "m", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"...
For internal use. Fails if this is a match. @return this
[ "For", "internal", "use", ".", "Fails", "if", "this", "is", "a", "match", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/matchers/src/main/java/org/cthul/matchers/diagnose/result/MatchResultProxy.java#L51-L57
train
derari/cthul
xml/src/main/java/org/cthul/resolve/ResolvingException.java
ResolvingException.wrap
public static ResolvingException wrap(RRequest request, Exception e) { if (e instanceof ResolvingException) return (ResolvingException) e; return new ResolvingException(request, e); }
java
public static ResolvingException wrap(RRequest request, Exception e) { if (e instanceof ResolvingException) return (ResolvingException) e; return new ResolvingException(request, e); }
[ "public", "static", "ResolvingException", "wrap", "(", "RRequest", "request", ",", "Exception", "e", ")", "{", "if", "(", "e", "instanceof", "ResolvingException", ")", "return", "(", "ResolvingException", ")", "e", ";", "return", "new", "ResolvingException", "("...
Wraps e in an resolving exception, if it isn't one already. @param request @param e @return resolving exception
[ "Wraps", "e", "in", "an", "resolving", "exception", "if", "it", "isn", "t", "one", "already", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/xml/src/main/java/org/cthul/resolve/ResolvingException.java#L30-L33
train
derari/cthul
xml/src/main/java/org/cthul/resolve/ResolvingException.java
ResolvingException.getResolvingCause
public Throwable getResolvingCause() { Throwable t = this, c = this; while (c instanceof ResolvingException) { t = c; c = t.getCause(); } return c == null ? t : c; }
java
public Throwable getResolvingCause() { Throwable t = this, c = this; while (c instanceof ResolvingException) { t = c; c = t.getCause(); } return c == null ? t : c; }
[ "public", "Throwable", "getResolvingCause", "(", ")", "{", "Throwable", "t", "=", "this", ",", "c", "=", "this", ";", "while", "(", "c", "instanceof", "ResolvingException", ")", "{", "t", "=", "c", ";", "c", "=", "t", ".", "getCause", "(", ")", ";", ...
Returns the underlying cause of this resolving exceptions. Unpacks nested resolving exceptions if necessary. @return cause
[ "Returns", "the", "underlying", "cause", "of", "this", "resolving", "exceptions", ".", "Unpacks", "nested", "resolving", "exceptions", "if", "necessary", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/xml/src/main/java/org/cthul/resolve/ResolvingException.java#L345-L351
train
derari/cthul
xml/src/main/java/org/cthul/resolve/RRequest.java
RRequest.expandSystemId
protected String expandSystemId(String baseId, String systemId) { if (baseId == null || baseId.isEmpty()) return systemId; if (systemId == null || systemId.isEmpty()) return baseId; try { return new URI(baseId).resolve(new URI(systemId)).toASCIIString(); // // int lastSep = baseId.lastIndexOf('/'); // return baseId.substring(0, lastSep+1) + systemId; // return baseId.substring(0, lastSep+1) + systemId; } catch (URISyntaxException ex) { throw new ResolvingException(toString(), ex); } }
java
protected String expandSystemId(String baseId, String systemId) { if (baseId == null || baseId.isEmpty()) return systemId; if (systemId == null || systemId.isEmpty()) return baseId; try { return new URI(baseId).resolve(new URI(systemId)).toASCIIString(); // // int lastSep = baseId.lastIndexOf('/'); // return baseId.substring(0, lastSep+1) + systemId; // return baseId.substring(0, lastSep+1) + systemId; } catch (URISyntaxException ex) { throw new ResolvingException(toString(), ex); } }
[ "protected", "String", "expandSystemId", "(", "String", "baseId", ",", "String", "systemId", ")", "{", "if", "(", "baseId", "==", "null", "||", "baseId", ".", "isEmpty", "(", ")", ")", "return", "systemId", ";", "if", "(", "systemId", "==", "null", "||",...
Calculates the schema file location. @param baseId @param systemId @return schema file path
[ "Calculates", "the", "schema", "file", "location", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/xml/src/main/java/org/cthul/resolve/RRequest.java#L117-L129
train
derari/cthul
parser-lib/src/main/java/org/cthul/parser/token/lexer/TokenStreamBuilder.java
TokenStreamBuilder.push
public void push(T token) { if (token == lastPushed) return; lastPushed = token; if (token.getChannel() == TokenChannel.Default) { main.add(token); } all.add(token); }
java
public void push(T token) { if (token == lastPushed) return; lastPushed = token; if (token.getChannel() == TokenChannel.Default) { main.add(token); } all.add(token); }
[ "public", "void", "push", "(", "T", "token", ")", "{", "if", "(", "token", "==", "lastPushed", ")", "return", ";", "lastPushed", "=", "token", ";", "if", "(", "token", ".", "getChannel", "(", ")", "==", "TokenChannel", ".", "Default", ")", "{", "main...
make Liskov spin
[ "make", "Liskov", "spin" ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/parser-lib/src/main/java/org/cthul/parser/token/lexer/TokenStreamBuilder.java#L91-L98
train
derari/cthul
strings/src/main/java/org/cthul/strings/format/FormatImplBase.java
FormatImplBase.flags
protected static char[] flags(final CharSequence... flagStrings) { final StringBuilder sb = new StringBuilder(); for (CharSequence flags: flagStrings) sb.append(flags); return flags(sb.toString()); }
java
protected static char[] flags(final CharSequence... flagStrings) { final StringBuilder sb = new StringBuilder(); for (CharSequence flags: flagStrings) sb.append(flags); return flags(sb.toString()); }
[ "protected", "static", "char", "[", "]", "flags", "(", "final", "CharSequence", "...", "flagStrings", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "CharSequence", "flags", ":", "flagStrings", ")", "sb", ...
Converts strings of flags into a sorted flag array, that can be passed as a parameter to other utility methods. @param flagStrings @return sorted flag array
[ "Converts", "strings", "of", "flags", "into", "a", "sorted", "flag", "array", "that", "can", "be", "passed", "as", "a", "parameter", "to", "other", "utility", "methods", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/strings/src/main/java/org/cthul/strings/format/FormatImplBase.java#L25-L29
train
derari/cthul
strings/src/main/java/org/cthul/strings/format/FormatImplBase.java
FormatImplBase.flags
protected static char[] flags(final String flagString) { if (flagString == null || flagString.isEmpty()) { return NO_FLAGS; } noDupsExcept(flagString, NO_FLAGS); final char[] flags = flagString.toCharArray(); Arrays.sort(flags); return flags; }
java
protected static char[] flags(final String flagString) { if (flagString == null || flagString.isEmpty()) { return NO_FLAGS; } noDupsExcept(flagString, NO_FLAGS); final char[] flags = flagString.toCharArray(); Arrays.sort(flags); return flags; }
[ "protected", "static", "char", "[", "]", "flags", "(", "final", "String", "flagString", ")", "{", "if", "(", "flagString", "==", "null", "||", "flagString", ".", "isEmpty", "(", ")", ")", "{", "return", "NO_FLAGS", ";", "}", "noDupsExcept", "(", "flagStr...
Converts a string of flags into a sorted flag array, that can be passed as a parameter to other utility methods. @param flagString @return sorted flag array
[ "Converts", "a", "string", "of", "flags", "into", "a", "sorted", "flag", "array", "that", "can", "be", "passed", "as", "a", "parameter", "to", "other", "utility", "methods", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/strings/src/main/java/org/cthul/strings/format/FormatImplBase.java#L37-L45
train
derari/cthul
strings/src/main/java/org/cthul/strings/format/FormatImplBase.java
FormatImplBase.ensureNoFlags
protected void ensureNoFlags(final String flags) { if (flags == null || flags.isEmpty()) return; throw FormatException.formatFlagsMismatch(flags, getFormatName()); }
java
protected void ensureNoFlags(final String flags) { if (flags == null || flags.isEmpty()) return; throw FormatException.formatFlagsMismatch(flags, getFormatName()); }
[ "protected", "void", "ensureNoFlags", "(", "final", "String", "flags", ")", "{", "if", "(", "flags", "==", "null", "||", "flags", ".", "isEmpty", "(", ")", ")", "return", ";", "throw", "FormatException", ".", "formatFlagsMismatch", "(", "flags", ",", "getF...
Ensures no flags are given. @param flags @throws FormatException if flags is not null or empty.
[ "Ensures", "no", "flags", "are", "given", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/strings/src/main/java/org/cthul/strings/format/FormatImplBase.java#L183-L186
train
derari/cthul
strings/src/main/java/org/cthul/strings/format/FormatImplBase.java
FormatImplBase.selectFlag
protected char selectFlag(final String flags, final char[] choice) { if (flags == null) return 0; StringBuilder conflict = null; char found = 0; for (int i = 0; i < flags.length(); i++) { char f = flags.charAt(i); if (oneOf(f, choice)) { if (found != 0) { if (conflict == null) conflict = new StringBuilder().append(found); conflict.append(f); } else { found = f; } } } if (conflict != null) { throw FormatException.illegalFlags( conflict.toString(), getFormatName()); } return found; }
java
protected char selectFlag(final String flags, final char[] choice) { if (flags == null) return 0; StringBuilder conflict = null; char found = 0; for (int i = 0; i < flags.length(); i++) { char f = flags.charAt(i); if (oneOf(f, choice)) { if (found != 0) { if (conflict == null) conflict = new StringBuilder().append(found); conflict.append(f); } else { found = f; } } } if (conflict != null) { throw FormatException.illegalFlags( conflict.toString(), getFormatName()); } return found; }
[ "protected", "char", "selectFlag", "(", "final", "String", "flags", ",", "final", "char", "[", "]", "choice", ")", "{", "if", "(", "flags", "==", "null", ")", "return", "0", ";", "StringBuilder", "conflict", "=", "null", ";", "char", "found", "=", "0",...
Selects exactly one of the expected flags. @param choice a {@link #flags(java.lang.String) flags} array @param flags @return one of {@code choice}, or {@code '\0'} @throws FormatFlagsConversionMismatchException if more than one expected flag was found.
[ "Selects", "exactly", "one", "of", "the", "expected", "flags", "." ]
74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc
https://github.com/derari/cthul/blob/74a31e3cb6a94f5f25cc5253d1dbd42e19a17ebc/strings/src/main/java/org/cthul/strings/format/FormatImplBase.java#L206-L226
train
aboutsip/sipstack
sipstack-example/src/main/java/io/sipstack/example/netty/sip/proxyregistrar/ProxyRegistrarHandler.java
ProxyRegistrarHandler.proxy
private void proxy(final SipResponse msg) { final ViaHeader via = msg.getViaHeader(); final Connection connection = this.stack.connect(via.getHost(), via.getPort()); connection.send(msg); }
java
private void proxy(final SipResponse msg) { final ViaHeader via = msg.getViaHeader(); final Connection connection = this.stack.connect(via.getHost(), via.getPort()); connection.send(msg); }
[ "private", "void", "proxy", "(", "final", "SipResponse", "msg", ")", "{", "final", "ViaHeader", "via", "=", "msg", ".", "getViaHeader", "(", ")", ";", "final", "Connection", "connection", "=", "this", ".", "stack", ".", "connect", "(", "via", ".", "getHo...
Proxy the response to @param via @param msg
[ "Proxy", "the", "response", "to" ]
33f2db1d580738f0385687b0429fab0630118f42
https://github.com/aboutsip/sipstack/blob/33f2db1d580738f0385687b0429fab0630118f42/sipstack-example/src/main/java/io/sipstack/example/netty/sip/proxyregistrar/ProxyRegistrarHandler.java#L127-L131
train
aboutsip/sipstack
sipstack-example/src/main/java/io/sipstack/example/netty/sip/proxyregistrar/ProxyRegistrarHandler.java
ProxyRegistrarHandler.processRegisterRequest
private SipResponse processRegisterRequest(final SipRequest request) { final SipURI requestURI = (SipURI) request.getRequestUri(); final Buffer domain = requestURI.getHost(); final SipURI aor = getAOR(request); // the aor is not allowed to register under this domain // generate a 404 according to specfication if (!validateDomain(domain, aor)) { return request.createResponse(404); } final Binding.Builder builder = Binding.with(); builder.aor(aor); builder.callId(request.getCallIDHeader()); builder.expires(getExpires(request)); builder.cseq(request.getCSeqHeader()); // NOTE: this is also cheating. There may be multiple contacts // and they must all get processed but whatever... builder.contact(getContactURI(request)); final Binding binding = builder.build(); final List<Binding> currentBindings = this.locationService.updateBindings(binding); final SipResponse response = request.createResponse(200); currentBindings.forEach(b -> { final SipURI contactURI = b.getContact(); contactURI.setParameter("expires", b.getExpires()); final ContactHeader contact = ContactHeader.with(contactURI).build(); response.addHeader(contact); }); return response; }
java
private SipResponse processRegisterRequest(final SipRequest request) { final SipURI requestURI = (SipURI) request.getRequestUri(); final Buffer domain = requestURI.getHost(); final SipURI aor = getAOR(request); // the aor is not allowed to register under this domain // generate a 404 according to specfication if (!validateDomain(domain, aor)) { return request.createResponse(404); } final Binding.Builder builder = Binding.with(); builder.aor(aor); builder.callId(request.getCallIDHeader()); builder.expires(getExpires(request)); builder.cseq(request.getCSeqHeader()); // NOTE: this is also cheating. There may be multiple contacts // and they must all get processed but whatever... builder.contact(getContactURI(request)); final Binding binding = builder.build(); final List<Binding> currentBindings = this.locationService.updateBindings(binding); final SipResponse response = request.createResponse(200); currentBindings.forEach(b -> { final SipURI contactURI = b.getContact(); contactURI.setParameter("expires", b.getExpires()); final ContactHeader contact = ContactHeader.with(contactURI).build(); response.addHeader(contact); }); return response; }
[ "private", "SipResponse", "processRegisterRequest", "(", "final", "SipRequest", "request", ")", "{", "final", "SipURI", "requestURI", "=", "(", "SipURI", ")", "request", ".", "getRequestUri", "(", ")", ";", "final", "Buffer", "domain", "=", "requestURI", ".", ...
Section 10.3 in RFC3261 outlines how to process a register request. For the purpose of this little exercise, we are skipping many steps just to keep things simple. @param request
[ "Section", "10", ".", "3", "in", "RFC3261", "outlines", "how", "to", "process", "a", "register", "request", ".", "For", "the", "purpose", "of", "this", "little", "exercise", "we", "are", "skipping", "many", "steps", "just", "to", "keep", "things", "simple"...
33f2db1d580738f0385687b0429fab0630118f42
https://github.com/aboutsip/sipstack/blob/33f2db1d580738f0385687b0429fab0630118f42/sipstack-example/src/main/java/io/sipstack/example/netty/sip/proxyregistrar/ProxyRegistrarHandler.java#L188-L220
train
aboutsip/sipstack
sipstack-example/src/main/java/io/sipstack/example/netty/sip/uac/UACHandler.java
UACHandler.generateAck
private SipRequest generateAck(final SipResponse response) { final ContactHeader contact = response.getContactHeader(); final SipURI requestURI = (SipURI) contact.getAddress().getURI(); final ToHeader to = response.getToHeader(); final FromHeader from = response.getFromHeader(); // The contact of the response is where the remote party wishes // to receive future request. Since an ACK is a "future", or sub-sequent, request, // the request-uri of the ACK has to be whatever is in the // contact header of the response. // Since this is an ACK, the cseq should have the same cseq number as the response, // i.e., the same as the original INVITE that we are ACK:ing. final CSeqHeader cseq = CSeqHeader.with().cseq(response.getCSeqHeader().getSeqNumber()).method("ACK").build(); final CallIdHeader callId = response.getCallIDHeader(); // If there are Record-Route headers in the response, they must be // copied over as well otherwise the ACK will not go the correct // path through the network. // TODO // we also have to create a new Via header and as always, when creating // via header we need to fill out which ip, port and transport we are // coming in over. In SIP, unlike many other protocols, we can use // any transport protocol and it can actually change from message // to message but in this simple example we will just use the // same last time so we will only have to generate a new branch id final ViaHeader via = response.getViaHeader().clone(); via.setBranch(ViaHeader.generateBranch()); // now we have all the pieces so let's put it together final SipRequest.Builder builder = SipRequest.ack(requestURI); builder.from(from); builder.to(to); builder.callId(callId); builder.cseq(cseq); builder.via(via); return builder.build(); }
java
private SipRequest generateAck(final SipResponse response) { final ContactHeader contact = response.getContactHeader(); final SipURI requestURI = (SipURI) contact.getAddress().getURI(); final ToHeader to = response.getToHeader(); final FromHeader from = response.getFromHeader(); // The contact of the response is where the remote party wishes // to receive future request. Since an ACK is a "future", or sub-sequent, request, // the request-uri of the ACK has to be whatever is in the // contact header of the response. // Since this is an ACK, the cseq should have the same cseq number as the response, // i.e., the same as the original INVITE that we are ACK:ing. final CSeqHeader cseq = CSeqHeader.with().cseq(response.getCSeqHeader().getSeqNumber()).method("ACK").build(); final CallIdHeader callId = response.getCallIDHeader(); // If there are Record-Route headers in the response, they must be // copied over as well otherwise the ACK will not go the correct // path through the network. // TODO // we also have to create a new Via header and as always, when creating // via header we need to fill out which ip, port and transport we are // coming in over. In SIP, unlike many other protocols, we can use // any transport protocol and it can actually change from message // to message but in this simple example we will just use the // same last time so we will only have to generate a new branch id final ViaHeader via = response.getViaHeader().clone(); via.setBranch(ViaHeader.generateBranch()); // now we have all the pieces so let's put it together final SipRequest.Builder builder = SipRequest.ack(requestURI); builder.from(from); builder.to(to); builder.callId(callId); builder.cseq(cseq); builder.via(via); return builder.build(); }
[ "private", "SipRequest", "generateAck", "(", "final", "SipResponse", "response", ")", "{", "final", "ContactHeader", "contact", "=", "response", ".", "getContactHeader", "(", ")", ";", "final", "SipURI", "requestURI", "=", "(", "SipURI", ")", "contact", ".", "...
Generating an ACK to a 2xx response is the same as any other subsequent request. However, a subsequent request is generated in the context of what is known as a Dialog and since we currently are completely stateless, this is not necessarily an easy thing to achieve but for now we will ignore many of the details. The general idea is this though: <ul> <li>The sub-sequent request is going to be sent to where ever the Contact header of the response is pointing to. This is known as the remote-target.</li> <li>CSeq is incremented by one EXCEPT for ACK's, which will have the same sequence number as what it is "ack:ing". The method of the CSeq is "ACK" though.</li> <li>Call-ID has to be the same</li> <li>The remote and local tags has to be correctly preserved on the To- and From-headers</li> <li></li> <li></li> </ul> @param response @return
[ "Generating", "an", "ACK", "to", "a", "2xx", "response", "is", "the", "same", "as", "any", "other", "subsequent", "request", ".", "However", "a", "subsequent", "request", "is", "generated", "in", "the", "context", "of", "what", "is", "known", "as", "a", ...
33f2db1d580738f0385687b0429fab0630118f42
https://github.com/aboutsip/sipstack/blob/33f2db1d580738f0385687b0429fab0630118f42/sipstack-example/src/main/java/io/sipstack/example/netty/sip/uac/UACHandler.java#L49-L87
train
jaeksoft/jcifs-krb5
src/jcifs/spnego/asn1/ASN1OctetString.java
ASN1OctetString.getInstance
public static ASN1OctetString getInstance( Object obj) { if (obj == null || obj instanceof ASN1OctetString) { return (ASN1OctetString)obj; } if (obj instanceof ASN1TaggedObject) { return getInstance(((ASN1TaggedObject)obj).getObject()); } if (obj instanceof ASN1Sequence) { Vector v = new Vector(); Enumeration e = ((ASN1Sequence)obj).getObjects(); while (e.hasMoreElements()) { v.addElement(e.nextElement()); } return new BERConstructedOctetString(v); } throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName()); }
java
public static ASN1OctetString getInstance( Object obj) { if (obj == null || obj instanceof ASN1OctetString) { return (ASN1OctetString)obj; } if (obj instanceof ASN1TaggedObject) { return getInstance(((ASN1TaggedObject)obj).getObject()); } if (obj instanceof ASN1Sequence) { Vector v = new Vector(); Enumeration e = ((ASN1Sequence)obj).getObjects(); while (e.hasMoreElements()) { v.addElement(e.nextElement()); } return new BERConstructedOctetString(v); } throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName()); }
[ "public", "static", "ASN1OctetString", "getInstance", "(", "Object", "obj", ")", "{", "if", "(", "obj", "==", "null", "||", "obj", "instanceof", "ASN1OctetString", ")", "{", "return", "(", "ASN1OctetString", ")", "obj", ";", "}", "if", "(", "obj", "instanc...
return an Octet String from the given object. @param obj the object we want converted. @exception IllegalArgumentException if the object cannot be converted.
[ "return", "an", "Octet", "String", "from", "the", "given", "object", "." ]
c16ea9a39925dc198adf3e049598aaea292dc5e4
https://github.com/jaeksoft/jcifs-krb5/blob/c16ea9a39925dc198adf3e049598aaea292dc5e4/src/jcifs/spnego/asn1/ASN1OctetString.java#L57-L84
train
pushbit/sprockets
src/main/java/net/sf/sprockets/util/logging/Loggers.java
Loggers.get
public static Logger get(Class<?> cls, String resourceBundleName) { return Logger.getLogger(cls.getPackage().getName(), resourceBundleName); }
java
public static Logger get(Class<?> cls, String resourceBundleName) { return Logger.getLogger(cls.getPackage().getName(), resourceBundleName); }
[ "public", "static", "Logger", "get", "(", "Class", "<", "?", ">", "cls", ",", "String", "resourceBundleName", ")", "{", "return", "Logger", ".", "getLogger", "(", "cls", ".", "getPackage", "(", ")", ".", "getName", "(", ")", ",", "resourceBundleName", ")...
Get a logger for the class's package that uses the resource bundle for localisation.
[ "Get", "a", "logger", "for", "the", "class", "s", "package", "that", "uses", "the", "resource", "bundle", "for", "localisation", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/util/logging/Loggers.java#L41-L43
train
pushbit/sprockets
src/main/java/net/sf/sprockets/naming/Contexts.java
Contexts.lookup
@SuppressWarnings("unchecked") public static <T> T lookup(String name) { try { return (T) new InitialContext().lookup(name); } catch (NamingException e) { throw new IllegalStateException(e); } }
java
@SuppressWarnings("unchecked") public static <T> T lookup(String name) { try { return (T) new InitialContext().lookup(name); } catch (NamingException e) { throw new IllegalStateException(e); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "<", "T", ">", "T", "lookup", "(", "String", "name", ")", "{", "try", "{", "return", "(", "T", ")", "new", "InitialContext", "(", ")", ".", "lookup", "(", "name", ")", ";", "}", ...
Get the named object in the starting context. @throws IllegalStateException wrapping any NamingException
[ "Get", "the", "named", "object", "in", "the", "starting", "context", "." ]
5d967317cbb2374c69d33271d3c7b7311e1ea4ac
https://github.com/pushbit/sprockets/blob/5d967317cbb2374c69d33271d3c7b7311e1ea4ac/src/main/java/net/sf/sprockets/naming/Contexts.java#L38-L45
train