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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java | ModbusSerialTransport.open | private void open() throws ModbusIOException {
if (commPort != null && !commPort.isOpen()) {
setTimeout(timeout);
try {
commPort.open();
}
catch (IOException e) {
throw new ModbusIOException(String.format("Cannot open port %s - %s",... | java | private void open() throws ModbusIOException {
if (commPort != null && !commPort.isOpen()) {
setTimeout(timeout);
try {
commPort.open();
}
catch (IOException e) {
throw new ModbusIOException(String.format("Cannot open port %s - %s",... | [
"private",
"void",
"open",
"(",
")",
"throws",
"ModbusIOException",
"{",
"if",
"(",
"commPort",
"!=",
"null",
"&&",
"!",
"commPort",
".",
"isOpen",
"(",
")",
")",
"{",
"setTimeout",
"(",
"timeout",
")",
";",
"try",
"{",
"commPort",
".",
"open",
"(",
... | Opens the port if it isn't already open
@throws ModbusIOException If a problem with the port | [
"Opens",
"the",
"port",
"if",
"it",
"isn",
"t",
"already",
"open"
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java#L161-L171 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java | ModbusSerialTransport.readEcho | protected void readEcho(int len) throws IOException {
byte echoBuf[] = new byte[len];
int echoLen = commPort.readBytes(echoBuf, len);
if (logger.isDebugEnabled()) {
logger.debug("Echo: {}", ModbusUtil.toHex(echoBuf, 0, echoLen));
}
if (echoLen != len) {
lo... | java | protected void readEcho(int len) throws IOException {
byte echoBuf[] = new byte[len];
int echoLen = commPort.readBytes(echoBuf, len);
if (logger.isDebugEnabled()) {
logger.debug("Echo: {}", ModbusUtil.toHex(echoBuf, 0, echoLen));
}
if (echoLen != len) {
lo... | [
"protected",
"void",
"readEcho",
"(",
"int",
"len",
")",
"throws",
"IOException",
"{",
"byte",
"echoBuf",
"[",
"]",
"=",
"new",
"byte",
"[",
"len",
"]",
";",
"int",
"echoLen",
"=",
"commPort",
".",
"readBytes",
"(",
"echoBuf",
",",
"len",
")",
";",
"... | Reads the own message echo produced in RS485 Echo Mode
within the given time frame.
@param len is the length of the echo to read. Timeout will occur if the
echo is not received in the time specified in the SerialConnection.
@throws IOException if a I/O error occurred. | [
"Reads",
"the",
"own",
"message",
"echo",
"produced",
"in",
"RS485",
"Echo",
"Mode",
"within",
"the",
"given",
"time",
"frame",
"."
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java#L372-L382 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java | ModbusSerialTransport.readByte | protected int readByte() throws IOException {
if (commPort != null && commPort.isOpen()) {
byte[] buffer = new byte[1];
int cnt = commPort.readBytes(buffer, 1);
if (cnt != 1) {
throw new IOException("Cannot read from serial port");
}
el... | java | protected int readByte() throws IOException {
if (commPort != null && commPort.isOpen()) {
byte[] buffer = new byte[1];
int cnt = commPort.readBytes(buffer, 1);
if (cnt != 1) {
throw new IOException("Cannot read from serial port");
}
el... | [
"protected",
"int",
"readByte",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"commPort",
"!=",
"null",
"&&",
"commPort",
".",
"isOpen",
"(",
")",
")",
"{",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"1",
"]",
";",
"int",
"cnt",
"=",... | Reads a byte from the comms port
@return Value of the byte
@throws IOException If it cannot read or times out | [
"Reads",
"a",
"byte",
"from",
"the",
"comms",
"port"
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java#L395-L409 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java | ModbusSerialTransport.readBytes | void readBytes(byte[] buffer, long bytesToRead) throws IOException {
if (commPort != null && commPort.isOpen()) {
int cnt = commPort.readBytes(buffer, bytesToRead);
if (cnt != bytesToRead) {
throw new IOException("Cannot read from serial port - truncated");
}
... | java | void readBytes(byte[] buffer, long bytesToRead) throws IOException {
if (commPort != null && commPort.isOpen()) {
int cnt = commPort.readBytes(buffer, bytesToRead);
if (cnt != bytesToRead) {
throw new IOException("Cannot read from serial port - truncated");
}
... | [
"void",
"readBytes",
"(",
"byte",
"[",
"]",
"buffer",
",",
"long",
"bytesToRead",
")",
"throws",
"IOException",
"{",
"if",
"(",
"commPort",
"!=",
"null",
"&&",
"commPort",
".",
"isOpen",
"(",
")",
")",
"{",
"int",
"cnt",
"=",
"commPort",
".",
"readByte... | Reads the specified number of bytes from the input stream
@param buffer Buffer to put data into
@param bytesToRead Number of bytes to read
@throws IOException If the port is invalid or if the number of bytes returned is not equal to that asked for | [
"Reads",
"the",
"specified",
"number",
"of",
"bytes",
"from",
"the",
"input",
"stream"
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java#L418-L428 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java | ModbusSerialTransport.writeBytes | final int writeBytes(byte[] buffer, long bytesToWrite) throws IOException {
if (commPort != null && commPort.isOpen()) {
return commPort.writeBytes(buffer, bytesToWrite);
}
else {
throw new IOException("Comm port is not valid or not open");
}
} | java | final int writeBytes(byte[] buffer, long bytesToWrite) throws IOException {
if (commPort != null && commPort.isOpen()) {
return commPort.writeBytes(buffer, bytesToWrite);
}
else {
throw new IOException("Comm port is not valid or not open");
}
} | [
"final",
"int",
"writeBytes",
"(",
"byte",
"[",
"]",
"buffer",
",",
"long",
"bytesToWrite",
")",
"throws",
"IOException",
"{",
"if",
"(",
"commPort",
"!=",
"null",
"&&",
"commPort",
".",
"isOpen",
"(",
")",
")",
"{",
"return",
"commPort",
".",
"writeByte... | Writes the bytes to the output stream
@param buffer Buffer to write
@param bytesToWrite Number of bytes to write
@return Number of bytes written
@throws java.io.IOException if writing to invalid port | [
"Writes",
"the",
"bytes",
"to",
"the",
"output",
"stream"
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java#L439-L446 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java | ModbusSerialTransport.readAsciiByte | int readAsciiByte() throws IOException {
if (commPort != null && commPort.isOpen()) {
byte[] buffer = new byte[1];
int cnt = commPort.readBytes(buffer, 1);
if (cnt != 1) {
throw new IOException("Cannot read from serial port");
}
else if... | java | int readAsciiByte() throws IOException {
if (commPort != null && commPort.isOpen()) {
byte[] buffer = new byte[1];
int cnt = commPort.readBytes(buffer, 1);
if (cnt != 1) {
throw new IOException("Cannot read from serial port");
}
else if... | [
"int",
"readAsciiByte",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"commPort",
"!=",
"null",
"&&",
"commPort",
".",
"isOpen",
"(",
")",
")",
"{",
"byte",
"[",
"]",
"buffer",
"=",
"new",
"byte",
"[",
"1",
"]",
";",
"int",
"cnt",
"=",
"commPo... | Reads an ascii byte from the input stream
It handles the special start and end frame markers
@return Byte value of the next ASCII couplet
@throws IOException If a problem with the port | [
"Reads",
"an",
"ascii",
"byte",
"from",
"the",
"input",
"stream",
"It",
"handles",
"the",
"special",
"start",
"and",
"end",
"frame",
"markers"
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java#L456-L487 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java | ModbusSerialTransport.writeAsciiBytes | int writeAsciiBytes(byte[] buffer, long bytesToWrite) throws IOException {
if (commPort != null && commPort.isOpen()) {
int cnt = 0;
for (int i = 0; i < bytesToWrite; i++) {
if (writeAsciiByte(buffer[i]) != 2) {
return cnt;
}
... | java | int writeAsciiBytes(byte[] buffer, long bytesToWrite) throws IOException {
if (commPort != null && commPort.isOpen()) {
int cnt = 0;
for (int i = 0; i < bytesToWrite; i++) {
if (writeAsciiByte(buffer[i]) != 2) {
return cnt;
}
... | [
"int",
"writeAsciiBytes",
"(",
"byte",
"[",
"]",
"buffer",
",",
"long",
"bytesToWrite",
")",
"throws",
"IOException",
"{",
"if",
"(",
"commPort",
"!=",
"null",
"&&",
"commPort",
".",
"isOpen",
"(",
")",
")",
"{",
"int",
"cnt",
"=",
"0",
";",
"for",
"... | Writes an array of bytes out as a stream of ascii characters
@param buffer Buffer of bytes to write
@param bytesToWrite Number of characters to write
@return Number of bytes written
@throws IOException If a problem with the port | [
"Writes",
"an",
"array",
"of",
"bytes",
"out",
"as",
"a",
"stream",
"of",
"ascii",
"characters"
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java#L538-L552 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java | ModbusSerialTransport.clearInput | void clearInput() throws IOException {
if (commPort.bytesAvailable() > 0) {
int len = commPort.bytesAvailable();
byte buf[] = new byte[len];
readBytes(buf, len);
if (logger.isDebugEnabled()) {
logger.debug("Clear input: {}", ModbusUtil.toHex(buf, 0... | java | void clearInput() throws IOException {
if (commPort.bytesAvailable() > 0) {
int len = commPort.bytesAvailable();
byte buf[] = new byte[len];
readBytes(buf, len);
if (logger.isDebugEnabled()) {
logger.debug("Clear input: {}", ModbusUtil.toHex(buf, 0... | [
"void",
"clearInput",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"commPort",
".",
"bytesAvailable",
"(",
")",
">",
"0",
")",
"{",
"int",
"len",
"=",
"commPort",
".",
"bytesAvailable",
"(",
")",
";",
"byte",
"buf",
"[",
"]",
"=",
"new",
"byte"... | clearInput - Clear the input if characters are found in the input stream.
@throws IOException If a problem with the port | [
"clearInput",
"-",
"Clear",
"the",
"input",
"if",
"characters",
"are",
"found",
"in",
"the",
"input",
"stream",
"."
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java#L559-L568 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java | ModbusSerialTransport.waitBetweenFrames | void waitBetweenFrames(int transDelayMS, long lastTransactionTimestamp) {
// If a fixed delay has been set
if (transDelayMS > 0) {
ModbusUtil.sleep(transDelayMS);
}
else {
// Make use we have a gap of 3.5 characters between adjacent requests
// We hav... | java | void waitBetweenFrames(int transDelayMS, long lastTransactionTimestamp) {
// If a fixed delay has been set
if (transDelayMS > 0) {
ModbusUtil.sleep(transDelayMS);
}
else {
// Make use we have a gap of 3.5 characters between adjacent requests
// We hav... | [
"void",
"waitBetweenFrames",
"(",
"int",
"transDelayMS",
",",
"long",
"lastTransactionTimestamp",
")",
"{",
"// If a fixed delay has been set",
"if",
"(",
"transDelayMS",
">",
"0",
")",
"{",
"ModbusUtil",
".",
"sleep",
"(",
"transDelayMS",
")",
";",
"}",
"else",
... | Injects a delay dependent on the last time we received a response or
if a fixed delay has been specified
@param transDelayMS Fixed transaction delay (milliseconds)
@param lastTransactionTimestamp Timestamp of last transaction | [
"Injects",
"a",
"delay",
"dependent",
"on",
"the",
"last",
"time",
"we",
"received",
"a",
"response",
"or",
"if",
"a",
"fixed",
"delay",
"has",
"been",
"specified"
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java#L593-L617 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java | ModbusSerialTransport.getCharIntervalMicro | long getCharIntervalMicro(double chars) {
// Make use we have a gap of 3.5 characters between adjacent requests
// We have to do the calculations here because it is possible that the caller may have changed
// the connection characteristics if they provided the connection instance
return... | java | long getCharIntervalMicro(double chars) {
// Make use we have a gap of 3.5 characters between adjacent requests
// We have to do the calculations here because it is possible that the caller may have changed
// the connection characteristics if they provided the connection instance
return... | [
"long",
"getCharIntervalMicro",
"(",
"double",
"chars",
")",
"{",
"// Make use we have a gap of 3.5 characters between adjacent requests",
"// We have to do the calculations here because it is possible that the caller may have changed",
"// the connection characteristics if they provided the conne... | Calculates an interval based on a set number of characters.
Used for message timings.
@param chars Number of caracters
@return microseconds | [
"Calculates",
"an",
"interval",
"based",
"on",
"a",
"set",
"number",
"of",
"characters",
".",
"Used",
"for",
"message",
"timings",
"."
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java#L665-L670 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java | ModbusSerialTransport.spinUntilBytesAvailable | boolean spinUntilBytesAvailable(long waitTimeMicroSec) {
long start = System.nanoTime();
while (availableBytes() < 1) {
long delta = System.nanoTime() - start;
if (delta > waitTimeMicroSec * 1000) {
return false;
}
}
return true;
} | java | boolean spinUntilBytesAvailable(long waitTimeMicroSec) {
long start = System.nanoTime();
while (availableBytes() < 1) {
long delta = System.nanoTime() - start;
if (delta > waitTimeMicroSec * 1000) {
return false;
}
}
return true;
} | [
"boolean",
"spinUntilBytesAvailable",
"(",
"long",
"waitTimeMicroSec",
")",
"{",
"long",
"start",
"=",
"System",
".",
"nanoTime",
"(",
")",
";",
"while",
"(",
"availableBytes",
"(",
")",
"<",
"1",
")",
"{",
"long",
"delta",
"=",
"System",
".",
"nanoTime",
... | Spins until the timeout or the condition is met.
This method will repeatedly poll the available bytes, so it should not have any side effects.
@param waitTimeMicroSec The time to wait for the condition to be true in microseconds
@return true if the condition ended the spin, false if the tim | [
"Spins",
"until",
"the",
"timeout",
"or",
"the",
"condition",
"is",
"met",
".",
"This",
"method",
"will",
"repeatedly",
"poll",
"the",
"available",
"bytes",
"so",
"it",
"should",
"not",
"have",
"any",
"side",
"effects",
"."
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/ModbusSerialTransport.java#L679-L688 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/slave/ModbusSlave.java | ModbusSlave.open | public void open() throws ModbusException {
// Start the listener if it isn' already running
if (!isRunning) {
try {
listenerThread = new Thread(listener);
listenerThread.start();
isRunning = true;
}
catch (Exception x... | java | public void open() throws ModbusException {
// Start the listener if it isn' already running
if (!isRunning) {
try {
listenerThread = new Thread(listener);
listenerThread.start();
isRunning = true;
}
catch (Exception x... | [
"public",
"void",
"open",
"(",
")",
"throws",
"ModbusException",
"{",
"// Start the listener if it isn' already running",
"if",
"(",
"!",
"isRunning",
")",
"{",
"try",
"{",
"listenerThread",
"=",
"new",
"Thread",
"(",
"listener",
")",
";",
"listenerThread",
".",
... | Opens the listener to service requests
@throws ModbusException If we cannot listen | [
"Opens",
"the",
"listener",
"to",
"service",
"requests"
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/slave/ModbusSlave.java#L208-L223 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/slave/ModbusSlave.java | ModbusSlave.closeListener | @SuppressWarnings("deprecation")
void closeListener() {
if (listener != null && listener.isListening()) {
listener.stop();
// Wait until the listener says it has stopped, but don't wait forever
int count = 0;
while (listenerThread != null && listenerThread.is... | java | @SuppressWarnings("deprecation")
void closeListener() {
if (listener != null && listener.isListening()) {
listener.stop();
// Wait until the listener says it has stopped, but don't wait forever
int count = 0;
while (listenerThread != null && listenerThread.is... | [
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"void",
"closeListener",
"(",
")",
"{",
"if",
"(",
"listener",
"!=",
"null",
"&&",
"listener",
".",
"isListening",
"(",
")",
")",
"{",
"listener",
".",
"stop",
"(",
")",
";",
"// Wait until the listener s... | Closes the listener of this slave | [
"Closes",
"the",
"listener",
"of",
"this",
"slave"
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/slave/ModbusSlave.java#L254-L272 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/net/AbstractModbusListener.java | AbstractModbusListener.handleRequest | void handleRequest(AbstractModbusTransport transport, AbstractModbusListener listener) throws ModbusIOException {
// Get the request from the transport. It will be processed
// using an associated process image
if (transport == null) {
throw new ModbusIOException("No transport spec... | java | void handleRequest(AbstractModbusTransport transport, AbstractModbusListener listener) throws ModbusIOException {
// Get the request from the transport. It will be processed
// using an associated process image
if (transport == null) {
throw new ModbusIOException("No transport spec... | [
"void",
"handleRequest",
"(",
"AbstractModbusTransport",
"transport",
",",
"AbstractModbusListener",
"listener",
")",
"throws",
"ModbusIOException",
"{",
"// Get the request from the transport. It will be processed",
"// using an associated process image",
"if",
"(",
"transport",
"... | Reads the request, checks it is valid and that the unit ID is ok
and sends back a response
@param transport Transport to read request from
@param listener Listener that the request was received by
@throws ModbusIOException If there is an issue with the transport or transmission | [
"Reads",
"the",
"request",
"checks",
"it",
"is",
"valid",
"and",
"that",
"the",
"unit",
"ID",
"is",
"ok",
"and",
"sends",
"back",
"a",
"response"
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/net/AbstractModbusListener.java#L153-L190 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/net/AbstractModbusListener.java | AbstractModbusListener.getProcessImage | public ProcessImage getProcessImage(int unitId) {
ModbusSlave slave = ModbusSlaveFactory.getSlave(this);
if (slave != null) {
return slave.getProcessImage(unitId);
}
return null;
} | java | public ProcessImage getProcessImage(int unitId) {
ModbusSlave slave = ModbusSlaveFactory.getSlave(this);
if (slave != null) {
return slave.getProcessImage(unitId);
}
return null;
} | [
"public",
"ProcessImage",
"getProcessImage",
"(",
"int",
"unitId",
")",
"{",
"ModbusSlave",
"slave",
"=",
"ModbusSlaveFactory",
".",
"getSlave",
"(",
"this",
")",
";",
"if",
"(",
"slave",
"!=",
"null",
")",
"{",
"return",
"slave",
".",
"getProcessImage",
"("... | Returns the related process image for this listener and Unit Id
@param unitId Unit ID
@return Process image associated with this listener and Unit ID | [
"Returns",
"the",
"related",
"process",
"image",
"for",
"this",
"listener",
"and",
"Unit",
"Id"
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/net/AbstractModbusListener.java#L198-L204 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/io/ModbusASCIITransport.java | ModbusASCIITransport.calculateLRC | private static byte calculateLRC(byte[] data, int off, int length, int tailskip) {
int lrc = 0;
for (int i = off; i < length - tailskip; i++) {
lrc += ((int) data[i]) & 0xFF;
}
return (byte) ((-lrc) & 0xff);
} | java | private static byte calculateLRC(byte[] data, int off, int length, int tailskip) {
int lrc = 0;
for (int i = off; i < length - tailskip; i++) {
lrc += ((int) data[i]) & 0xFF;
}
return (byte) ((-lrc) & 0xff);
} | [
"private",
"static",
"byte",
"calculateLRC",
"(",
"byte",
"[",
"]",
"data",
",",
"int",
"off",
",",
"int",
"length",
",",
"int",
"tailskip",
")",
"{",
"int",
"lrc",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"off",
";",
"i",
"<",
"length",
"-",
... | Calculates a LRC checksum
@param data Data to use
@param off Offset into byte array
@param length Number of bytes to use
@param tailskip Bytes to skip at tail
@return Checksum | [
"Calculates",
"a",
"LRC",
"checksum"
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/ModbusASCIITransport.java#L211-L217 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/facade/AbstractModbusMaster.java | AbstractModbusMaster.readCoils | public BitVector readCoils(int unitId, int ref, int count) throws ModbusException {
checkTransaction();
if (readCoilsRequest == null) {
readCoilsRequest = new ReadCoilsRequest();
}
readCoilsRequest.setUnitID(unitId);
readCoilsRequest.setReference(ref);
readCoi... | java | public BitVector readCoils(int unitId, int ref, int count) throws ModbusException {
checkTransaction();
if (readCoilsRequest == null) {
readCoilsRequest = new ReadCoilsRequest();
}
readCoilsRequest.setUnitID(unitId);
readCoilsRequest.setReference(ref);
readCoi... | [
"public",
"BitVector",
"readCoils",
"(",
"int",
"unitId",
",",
"int",
"ref",
",",
"int",
"count",
")",
"throws",
"ModbusException",
"{",
"checkTransaction",
"(",
")",
";",
"if",
"(",
"readCoilsRequest",
"==",
"null",
")",
"{",
"readCoilsRequest",
"=",
"new",... | Reads a given number of coil states from the slave.
Note that the number of bits in the bit vector will be
forced to the number originally requested.
@param unitId the slave unit id.
@param ref the offset of the coil to start reading from.
@param count the number of coil states to be read.
@return a <tt>BitVecto... | [
"Reads",
"a",
"given",
"number",
"of",
"coil",
"states",
"from",
"the",
"slave",
"."
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/facade/AbstractModbusMaster.java#L89-L102 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/facade/AbstractModbusMaster.java | AbstractModbusMaster.writeCoil | public boolean writeCoil(int unitId, int ref, boolean state) throws ModbusException {
checkTransaction();
if (writeCoilRequest == null) {
writeCoilRequest = new WriteCoilRequest();
}
writeCoilRequest.setUnitID(unitId);
writeCoilRequest.setReference(ref);
write... | java | public boolean writeCoil(int unitId, int ref, boolean state) throws ModbusException {
checkTransaction();
if (writeCoilRequest == null) {
writeCoilRequest = new WriteCoilRequest();
}
writeCoilRequest.setUnitID(unitId);
writeCoilRequest.setReference(ref);
write... | [
"public",
"boolean",
"writeCoil",
"(",
"int",
"unitId",
",",
"int",
"ref",
",",
"boolean",
"state",
")",
"throws",
"ModbusException",
"{",
"checkTransaction",
"(",
")",
";",
"if",
"(",
"writeCoilRequest",
"==",
"null",
")",
"{",
"writeCoilRequest",
"=",
"new... | Writes a coil state to the slave.
@param unitId the slave unit id.
@param ref the offset of the coil to be written.
@param state the coil state to be written.
@return the state of the coil as returned from the slave.
@throws ModbusException if an I/O error, a slave exception or
a transaction error occurs. | [
"Writes",
"a",
"coil",
"state",
"to",
"the",
"slave",
"."
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/facade/AbstractModbusMaster.java#L116-L127 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/facade/AbstractModbusMaster.java | AbstractModbusMaster.writeMultipleCoils | public void writeMultipleCoils(int unitId, int ref, BitVector coils) throws ModbusException {
checkTransaction();
if (writeMultipleCoilsRequest == null) {
writeMultipleCoilsRequest = new WriteMultipleCoilsRequest();
}
writeMultipleCoilsRequest.setUnitID(unitId);
write... | java | public void writeMultipleCoils(int unitId, int ref, BitVector coils) throws ModbusException {
checkTransaction();
if (writeMultipleCoilsRequest == null) {
writeMultipleCoilsRequest = new WriteMultipleCoilsRequest();
}
writeMultipleCoilsRequest.setUnitID(unitId);
write... | [
"public",
"void",
"writeMultipleCoils",
"(",
"int",
"unitId",
",",
"int",
"ref",
",",
"BitVector",
"coils",
")",
"throws",
"ModbusException",
"{",
"checkTransaction",
"(",
")",
";",
"if",
"(",
"writeMultipleCoilsRequest",
"==",
"null",
")",
"{",
"writeMultipleCo... | Writes a given number of coil states to the slave.
Note that the number of coils to be written is given
implicitly, through {@link BitVector#size()}.
@param unitId the slave unit id.
@param ref the offset of the coil to start writing to.
@param coils a <tt>BitVector</tt> which holds the coil states to be written.... | [
"Writes",
"a",
"given",
"number",
"of",
"coil",
"states",
"to",
"the",
"slave",
"."
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/facade/AbstractModbusMaster.java#L142-L152 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/facade/AbstractModbusMaster.java | AbstractModbusMaster.readInputDiscretes | public BitVector readInputDiscretes(int unitId, int ref, int count) throws ModbusException {
checkTransaction();
if (readInputDiscretesRequest == null) {
readInputDiscretesRequest = new ReadInputDiscretesRequest();
}
readInputDiscretesRequest.setUnitID(unitId);
readIn... | java | public BitVector readInputDiscretes(int unitId, int ref, int count) throws ModbusException {
checkTransaction();
if (readInputDiscretesRequest == null) {
readInputDiscretesRequest = new ReadInputDiscretesRequest();
}
readInputDiscretesRequest.setUnitID(unitId);
readIn... | [
"public",
"BitVector",
"readInputDiscretes",
"(",
"int",
"unitId",
",",
"int",
"ref",
",",
"int",
"count",
")",
"throws",
"ModbusException",
"{",
"checkTransaction",
"(",
")",
";",
"if",
"(",
"readInputDiscretesRequest",
"==",
"null",
")",
"{",
"readInputDiscret... | Reads a given number of input discrete states from the slave.
Note that the number of bits in the bit vector will be
forced to the number originally requested.
@param unitId the slave unit id.
@param ref the offset of the input discrete to start reading from.
@param count the number of input discrete states to be... | [
"Reads",
"a",
"given",
"number",
"of",
"input",
"discrete",
"states",
"from",
"the",
"slave",
"."
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/facade/AbstractModbusMaster.java#L170-L183 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/facade/AbstractModbusMaster.java | AbstractModbusMaster.readInputRegisters | public InputRegister[] readInputRegisters(int unitId, int ref, int count) throws ModbusException {
checkTransaction();
if (readInputRegistersRequest == null) {
readInputRegistersRequest = new ReadInputRegistersRequest();
}
readInputRegistersRequest.setUnitID(unitId);
... | java | public InputRegister[] readInputRegisters(int unitId, int ref, int count) throws ModbusException {
checkTransaction();
if (readInputRegistersRequest == null) {
readInputRegistersRequest = new ReadInputRegistersRequest();
}
readInputRegistersRequest.setUnitID(unitId);
... | [
"public",
"InputRegister",
"[",
"]",
"readInputRegisters",
"(",
"int",
"unitId",
",",
"int",
"ref",
",",
"int",
"count",
")",
"throws",
"ModbusException",
"{",
"checkTransaction",
"(",
")",
";",
"if",
"(",
"readInputRegistersRequest",
"==",
"null",
")",
"{",
... | Reads a given number of input registers from the slave.
Note that the number of input registers returned (i.e. array length)
will be according to the number received in the slave response.
@param unitId the slave unit id.
@param ref the offset of the input register to start reading from.
@param count the number o... | [
"Reads",
"a",
"given",
"number",
"of",
"input",
"registers",
"from",
"the",
"slave",
"."
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/facade/AbstractModbusMaster.java#L200-L211 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/facade/AbstractModbusMaster.java | AbstractModbusMaster.readMultipleRegisters | public Register[] readMultipleRegisters(int unitId, int ref, int count) throws ModbusException {
checkTransaction();
if (readMultipleRegistersRequest == null) {
readMultipleRegistersRequest = new ReadMultipleRegistersRequest();
}
readMultipleRegistersRequest.setUnitID(unitId)... | java | public Register[] readMultipleRegisters(int unitId, int ref, int count) throws ModbusException {
checkTransaction();
if (readMultipleRegistersRequest == null) {
readMultipleRegistersRequest = new ReadMultipleRegistersRequest();
}
readMultipleRegistersRequest.setUnitID(unitId)... | [
"public",
"Register",
"[",
"]",
"readMultipleRegisters",
"(",
"int",
"unitId",
",",
"int",
"ref",
",",
"int",
"count",
")",
"throws",
"ModbusException",
"{",
"checkTransaction",
"(",
")",
";",
"if",
"(",
"readMultipleRegistersRequest",
"==",
"null",
")",
"{",
... | Reads a given number of registers from the slave.
Note that the number of registers returned (i.e. array length)
will be according to the number received in the slave response.
@param unitId the slave unit id.
@param ref the offset of the register to start reading from.
@param count the number of registers to be ... | [
"Reads",
"a",
"given",
"number",
"of",
"registers",
"from",
"the",
"slave",
"."
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/facade/AbstractModbusMaster.java#L228-L239 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/facade/AbstractModbusMaster.java | AbstractModbusMaster.writeSingleRegister | public int writeSingleRegister(int unitId, int ref, Register register) throws ModbusException {
checkTransaction();
if (writeSingleRegisterRequest == null) {
writeSingleRegisterRequest = new WriteSingleRegisterRequest();
}
writeSingleRegisterRequest.setUnitID(unitId);
... | java | public int writeSingleRegister(int unitId, int ref, Register register) throws ModbusException {
checkTransaction();
if (writeSingleRegisterRequest == null) {
writeSingleRegisterRequest = new WriteSingleRegisterRequest();
}
writeSingleRegisterRequest.setUnitID(unitId);
... | [
"public",
"int",
"writeSingleRegister",
"(",
"int",
"unitId",
",",
"int",
"ref",
",",
"Register",
"register",
")",
"throws",
"ModbusException",
"{",
"checkTransaction",
"(",
")",
";",
"if",
"(",
"writeSingleRegisterRequest",
"==",
"null",
")",
"{",
"writeSingleR... | Writes a single register to the slave.
@param unitId the slave unit id.
@param ref the offset of the register to be written.
@param register a <tt>Register</tt> holding the value of the register
to be written.
@return the value of the register as returned from the slave.
@throws ModbusException if an I/O erro... | [
"Writes",
"a",
"single",
"register",
"to",
"the",
"slave",
"."
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/facade/AbstractModbusMaster.java#L254-L265 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/facade/AbstractModbusMaster.java | AbstractModbusMaster.writeMultipleRegisters | public int writeMultipleRegisters(int unitId, int ref, Register[] registers) throws ModbusException {
checkTransaction();
if (writeMultipleRegistersRequest == null) {
writeMultipleRegistersRequest = new WriteMultipleRegistersRequest();
}
writeMultipleRegistersRequest.setUnitI... | java | public int writeMultipleRegisters(int unitId, int ref, Register[] registers) throws ModbusException {
checkTransaction();
if (writeMultipleRegistersRequest == null) {
writeMultipleRegistersRequest = new WriteMultipleRegistersRequest();
}
writeMultipleRegistersRequest.setUnitI... | [
"public",
"int",
"writeMultipleRegisters",
"(",
"int",
"unitId",
",",
"int",
"ref",
",",
"Register",
"[",
"]",
"registers",
")",
"throws",
"ModbusException",
"{",
"checkTransaction",
"(",
")",
";",
"if",
"(",
"writeMultipleRegistersRequest",
"==",
"null",
")",
... | Writes a number of registers to the slave.
@param unitId the slave unit id.
@param ref the offset of the register to start writing to.
@param registers a <tt>Register[]</tt> holding the values of
the registers to be written.
@return the number of registers that have been written.
@throws ModbusException if ... | [
"Writes",
"a",
"number",
"of",
"registers",
"to",
"the",
"slave",
"."
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/facade/AbstractModbusMaster.java#L280-L291 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/facade/AbstractModbusMaster.java | AbstractModbusMaster.getAndCheckResponse | private ModbusResponse getAndCheckResponse() throws ModbusException {
ModbusResponse res = transaction.getResponse();
if (res == null) {
throw new ModbusException("No response");
}
return res;
} | java | private ModbusResponse getAndCheckResponse() throws ModbusException {
ModbusResponse res = transaction.getResponse();
if (res == null) {
throw new ModbusException("No response");
}
return res;
} | [
"private",
"ModbusResponse",
"getAndCheckResponse",
"(",
")",
"throws",
"ModbusException",
"{",
"ModbusResponse",
"res",
"=",
"transaction",
".",
"getResponse",
"(",
")",
";",
"if",
"(",
"res",
"==",
"null",
")",
"{",
"throw",
"new",
"ModbusException",
"(",
"\... | Reads the response from the transaction
If there is no response, then it throws an error
@return Modbus response
@throws ModbusException If response is null | [
"Reads",
"the",
"response",
"from",
"the",
"transaction",
"If",
"there",
"is",
"no",
"response",
"then",
"it",
"throws",
"an",
"error"
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/facade/AbstractModbusMaster.java#L485-L491 | train |
steveohara/j2mod | src/main/java/com/ghgande/j2mod/modbus/net/SerialConnection.java | SerialConnection.getCommPort | public static AbstractSerialConnection getCommPort(String commPort) {
SerialConnection jSerialCommPort = new SerialConnection();
jSerialCommPort.serialPort = SerialPort.getCommPort(commPort);
return jSerialCommPort;
} | java | public static AbstractSerialConnection getCommPort(String commPort) {
SerialConnection jSerialCommPort = new SerialConnection();
jSerialCommPort.serialPort = SerialPort.getCommPort(commPort);
return jSerialCommPort;
} | [
"public",
"static",
"AbstractSerialConnection",
"getCommPort",
"(",
"String",
"commPort",
")",
"{",
"SerialConnection",
"jSerialCommPort",
"=",
"new",
"SerialConnection",
"(",
")",
";",
"jSerialCommPort",
".",
"serialPort",
"=",
"SerialPort",
".",
"getCommPort",
"(",
... | Returns a JSerialComm implementation for the given comms port
@param commPort Comms port e.g. /dev/ttyAMA0
@return JSerialComm implementation | [
"Returns",
"a",
"JSerialComm",
"implementation",
"for",
"the",
"given",
"comms",
"port"
] | 67162c55d7c02564e50211a9df06b8314953b5f2 | https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/net/SerialConnection.java#L75-L79 | train |
jurmous/etcd4j | src/main/java/mousio/client/promises/ResponsePromise.java | ResponsePromise.attachNettyPromise | public void attachNettyPromise(Promise<T> promise) {
promise.addListener(promiseHandler);
Promise<T> oldPromise = this.promise;
this.promise = promise;
if (oldPromise != null) {
oldPromise.removeListener(promiseHandler);
oldPromise.cancel(true);
}
} | java | public void attachNettyPromise(Promise<T> promise) {
promise.addListener(promiseHandler);
Promise<T> oldPromise = this.promise;
this.promise = promise;
if (oldPromise != null) {
oldPromise.removeListener(promiseHandler);
oldPromise.cancel(true);
}
} | [
"public",
"void",
"attachNettyPromise",
"(",
"Promise",
"<",
"T",
">",
"promise",
")",
"{",
"promise",
".",
"addListener",
"(",
"promiseHandler",
")",
";",
"Promise",
"<",
"T",
">",
"oldPromise",
"=",
"this",
".",
"promise",
";",
"this",
".",
"promise",
... | Attach Netty Promise
@param promise netty promise to set up response promise with | [
"Attach",
"Netty",
"Promise"
] | ffb1d574cf85bbab025dd566ce250f1860bbcbc7 | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/client/promises/ResponsePromise.java#L80-L90 | train |
jurmous/etcd4j | src/main/java/mousio/client/promises/ResponsePromise.java | ResponsePromise.addListener | public void addListener(IsSimplePromiseResponseHandler<T> listener) {
if (handlers == null) {
handlers = new LinkedList<>();
}
handlers.add(listener);
if (response != null || exception != null) {
listener.onResponse(this);
}
} | java | public void addListener(IsSimplePromiseResponseHandler<T> listener) {
if (handlers == null) {
handlers = new LinkedList<>();
}
handlers.add(listener);
if (response != null || exception != null) {
listener.onResponse(this);
}
} | [
"public",
"void",
"addListener",
"(",
"IsSimplePromiseResponseHandler",
"<",
"T",
">",
"listener",
")",
"{",
"if",
"(",
"handlers",
"==",
"null",
")",
"{",
"handlers",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"}",
"handlers",
".",
"add",
"(",
"list... | Add a promise to do when Response comes in
@param listener to add | [
"Add",
"a",
"promise",
"to",
"do",
"when",
"Response",
"comes",
"in"
] | ffb1d574cf85bbab025dd566ce250f1860bbcbc7 | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/client/promises/ResponsePromise.java#L97-L107 | train |
jurmous/etcd4j | src/main/java/mousio/client/promises/ResponsePromise.java | ResponsePromise.handlePromise | protected void handlePromise(Promise<T> promise) {
if (!promise.isSuccess()) {
this.setException(promise.cause());
} else {
this.response = promise.getNow();
if (handlers != null) {
for (IsSimplePromiseResponseHandler<T> h : handlers) {
h.onResponse(this);
}
}
... | java | protected void handlePromise(Promise<T> promise) {
if (!promise.isSuccess()) {
this.setException(promise.cause());
} else {
this.response = promise.getNow();
if (handlers != null) {
for (IsSimplePromiseResponseHandler<T> h : handlers) {
h.onResponse(this);
}
}
... | [
"protected",
"void",
"handlePromise",
"(",
"Promise",
"<",
"T",
">",
"promise",
")",
"{",
"if",
"(",
"!",
"promise",
".",
"isSuccess",
"(",
")",
")",
"{",
"this",
".",
"setException",
"(",
"promise",
".",
"cause",
"(",
")",
")",
";",
"}",
"else",
"... | Handle the promise
@param promise to handle | [
"Handle",
"the",
"promise"
] | ffb1d574cf85bbab025dd566ce250f1860bbcbc7 | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/client/promises/ResponsePromise.java#L125-L136 | train |
jurmous/etcd4j | src/main/java/mousio/client/promises/ResponsePromise.java | ResponsePromise.waitForPromiseSuccess | protected void waitForPromiseSuccess() throws IOException, TimeoutException {
while(!promise.isDone() && !promise.isCancelled()) {
Promise<T> listeningPromise = this.promise;
listeningPromise.awaitUninterruptibly();
if (listeningPromise == this.promise) {
this.handlePromise(promise);
... | java | protected void waitForPromiseSuccess() throws IOException, TimeoutException {
while(!promise.isDone() && !promise.isCancelled()) {
Promise<T> listeningPromise = this.promise;
listeningPromise.awaitUninterruptibly();
if (listeningPromise == this.promise) {
this.handlePromise(promise);
... | [
"protected",
"void",
"waitForPromiseSuccess",
"(",
")",
"throws",
"IOException",
",",
"TimeoutException",
"{",
"while",
"(",
"!",
"promise",
".",
"isDone",
"(",
")",
"&&",
"!",
"promise",
".",
"isCancelled",
"(",
")",
")",
"{",
"Promise",
"<",
"T",
">",
... | Wait for promise to be done
@throws IOException on IOException
@throws TimeoutException on timeout | [
"Wait",
"for",
"promise",
"to",
"be",
"done"
] | ffb1d574cf85bbab025dd566ce250f1860bbcbc7 | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/client/promises/ResponsePromise.java#L183-L192 | train |
jurmous/etcd4j | src/main/java/mousio/client/promises/ResponsePromise.java | ResponsePromise.handleRetry | public void handleRetry(Throwable cause) {
try {
this.retryPolicy.retry(connectionState, retryHandler, connectionFailHandler);
} catch (RetryPolicy.RetryCancelled retryCancelled) {
this.getNettyPromise().setFailure(cause);
}
} | java | public void handleRetry(Throwable cause) {
try {
this.retryPolicy.retry(connectionState, retryHandler, connectionFailHandler);
} catch (RetryPolicy.RetryCancelled retryCancelled) {
this.getNettyPromise().setFailure(cause);
}
} | [
"public",
"void",
"handleRetry",
"(",
"Throwable",
"cause",
")",
"{",
"try",
"{",
"this",
".",
"retryPolicy",
".",
"retry",
"(",
"connectionState",
",",
"retryHandler",
",",
"connectionFailHandler",
")",
";",
"}",
"catch",
"(",
"RetryPolicy",
".",
"RetryCancel... | Handles a retry
@param cause of last connect fail | [
"Handles",
"a",
"retry"
] | ffb1d574cf85bbab025dd566ce250f1860bbcbc7 | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/client/promises/ResponsePromise.java#L218-L224 | train |
jurmous/etcd4j | src/main/java/mousio/etcd4j/EtcdClient.java | EtcdClient.getSelfStats | public EtcdSelfStatsResponse getSelfStats() {
try {
return new EtcdSelfStatsRequest(this.client, retryHandler).send().get();
} catch (IOException | EtcdException | EtcdAuthenticationException | TimeoutException e) {
return null;
}
} | java | public EtcdSelfStatsResponse getSelfStats() {
try {
return new EtcdSelfStatsRequest(this.client, retryHandler).send().get();
} catch (IOException | EtcdException | EtcdAuthenticationException | TimeoutException e) {
return null;
}
} | [
"public",
"EtcdSelfStatsResponse",
"getSelfStats",
"(",
")",
"{",
"try",
"{",
"return",
"new",
"EtcdSelfStatsRequest",
"(",
"this",
".",
"client",
",",
"retryHandler",
")",
".",
"send",
"(",
")",
".",
"get",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",... | Get the Self Statistics of Etcd
@return EtcdSelfStatsResponse | [
"Get",
"the",
"Self",
"Statistics",
"of",
"Etcd"
] | ffb1d574cf85bbab025dd566ce250f1860bbcbc7 | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/etcd4j/EtcdClient.java#L145-L151 | train |
jurmous/etcd4j | src/main/java/mousio/etcd4j/EtcdClient.java | EtcdClient.getLeaderStats | public EtcdLeaderStatsResponse getLeaderStats() {
try {
return new EtcdLeaderStatsRequest(this.client, retryHandler).send().get();
} catch (IOException | EtcdException | EtcdAuthenticationException | TimeoutException e) {
return null;
}
} | java | public EtcdLeaderStatsResponse getLeaderStats() {
try {
return new EtcdLeaderStatsRequest(this.client, retryHandler).send().get();
} catch (IOException | EtcdException | EtcdAuthenticationException | TimeoutException e) {
return null;
}
} | [
"public",
"EtcdLeaderStatsResponse",
"getLeaderStats",
"(",
")",
"{",
"try",
"{",
"return",
"new",
"EtcdLeaderStatsRequest",
"(",
"this",
".",
"client",
",",
"retryHandler",
")",
".",
"send",
"(",
")",
".",
"get",
"(",
")",
";",
"}",
"catch",
"(",
"IOExcep... | Get the Leader Statistics of Etcd
@return EtcdLeaderStatsResponse | [
"Get",
"the",
"Leader",
"Statistics",
"of",
"Etcd"
] | ffb1d574cf85bbab025dd566ce250f1860bbcbc7 | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/etcd4j/EtcdClient.java#L158-L164 | train |
jurmous/etcd4j | src/main/java/mousio/etcd4j/EtcdClient.java | EtcdClient.getStoreStats | public EtcdStoreStatsResponse getStoreStats() {
try {
return new EtcdStoreStatsRequest(this.client, retryHandler).send().get();
} catch (IOException | EtcdException | EtcdAuthenticationException | TimeoutException e) {
return null;
}
} | java | public EtcdStoreStatsResponse getStoreStats() {
try {
return new EtcdStoreStatsRequest(this.client, retryHandler).send().get();
} catch (IOException | EtcdException | EtcdAuthenticationException | TimeoutException e) {
return null;
}
} | [
"public",
"EtcdStoreStatsResponse",
"getStoreStats",
"(",
")",
"{",
"try",
"{",
"return",
"new",
"EtcdStoreStatsRequest",
"(",
"this",
".",
"client",
",",
"retryHandler",
")",
".",
"send",
"(",
")",
".",
"get",
"(",
")",
";",
"}",
"catch",
"(",
"IOExceptio... | Get the Store Statistics of Etcd
@return vEtcdStoreStatsResponse | [
"Get",
"the",
"Store",
"Statistics",
"of",
"Etcd"
] | ffb1d574cf85bbab025dd566ce250f1860bbcbc7 | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/etcd4j/EtcdClient.java#L171-L177 | train |
jurmous/etcd4j | src/main/java/mousio/etcd4j/EtcdClient.java | EtcdClient.put | public EtcdKeyPutRequest put(String key, String value) {
return new EtcdKeyPutRequest(client, key, retryHandler).value(value);
} | java | public EtcdKeyPutRequest put(String key, String value) {
return new EtcdKeyPutRequest(client, key, retryHandler).value(value);
} | [
"public",
"EtcdKeyPutRequest",
"put",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"return",
"new",
"EtcdKeyPutRequest",
"(",
"client",
",",
"key",
",",
"retryHandler",
")",
".",
"value",
"(",
"value",
")",
";",
"}"
] | Put a key with a value
@param key to put
@param value to put on key
@return EtcdKeysRequest | [
"Put",
"a",
"key",
"with",
"a",
"value"
] | ffb1d574cf85bbab025dd566ce250f1860bbcbc7 | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/etcd4j/EtcdClient.java#L212-L214 | train |
jurmous/etcd4j | src/main/java/mousio/etcd4j/EtcdClient.java | EtcdClient.post | public EtcdKeyPostRequest post(String key, String value) {
return new EtcdKeyPostRequest(client, key, retryHandler).value(value);
} | java | public EtcdKeyPostRequest post(String key, String value) {
return new EtcdKeyPostRequest(client, key, retryHandler).value(value);
} | [
"public",
"EtcdKeyPostRequest",
"post",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"return",
"new",
"EtcdKeyPostRequest",
"(",
"client",
",",
"key",
",",
"retryHandler",
")",
".",
"value",
"(",
"value",
")",
";",
"}"
] | Post a value to a key for in-order keys.
@param key to post to
@param value to post
@return EtcdKeysRequest | [
"Post",
"a",
"value",
"to",
"a",
"key",
"for",
"in",
"-",
"order",
"keys",
"."
] | ffb1d574cf85bbab025dd566ce250f1860bbcbc7 | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/etcd4j/EtcdClient.java#L245-L247 | train |
jurmous/etcd4j | src/main/java/mousio/etcd4j/security/SecurityContextBuilder.java | SecurityContextBuilder.forKeystore | public static SslContext forKeystore(String keystorePath, String keystorePassword)
throws SecurityContextException {
return forKeystore(keystorePath, keystorePassword, "SunX509");
} | java | public static SslContext forKeystore(String keystorePath, String keystorePassword)
throws SecurityContextException {
return forKeystore(keystorePath, keystorePassword, "SunX509");
} | [
"public",
"static",
"SslContext",
"forKeystore",
"(",
"String",
"keystorePath",
",",
"String",
"keystorePassword",
")",
"throws",
"SecurityContextException",
"{",
"return",
"forKeystore",
"(",
"keystorePath",
",",
"keystorePassword",
",",
"\"SunX509\"",
")",
";",
"}"
... | Builds SslContext using a protected keystore file. Adequate for non-mutual TLS connections.
@param keystorePath Path for keystore file
@param keystorePassword Password for protected keystore file
@return SslContext ready to use
@throws SecurityContextException for any troubles building the SslContext | [
"Builds",
"SslContext",
"using",
"a",
"protected",
"keystore",
"file",
".",
"Adequate",
"for",
"non",
"-",
"mutual",
"TLS",
"connections",
"."
] | ffb1d574cf85bbab025dd566ce250f1860bbcbc7 | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/etcd4j/security/SecurityContextBuilder.java#L27-L30 | train |
jurmous/etcd4j | src/main/java/mousio/etcd4j/security/SecurityContextBuilder.java | SecurityContextBuilder.forKeystoreAndTruststore | public static SslContext forKeystoreAndTruststore(InputStream keystore, String keystorePassword, InputStream truststore, String truststorePassword, String keyManagerAlgorithm)
throws SecurityContextException {
try {
final KeyStore ks = KeyStore.getInstance(KEYSTORE_JKS);
fina... | java | public static SslContext forKeystoreAndTruststore(InputStream keystore, String keystorePassword, InputStream truststore, String truststorePassword, String keyManagerAlgorithm)
throws SecurityContextException {
try {
final KeyStore ks = KeyStore.getInstance(KEYSTORE_JKS);
fina... | [
"public",
"static",
"SslContext",
"forKeystoreAndTruststore",
"(",
"InputStream",
"keystore",
",",
"String",
"keystorePassword",
",",
"InputStream",
"truststore",
",",
"String",
"truststorePassword",
",",
"String",
"keyManagerAlgorithm",
")",
"throws",
"SecurityContextExcep... | Builds SslContext using protected keystore and truststores, overriding default key manger algorithm. Adequate for mutual TLS connections.
@param keystore Keystore inputstream (file, binaries, etc)
@param keystorePassword Password for protected keystore file
@param truststore Truststore inputstream (file, binaries, etc)... | [
"Builds",
"SslContext",
"using",
"protected",
"keystore",
"and",
"truststores",
"overriding",
"default",
"key",
"manger",
"algorithm",
".",
"Adequate",
"for",
"mutual",
"TLS",
"connections",
"."
] | ffb1d574cf85bbab025dd566ce250f1860bbcbc7 | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/etcd4j/security/SecurityContextBuilder.java#L121-L143 | train |
jurmous/etcd4j | src/main/java/mousio/etcd4j/transport/EtcdNettyClient.java | EtcdNettyClient.send | public <R> EtcdResponsePromise<R> send(final EtcdRequest<R> etcdRequest) throws IOException {
ConnectionState connectionState = new ConnectionState(uris, lastWorkingUriIndex);
if (etcdRequest.getPromise() == null) {
etcdRequest.setPromise(new EtcdResponsePromise<R>(
etcdRequest.getRetryPolicy(),
... | java | public <R> EtcdResponsePromise<R> send(final EtcdRequest<R> etcdRequest) throws IOException {
ConnectionState connectionState = new ConnectionState(uris, lastWorkingUriIndex);
if (etcdRequest.getPromise() == null) {
etcdRequest.setPromise(new EtcdResponsePromise<R>(
etcdRequest.getRetryPolicy(),
... | [
"public",
"<",
"R",
">",
"EtcdResponsePromise",
"<",
"R",
">",
"send",
"(",
"final",
"EtcdRequest",
"<",
"R",
">",
"etcdRequest",
")",
"throws",
"IOException",
"{",
"ConnectionState",
"connectionState",
"=",
"new",
"ConnectionState",
"(",
"uris",
",",
"lastWor... | Send a request and get a future.
@param etcdRequest Etcd Request to send
@return Promise for the request. | [
"Send",
"a",
"request",
"and",
"get",
"a",
"future",
"."
] | ffb1d574cf85bbab025dd566ce250f1860bbcbc7 | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/etcd4j/transport/EtcdNettyClient.java#L178-L196 | train |
jurmous/etcd4j | src/main/java/mousio/etcd4j/transport/EtcdNettyClient.java | EtcdNettyClient.modifyPipeLine | private <R> void modifyPipeLine(final EtcdRequest<R> req, final ChannelPipeline pipeline) {
final EtcdResponseHandler<R> handler = new EtcdResponseHandler<>(this, req);
if (req.hasTimeout()) {
pipeline.addFirst(new ReadTimeoutHandler(req.getTimeout(), req.getTimeoutUnit()));
}
pipeline.addLast(h... | java | private <R> void modifyPipeLine(final EtcdRequest<R> req, final ChannelPipeline pipeline) {
final EtcdResponseHandler<R> handler = new EtcdResponseHandler<>(this, req);
if (req.hasTimeout()) {
pipeline.addFirst(new ReadTimeoutHandler(req.getTimeout(), req.getTimeoutUnit()));
}
pipeline.addLast(h... | [
"private",
"<",
"R",
">",
"void",
"modifyPipeLine",
"(",
"final",
"EtcdRequest",
"<",
"R",
">",
"req",
",",
"final",
"ChannelPipeline",
"pipeline",
")",
"{",
"final",
"EtcdResponseHandler",
"<",
"R",
">",
"handler",
"=",
"new",
"EtcdResponseHandler",
"<>",
"... | Modify the pipeline for the request
@param req to process
@param pipeline to modify
@param <R> Type of Response | [
"Modify",
"the",
"pipeline",
"for",
"the",
"request"
] | ffb1d574cf85bbab025dd566ce250f1860bbcbc7 | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/etcd4j/transport/EtcdNettyClient.java#L331-L346 | train |
jurmous/etcd4j | src/main/java/mousio/etcd4j/transport/EtcdNettyClient.java | EtcdNettyClient.createAndSendHttpRequest | private <R> ChannelFuture createAndSendHttpRequest(URI server, String uri, EtcdRequest<R> etcdRequest, Channel channel) throws Exception {
HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, etcdRequest.getMethod(), uri);
httpRequest.headers().add(HttpHeaderNames.CONNECTION, "keep-alive");
... | java | private <R> ChannelFuture createAndSendHttpRequest(URI server, String uri, EtcdRequest<R> etcdRequest, Channel channel) throws Exception {
HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, etcdRequest.getMethod(), uri);
httpRequest.headers().add(HttpHeaderNames.CONNECTION, "keep-alive");
... | [
"private",
"<",
"R",
">",
"ChannelFuture",
"createAndSendHttpRequest",
"(",
"URI",
"server",
",",
"String",
"uri",
",",
"EtcdRequest",
"<",
"R",
">",
"etcdRequest",
",",
"Channel",
"channel",
")",
"throws",
"Exception",
"{",
"HttpRequest",
"httpRequest",
"=",
... | Get HttpRequest belonging to etcdRequest
@param server server for http request
@param uri to send request to
@param etcdRequest to send
@param channel to send request on
@param <R> Response type
@return HttpRequest
@throws Exception when creating or sending HTTP request fails | [
"Get",
"HttpRequest",
"belonging",
"to",
"etcdRequest"
] | ffb1d574cf85bbab025dd566ce250f1860bbcbc7 | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/etcd4j/transport/EtcdNettyClient.java#L359-L396 | train |
jurmous/etcd4j | src/main/java/mousio/etcd4j/requests/EtcdKeyPutRequest.java | EtcdKeyPutRequest.refresh | public EtcdKeyPutRequest refresh(Integer ttl) {
this.requestParams.put("refresh", "true");
this.prevExist(true);
return ttl(ttl);
} | java | public EtcdKeyPutRequest refresh(Integer ttl) {
this.requestParams.put("refresh", "true");
this.prevExist(true);
return ttl(ttl);
} | [
"public",
"EtcdKeyPutRequest",
"refresh",
"(",
"Integer",
"ttl",
")",
"{",
"this",
".",
"requestParams",
".",
"put",
"(",
"\"refresh\"",
",",
"\"true\"",
")",
";",
"this",
".",
"prevExist",
"(",
"true",
")",
";",
"return",
"ttl",
"(",
"ttl",
")",
";",
... | Set Time to live on a refresh request.
Requires previous value to exist
@param ttl time to live in seconds
@return Itself for chaining | [
"Set",
"Time",
"to",
"live",
"on",
"a",
"refresh",
"request",
".",
"Requires",
"previous",
"value",
"to",
"exist"
] | ffb1d574cf85bbab025dd566ce250f1860bbcbc7 | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/etcd4j/requests/EtcdKeyPutRequest.java#L69-L73 | train |
jurmous/etcd4j | src/main/java/mousio/client/retry/RetryPolicy.java | RetryPolicy.retry | public final void retry(final ConnectionState state, final RetryHandler retryHandler, final ConnectionFailHandler failHandler) throws RetryCancelled {
if (state.retryCount == 0) {
state.msBeforeRetry = this.startRetryTime;
}
state.retryCount++;
state.uriIndex = state.retryCount % state.uris.lengt... | java | public final void retry(final ConnectionState state, final RetryHandler retryHandler, final ConnectionFailHandler failHandler) throws RetryCancelled {
if (state.retryCount == 0) {
state.msBeforeRetry = this.startRetryTime;
}
state.retryCount++;
state.uriIndex = state.retryCount % state.uris.lengt... | [
"public",
"final",
"void",
"retry",
"(",
"final",
"ConnectionState",
"state",
",",
"final",
"RetryHandler",
"retryHandler",
",",
"final",
"ConnectionFailHandler",
"failHandler",
")",
"throws",
"RetryCancelled",
"{",
"if",
"(",
"state",
".",
"retryCount",
"==",
"0"... | Does the retry. Will always try all URIs before throwing an exception.
@param state of connection
@param retryHandler handles the retry itself
@param failHandler handles the fail
@throws RetryCancelled if retry is cancelled | [
"Does",
"the",
"retry",
".",
"Will",
"always",
"try",
"all",
"URIs",
"before",
"throwing",
"an",
"exception",
"."
] | ffb1d574cf85bbab025dd566ce250f1860bbcbc7 | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/client/retry/RetryPolicy.java#L51-L91 | train |
jurmous/etcd4j | src/main/java/mousio/etcd4j/transport/EtcdNettyConfig.java | EtcdNettyConfig.setEventLoopGroup | public EtcdNettyConfig setEventLoopGroup(EventLoopGroup eventLoopGroup, boolean managed) {
if (this.eventLoopGroup != null && this.managedEventLoopGroup) { // if i manage it, close the old when new one come
this.eventLoopGroup.shutdownGracefully();
}
this.eventLoopGroup = eventLoopGroup;
this.mana... | java | public EtcdNettyConfig setEventLoopGroup(EventLoopGroup eventLoopGroup, boolean managed) {
if (this.eventLoopGroup != null && this.managedEventLoopGroup) { // if i manage it, close the old when new one come
this.eventLoopGroup.shutdownGracefully();
}
this.eventLoopGroup = eventLoopGroup;
this.mana... | [
"public",
"EtcdNettyConfig",
"setEventLoopGroup",
"(",
"EventLoopGroup",
"eventLoopGroup",
",",
"boolean",
"managed",
")",
"{",
"if",
"(",
"this",
".",
"eventLoopGroup",
"!=",
"null",
"&&",
"this",
".",
"managedEventLoopGroup",
")",
"{",
"// if i manage it, close the ... | Set a custom event loop group. For use within existing netty architectures
@param eventLoopGroup eventLoopGroup to set.
@param managed whether event loop group will be closed when etcd client close, true represent yes
@return itself for chaining. | [
"Set",
"a",
"custom",
"event",
"loop",
"group",
".",
"For",
"use",
"within",
"existing",
"netty",
"architectures"
] | ffb1d574cf85bbab025dd566ce250f1860bbcbc7 | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/etcd4j/transport/EtcdNettyConfig.java#L99-L106 | train |
jurmous/etcd4j | src/main/java/mousio/client/util/SRV2URIs.java | SRV2URIs.fromDNSName | public static URI[] fromDNSName(String srvName) throws NamingException {
List<URI> uris = new ArrayList<>();
Hashtable<String, String> env = new Hashtable<>();
env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
env.put("java.naming.provider.url", "dns:");
DirContext ctx =... | java | public static URI[] fromDNSName(String srvName) throws NamingException {
List<URI> uris = new ArrayList<>();
Hashtable<String, String> env = new Hashtable<>();
env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");
env.put("java.naming.provider.url", "dns:");
DirContext ctx =... | [
"public",
"static",
"URI",
"[",
"]",
"fromDNSName",
"(",
"String",
"srvName",
")",
"throws",
"NamingException",
"{",
"List",
"<",
"URI",
">",
"uris",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Hashtable",
"<",
"String",
",",
"String",
">",
"env",
"... | Convert given DNS SRV address to array of URIs
@param srvName complete DNS name to resolve to URIs
@return Array of URIs
@throws NamingException if DNS name was invalid | [
"Convert",
"given",
"DNS",
"SRV",
"address",
"to",
"array",
"of",
"URIs"
] | ffb1d574cf85bbab025dd566ce250f1860bbcbc7 | https://github.com/jurmous/etcd4j/blob/ffb1d574cf85bbab025dd566ce250f1860bbcbc7/src/main/java/mousio/client/util/SRV2URIs.java#L53-L81 | train |
jalkanen/speed4j | src/main/java/com/ecyrd/speed4j/log/Slf4jLog.java | Slf4jLog.setSlf4jLogname | public void setSlf4jLogname(String logName)
{
// use length() == 0 instead of isEmpty() for Java 5 compatibility
if( logName.length() == 0 )
{
m_log = null;
}
else
{
m_log = LoggerFactory.getLogger(logName);
}
} | java | public void setSlf4jLogname(String logName)
{
// use length() == 0 instead of isEmpty() for Java 5 compatibility
if( logName.length() == 0 )
{
m_log = null;
}
else
{
m_log = LoggerFactory.getLogger(logName);
}
} | [
"public",
"void",
"setSlf4jLogname",
"(",
"String",
"logName",
")",
"{",
"// use length() == 0 instead of isEmpty() for Java 5 compatibility",
"if",
"(",
"logName",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"m_log",
"=",
"null",
";",
"}",
"else",
"{",
"m_log... | Set the name of the logger that this logger should log to.
If you set it to an empty string, will shut up completely. | [
"Set",
"the",
"name",
"of",
"the",
"logger",
"that",
"this",
"logger",
"should",
"log",
"to",
".",
"If",
"you",
"set",
"it",
"to",
"an",
"empty",
"string",
"will",
"shut",
"up",
"completely",
"."
] | 1d2db9c9b9def869c25fedb9bbd7cf95c39023bd | https://github.com/jalkanen/speed4j/blob/1d2db9c9b9def869c25fedb9bbd7cf95c39023bd/src/main/java/com/ecyrd/speed4j/log/Slf4jLog.java#L38-L49 | train |
jalkanen/speed4j | src/main/java/com/ecyrd/speed4j/log/Slf4jLog.java | Slf4jLog.log | @Override
public void log(StopWatch sw)
{
//
// This avoids calling the possibly expensive sw.toString() method if logging is disabled.
//
if( m_log != null && m_log.isInfoEnabled() )
{
m_log.info(sw.toString());
}
} | java | @Override
public void log(StopWatch sw)
{
//
// This avoids calling the possibly expensive sw.toString() method if logging is disabled.
//
if( m_log != null && m_log.isInfoEnabled() )
{
m_log.info(sw.toString());
}
} | [
"@",
"Override",
"public",
"void",
"log",
"(",
"StopWatch",
"sw",
")",
"{",
"//",
"// This avoids calling the possibly expensive sw.toString() method if logging is disabled.",
"//",
"if",
"(",
"m_log",
"!=",
"null",
"&&",
"m_log",
".",
"isInfoEnabled",
"(",
")",
")",... | Logs using the INFO priority. | [
"Logs",
"using",
"the",
"INFO",
"priority",
"."
] | 1d2db9c9b9def869c25fedb9bbd7cf95c39023bd | https://github.com/jalkanen/speed4j/blob/1d2db9c9b9def869c25fedb9bbd7cf95c39023bd/src/main/java/com/ecyrd/speed4j/log/Slf4jLog.java#L54-L64 | train |
jalkanen/speed4j | src/main/java/com/ecyrd/speed4j/log/PeriodicalLog.java | PeriodicalLog.log | @Override
public void log(StopWatch sw)
{
if( !m_queue.offer( sw.freeze() ) ) m_rejectedStopWatches.getAndIncrement();
if( m_collectorThread == null )
{
synchronized(this)
{
//
// Ensure that there is no race condition starting th... | java | @Override
public void log(StopWatch sw)
{
if( !m_queue.offer( sw.freeze() ) ) m_rejectedStopWatches.getAndIncrement();
if( m_collectorThread == null )
{
synchronized(this)
{
//
// Ensure that there is no race condition starting th... | [
"@",
"Override",
"public",
"void",
"log",
"(",
"StopWatch",
"sw",
")",
"{",
"if",
"(",
"!",
"m_queue",
".",
"offer",
"(",
"sw",
".",
"freeze",
"(",
")",
")",
")",
"m_rejectedStopWatches",
".",
"getAndIncrement",
"(",
")",
";",
"if",
"(",
"m_collectorTh... | This method also starts the collector thread lazily. | [
"This",
"method",
"also",
"starts",
"the",
"collector",
"thread",
"lazily",
"."
] | 1d2db9c9b9def869c25fedb9bbd7cf95c39023bd | https://github.com/jalkanen/speed4j/blob/1d2db9c9b9def869c25fedb9bbd7cf95c39023bd/src/main/java/com/ecyrd/speed4j/log/PeriodicalLog.java#L133-L158 | train |
jalkanen/speed4j | src/main/java/com/ecyrd/speed4j/log/PeriodicalLog.java | PeriodicalLog.rebuildJmx | private void rebuildJmx()
{
m_mbeanServer = ManagementFactory.getPlatformMBeanServer();
try
{
buildMBeanInfo();
//
// Remove and reinstall from the MBean registry if it already exists. Also
// remove previous instances.
//
... | java | private void rebuildJmx()
{
m_mbeanServer = ManagementFactory.getPlatformMBeanServer();
try
{
buildMBeanInfo();
//
// Remove and reinstall from the MBean registry if it already exists. Also
// remove previous instances.
//
... | [
"private",
"void",
"rebuildJmx",
"(",
")",
"{",
"m_mbeanServer",
"=",
"ManagementFactory",
".",
"getPlatformMBeanServer",
"(",
")",
";",
"try",
"{",
"buildMBeanInfo",
"(",
")",
";",
"//",
"// Remove and reinstall from the MBean registry if it already exists. Also",
"// ... | Rebuild the JMX bean. | [
"Rebuild",
"the",
"JMX",
"bean",
"."
] | 1d2db9c9b9def869c25fedb9bbd7cf95c39023bd | https://github.com/jalkanen/speed4j/blob/1d2db9c9b9def869c25fedb9bbd7cf95c39023bd/src/main/java/com/ecyrd/speed4j/log/PeriodicalLog.java#L279-L322 | train |
jalkanen/speed4j | src/main/java/com/ecyrd/speed4j/log/PeriodicalLog.java | PeriodicalLog.emptyQueue | private boolean emptyQueue(long finalMoment)
{
StopWatch sw;
try
{
while( null != (sw = m_queue.poll(100, TimeUnit.MILLISECONDS)) )
{
// Ignore faulty StopWatches
if( sw.getTag() == null ) continue;
if... | java | private boolean emptyQueue(long finalMoment)
{
StopWatch sw;
try
{
while( null != (sw = m_queue.poll(100, TimeUnit.MILLISECONDS)) )
{
// Ignore faulty StopWatches
if( sw.getTag() == null ) continue;
if... | [
"private",
"boolean",
"emptyQueue",
"(",
"long",
"finalMoment",
")",
"{",
"StopWatch",
"sw",
";",
"try",
"{",
"while",
"(",
"null",
"!=",
"(",
"sw",
"=",
"m_queue",
".",
"poll",
"(",
"100",
",",
"TimeUnit",
".",
"MILLISECONDS",
")",
")",
")",
"{",
"/... | Empties the StopWatch queue, and builds the statistics on the go.
This is run in the Collector Thread context. Leaves the queue
when the items in it start later than what we need.
@return true, if the queue is not emptied and there are events
in it where the finalMoment is achieved. | [
"Empties",
"the",
"StopWatch",
"queue",
"and",
"builds",
"the",
"statistics",
"on",
"the",
"go",
".",
"This",
"is",
"run",
"in",
"the",
"Collector",
"Thread",
"context",
".",
"Leaves",
"the",
"queue",
"when",
"the",
"items",
"in",
"it",
"start",
"later",
... | 1d2db9c9b9def869c25fedb9bbd7cf95c39023bd | https://github.com/jalkanen/speed4j/blob/1d2db9c9b9def869c25fedb9bbd7cf95c39023bd/src/main/java/com/ecyrd/speed4j/log/PeriodicalLog.java#L369-L422 | train |
jalkanen/speed4j | src/main/java/com/ecyrd/speed4j/StopWatchFactory.java | StopWatchFactory.configure | private static void configure()
{
String propertyFile = System.getProperty( SYSTEM_PROPERTY, PROPERTYFILENAME );
InputStream in = findConfigFile( propertyFile,
"/com/ecyrd/speed4j/default_speed4j.properties");
configure(in);
} | java | private static void configure()
{
String propertyFile = System.getProperty( SYSTEM_PROPERTY, PROPERTYFILENAME );
InputStream in = findConfigFile( propertyFile,
"/com/ecyrd/speed4j/default_speed4j.properties");
configure(in);
} | [
"private",
"static",
"void",
"configure",
"(",
")",
"{",
"String",
"propertyFile",
"=",
"System",
".",
"getProperty",
"(",
"SYSTEM_PROPERTY",
",",
"PROPERTYFILENAME",
")",
";",
"InputStream",
"in",
"=",
"findConfigFile",
"(",
"propertyFile",
",",
"\"/com/ecyrd/spe... | Does the default configuration by trying to locate the default
config file as defined in the System properties. | [
"Does",
"the",
"default",
"configuration",
"by",
"trying",
"to",
"locate",
"the",
"default",
"config",
"file",
"as",
"defined",
"in",
"the",
"System",
"properties",
"."
] | 1d2db9c9b9def869c25fedb9bbd7cf95c39023bd | https://github.com/jalkanen/speed4j/blob/1d2db9c9b9def869c25fedb9bbd7cf95c39023bd/src/main/java/com/ecyrd/speed4j/StopWatchFactory.java#L97-L105 | train |
jalkanen/speed4j | src/main/java/com/ecyrd/speed4j/StopWatchFactory.java | StopWatchFactory.configure | @SuppressWarnings( "unchecked" )
private static synchronized void configure(InputStream in) throws ConfigurationException
{
if( c_factories == null )
c_factories = new HashMap<String, StopWatchFactory>();
try
{
c_config.load(in);
}
catch (IOExcept... | java | @SuppressWarnings( "unchecked" )
private static synchronized void configure(InputStream in) throws ConfigurationException
{
if( c_factories == null )
c_factories = new HashMap<String, StopWatchFactory>();
try
{
c_config.load(in);
}
catch (IOExcept... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"static",
"synchronized",
"void",
"configure",
"(",
"InputStream",
"in",
")",
"throws",
"ConfigurationException",
"{",
"if",
"(",
"c_factories",
"==",
"null",
")",
"c_factories",
"=",
"new",
"HashMap",... | Load configuration file, try to parse it and do something useful.
@throws ConfigurationException If configuration fails. | [
"Load",
"configuration",
"file",
"try",
"to",
"parse",
"it",
"and",
"do",
"something",
"useful",
"."
] | 1d2db9c9b9def869c25fedb9bbd7cf95c39023bd | https://github.com/jalkanen/speed4j/blob/1d2db9c9b9def869c25fedb9bbd7cf95c39023bd/src/main/java/com/ecyrd/speed4j/StopWatchFactory.java#L112-L171 | train |
jalkanen/speed4j | src/main/java/com/ecyrd/speed4j/StopWatchFactory.java | StopWatchFactory.getStopWatch | public StopWatch getStopWatch( String tag, String message )
{
return new LoggingStopWatch( m_log, tag, message );
} | java | public StopWatch getStopWatch( String tag, String message )
{
return new LoggingStopWatch( m_log, tag, message );
} | [
"public",
"StopWatch",
"getStopWatch",
"(",
"String",
"tag",
",",
"String",
"message",
")",
"{",
"return",
"new",
"LoggingStopWatch",
"(",
"m_log",
",",
"tag",
",",
"message",
")",
";",
"}"
] | Returns a StopWatch for the given tag and given message.
@param tag Tag which identifies this StopWatch.
@param message A free-form message.
@return A new StopWatch. | [
"Returns",
"a",
"StopWatch",
"for",
"the",
"given",
"tag",
"and",
"given",
"message",
"."
] | 1d2db9c9b9def869c25fedb9bbd7cf95c39023bd | https://github.com/jalkanen/speed4j/blob/1d2db9c9b9def869c25fedb9bbd7cf95c39023bd/src/main/java/com/ecyrd/speed4j/StopWatchFactory.java#L247-L250 | train |
jalkanen/speed4j | src/main/java/com/ecyrd/speed4j/StopWatchFactory.java | StopWatchFactory.shutdown | public static synchronized void shutdown()
{
if( c_factories == null ) return; // Nothing to do
for( Iterator<Entry<String, StopWatchFactory>> i = c_factories.entrySet().iterator(); i.hasNext() ; )
{
Map.Entry<String,StopWatchFactory> e = i.next();
StopWatchFactory ... | java | public static synchronized void shutdown()
{
if( c_factories == null ) return; // Nothing to do
for( Iterator<Entry<String, StopWatchFactory>> i = c_factories.entrySet().iterator(); i.hasNext() ; )
{
Map.Entry<String,StopWatchFactory> e = i.next();
StopWatchFactory ... | [
"public",
"static",
"synchronized",
"void",
"shutdown",
"(",
")",
"{",
"if",
"(",
"c_factories",
"==",
"null",
")",
"return",
";",
"// Nothing to do",
"for",
"(",
"Iterator",
"<",
"Entry",
"<",
"String",
",",
"StopWatchFactory",
">",
">",
"i",
"=",
"c_fact... | Shut down all StopWatchFactories. This method is useful
to call to clean up any resources which might be usable. | [
"Shut",
"down",
"all",
"StopWatchFactories",
".",
"This",
"method",
"is",
"useful",
"to",
"call",
"to",
"clean",
"up",
"any",
"resources",
"which",
"might",
"be",
"usable",
"."
] | 1d2db9c9b9def869c25fedb9bbd7cf95c39023bd | https://github.com/jalkanen/speed4j/blob/1d2db9c9b9def869c25fedb9bbd7cf95c39023bd/src/main/java/com/ecyrd/speed4j/StopWatchFactory.java#L272-L287 | train |
jalkanen/speed4j | src/main/java/com/ecyrd/speed4j/StopWatchFactory.java | StopWatchFactory.getInstance | public static StopWatchFactory getInstance(String loggerName) throws ConfigurationException
{
StopWatchFactory swf = getFactories().get(loggerName);
if( swf == null ) throw new ConfigurationException("No logger by the name "+loggerName+" found.");
return swf;
} | java | public static StopWatchFactory getInstance(String loggerName) throws ConfigurationException
{
StopWatchFactory swf = getFactories().get(loggerName);
if( swf == null ) throw new ConfigurationException("No logger by the name "+loggerName+" found.");
return swf;
} | [
"public",
"static",
"StopWatchFactory",
"getInstance",
"(",
"String",
"loggerName",
")",
"throws",
"ConfigurationException",
"{",
"StopWatchFactory",
"swf",
"=",
"getFactories",
"(",
")",
".",
"get",
"(",
"loggerName",
")",
";",
"if",
"(",
"swf",
"==",
"null",
... | Returns a StopWatchFactory that has been configured previously. May return
null, if the factory has not been configured.
@param loggerName name to search for.
@return A factory, or null, if not found. | [
"Returns",
"a",
"StopWatchFactory",
"that",
"has",
"been",
"configured",
"previously",
".",
"May",
"return",
"null",
"if",
"the",
"factory",
"has",
"not",
"been",
"configured",
"."
] | 1d2db9c9b9def869c25fedb9bbd7cf95c39023bd | https://github.com/jalkanen/speed4j/blob/1d2db9c9b9def869c25fedb9bbd7cf95c39023bd/src/main/java/com/ecyrd/speed4j/StopWatchFactory.java#L315-L322 | train |
jalkanen/speed4j | src/main/java/com/ecyrd/speed4j/StopWatch.java | StopWatch.stop | public StopWatch stop( String tag, String message )
{
m_tag = tag;
m_message = message;
stop();
return this;
} | java | public StopWatch stop( String tag, String message )
{
m_tag = tag;
m_message = message;
stop();
return this;
} | [
"public",
"StopWatch",
"stop",
"(",
"String",
"tag",
",",
"String",
"message",
")",
"{",
"m_tag",
"=",
"tag",
";",
"m_message",
"=",
"message",
";",
"stop",
"(",
")",
";",
"return",
"this",
";",
"}"
] | Stops the StopWatch, assigns the tag and a free-form message.
@param tag The tag to assign.
@param message A free-form message that associates with this particular StopWatch.
@return This StopWatch. | [
"Stops",
"the",
"StopWatch",
"assigns",
"the",
"tag",
"and",
"a",
"free",
"-",
"form",
"message",
"."
] | 1d2db9c9b9def869c25fedb9bbd7cf95c39023bd | https://github.com/jalkanen/speed4j/blob/1d2db9c9b9def869c25fedb9bbd7cf95c39023bd/src/main/java/com/ecyrd/speed4j/StopWatch.java#L151-L158 | train |
jalkanen/speed4j | src/main/java/com/ecyrd/speed4j/StopWatch.java | StopWatch.getReadableTime | private String getReadableTime()
{
long ns = getTimeNanos();
if( ns < 50L * 1000 )
return ns + " ns";
if( ns < 50L * 1000 * 1000 )
return (ns/1000)+" us";
if( ns < 50L * 1000 * 1000 * 1000 )
return (ns/(1000*1000))+" ms";
return ns/NANO... | java | private String getReadableTime()
{
long ns = getTimeNanos();
if( ns < 50L * 1000 )
return ns + " ns";
if( ns < 50L * 1000 * 1000 )
return (ns/1000)+" us";
if( ns < 50L * 1000 * 1000 * 1000 )
return (ns/(1000*1000))+" ms";
return ns/NANO... | [
"private",
"String",
"getReadableTime",
"(",
")",
"{",
"long",
"ns",
"=",
"getTimeNanos",
"(",
")",
";",
"if",
"(",
"ns",
"<",
"50L",
"*",
"1000",
")",
"return",
"ns",
"+",
"\" ns\"",
";",
"if",
"(",
"ns",
"<",
"50L",
"*",
"1000",
"*",
"1000",
")... | Returns a the time in something that is human-readable.
@return A human-readable time string. | [
"Returns",
"a",
"the",
"time",
"in",
"something",
"that",
"is",
"human",
"-",
"readable",
"."
] | 1d2db9c9b9def869c25fedb9bbd7cf95c39023bd | https://github.com/jalkanen/speed4j/blob/1d2db9c9b9def869c25fedb9bbd7cf95c39023bd/src/main/java/com/ecyrd/speed4j/StopWatch.java#L329-L343 | train |
jalkanen/speed4j | src/main/java/com/ecyrd/speed4j/log/CollectedStatistics.java | CollectedStatistics.add | public synchronized void add(StopWatch sw)
{
double timeInMs = sw.getTimeMicros() / MICROS_IN_MILLIS;
// let fake the array
for ( int i=0; i < sw.getCount() ; i++ )
m_times.add(timeInMs / sw.getCount());
if( timeInMs < m_min ) m_min = timeInMs;
if( timeInMs > m_ma... | java | public synchronized void add(StopWatch sw)
{
double timeInMs = sw.getTimeMicros() / MICROS_IN_MILLIS;
// let fake the array
for ( int i=0; i < sw.getCount() ; i++ )
m_times.add(timeInMs / sw.getCount());
if( timeInMs < m_min ) m_min = timeInMs;
if( timeInMs > m_ma... | [
"public",
"synchronized",
"void",
"add",
"(",
"StopWatch",
"sw",
")",
"{",
"double",
"timeInMs",
"=",
"sw",
".",
"getTimeMicros",
"(",
")",
"/",
"MICROS_IN_MILLIS",
";",
"// let fake the array",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"sw",
".",... | Add a StopWatch to the statistics.
@param sw StopWatch to add. | [
"Add",
"a",
"StopWatch",
"to",
"the",
"statistics",
"."
] | 1d2db9c9b9def869c25fedb9bbd7cf95c39023bd | https://github.com/jalkanen/speed4j/blob/1d2db9c9b9def869c25fedb9bbd7cf95c39023bd/src/main/java/com/ecyrd/speed4j/log/CollectedStatistics.java#L42-L50 | train |
Afrozaar/wp-api-v2-client-java | src/main/java/com/afrozaar/wordpress/wpapi/v2/model/builder/PostBuilder.java | PostBuilder.withCategories | public PostBuilder withCategories(Term... terms) {
return withCategories(Arrays.stream(terms).map(Term::getId).collect(toList()));
} | java | public PostBuilder withCategories(Term... terms) {
return withCategories(Arrays.stream(terms).map(Term::getId).collect(toList()));
} | [
"public",
"PostBuilder",
"withCategories",
"(",
"Term",
"...",
"terms",
")",
"{",
"return",
"withCategories",
"(",
"Arrays",
".",
"stream",
"(",
"terms",
")",
".",
"map",
"(",
"Term",
"::",
"getId",
")",
".",
"collect",
"(",
"toList",
"(",
")",
")",
")... | Add existing Category term items when building a post. | [
"Add",
"existing",
"Category",
"term",
"items",
"when",
"building",
"a",
"post",
"."
] | f654c989a9edea5d1a28b7102f83bffc55eaf477 | https://github.com/Afrozaar/wp-api-v2-client-java/blob/f654c989a9edea5d1a28b7102f83bffc55eaf477/src/main/java/com/afrozaar/wordpress/wpapi/v2/model/builder/PostBuilder.java#L151-L153 | train |
Afrozaar/wp-api-v2-client-java | src/main/java/com/afrozaar/wordpress/wpapi/v2/model/builder/PostBuilder.java | PostBuilder.withTags | public PostBuilder withTags(Term... tags) {
return withTags(Arrays.stream(tags).map(Term::getId).collect(toList()));
} | java | public PostBuilder withTags(Term... tags) {
return withTags(Arrays.stream(tags).map(Term::getId).collect(toList()));
} | [
"public",
"PostBuilder",
"withTags",
"(",
"Term",
"...",
"tags",
")",
"{",
"return",
"withTags",
"(",
"Arrays",
".",
"stream",
"(",
"tags",
")",
".",
"map",
"(",
"Term",
"::",
"getId",
")",
".",
"collect",
"(",
"toList",
"(",
")",
")",
")",
";",
"}... | Add existing Tag term items when building a post. | [
"Add",
"existing",
"Tag",
"term",
"items",
"when",
"building",
"a",
"post",
"."
] | f654c989a9edea5d1a28b7102f83bffc55eaf477 | https://github.com/Afrozaar/wp-api-v2-client-java/blob/f654c989a9edea5d1a28b7102f83bffc55eaf477/src/main/java/com/afrozaar/wordpress/wpapi/v2/model/builder/PostBuilder.java#L158-L160 | train |
JadiraOrg/jadira | cdt/src/main/java/org/jadira/cdt/phonenumber/impl/E164PhoneNumberWithExtension.java | E164PhoneNumberWithExtension.ofPhoneNumberStringAndExtension | public static E164PhoneNumberWithExtension ofPhoneNumberStringAndExtension(String phoneNumber, String extension, CountryCode defaultCountryCode) {
return new E164PhoneNumberWithExtension(phoneNumber, extension, defaultCountryCode);
} | java | public static E164PhoneNumberWithExtension ofPhoneNumberStringAndExtension(String phoneNumber, String extension, CountryCode defaultCountryCode) {
return new E164PhoneNumberWithExtension(phoneNumber, extension, defaultCountryCode);
} | [
"public",
"static",
"E164PhoneNumberWithExtension",
"ofPhoneNumberStringAndExtension",
"(",
"String",
"phoneNumber",
",",
"String",
"extension",
",",
"CountryCode",
"defaultCountryCode",
")",
"{",
"return",
"new",
"E164PhoneNumberWithExtension",
"(",
"phoneNumber",
",",
"ex... | Creates a new E164 Phone Number with the given extension.
@param phoneNumber The phone number in arbitrary parseable format (may be a national format)
@param extension The extension, or null for no extension
@param defaultCountryCode The Country to apply if no country is indicated by the phone number
@return A new inst... | [
"Creates",
"a",
"new",
"E164",
"Phone",
"Number",
"with",
"the",
"given",
"extension",
"."
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cdt/src/main/java/org/jadira/cdt/phonenumber/impl/E164PhoneNumberWithExtension.java#L212-L214 | train |
JadiraOrg/jadira | cloning/src/main/java/org/jadira/reflection/access/model/FieldModel.java | FieldModel.get | @SuppressWarnings("unchecked")
public static final <C> FieldModel<C> get(Field f, FieldAccess<C> fieldAccess) {
String fieldModelKey = (fieldAccess.getClass().getSimpleName() + ":" + f.getClass().getName() + "#" + f.getName());
FieldModel<C> fieldModel = (FieldModel<C>)fieldModels.get(fieldModelKey);
if ... | java | @SuppressWarnings("unchecked")
public static final <C> FieldModel<C> get(Field f, FieldAccess<C> fieldAccess) {
String fieldModelKey = (fieldAccess.getClass().getSimpleName() + ":" + f.getClass().getName() + "#" + f.getName());
FieldModel<C> fieldModel = (FieldModel<C>)fieldModels.get(fieldModelKey);
if ... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"final",
"<",
"C",
">",
"FieldModel",
"<",
"C",
">",
"get",
"(",
"Field",
"f",
",",
"FieldAccess",
"<",
"C",
">",
"fieldAccess",
")",
"{",
"String",
"fieldModelKey",
"=",
"(",
"field... | Returns a field model for the given Field and FieldAccess instance. If a FieldModel
already exists, it will be reused.
@param f The Field
@param fieldAccess The Field Access that can be used to introspect the field
@param <C> The type of class being accessed
@return The Field Model | [
"Returns",
"a",
"field",
"model",
"for",
"the",
"given",
"Field",
"and",
"FieldAccess",
"instance",
".",
"If",
"a",
"FieldModel",
"already",
"exists",
"it",
"will",
"be",
"reused",
"."
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cloning/src/main/java/org/jadira/reflection/access/model/FieldModel.java#L77-L97 | train |
JadiraOrg/jadira | cloning/src/main/java/org/jadira/reflection/cloning/mutability/MutabilityDetector.java | MutabilityDetector.isImmutable | public boolean isImmutable(Class<?> clazz) {
if (clazz.isPrimitive() || clazz.isEnum()) {
return false;
}
if (clazz.isArray()) {
return false;
}
final IsImmutable isImmutable;
if (DETECTED_IMMUTABLE_CLASSES.containsKey(clazz)) {
... | java | public boolean isImmutable(Class<?> clazz) {
if (clazz.isPrimitive() || clazz.isEnum()) {
return false;
}
if (clazz.isArray()) {
return false;
}
final IsImmutable isImmutable;
if (DETECTED_IMMUTABLE_CLASSES.containsKey(clazz)) {
... | [
"public",
"boolean",
"isImmutable",
"(",
"Class",
"<",
"?",
">",
"clazz",
")",
"{",
"if",
"(",
"clazz",
".",
"isPrimitive",
"(",
")",
"||",
"clazz",
".",
"isEnum",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"clazz",
".",
"isArray",... | Return true if immutable or effectively immutable
@param clazz Class under test
@return True if immutable or effectively immutable | [
"Return",
"true",
"if",
"immutable",
"or",
"effectively",
"immutable"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cloning/src/main/java/org/jadira/reflection/cloning/mutability/MutabilityDetector.java#L60-L83 | train |
JadiraOrg/jadira | bindings/src/main/java/org/jadira/bindings/core/utils/lang/IterableEnumeration.java | IterableEnumeration.wrapEnumeration | public static <E> Iterable<E> wrapEnumeration(Enumeration<E> enumeration) {
return new IterableEnumeration<E>(enumeration);
} | java | public static <E> Iterable<E> wrapEnumeration(Enumeration<E> enumeration) {
return new IterableEnumeration<E>(enumeration);
} | [
"public",
"static",
"<",
"E",
">",
"Iterable",
"<",
"E",
">",
"wrapEnumeration",
"(",
"Enumeration",
"<",
"E",
">",
"enumeration",
")",
"{",
"return",
"new",
"IterableEnumeration",
"<",
"E",
">",
"(",
"enumeration",
")",
";",
"}"
] | Typesafe factory method for construction convenience
@param enumeration The enumeration to be wrapped with type-arg of E
@param <E> Type-arg for the relevant enumeration
@return An Iterable instance for subject type, E | [
"Typesafe",
"factory",
"method",
"for",
"construction",
"convenience"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/bindings/src/main/java/org/jadira/bindings/core/utils/lang/IterableEnumeration.java#L64-L66 | train |
JadiraOrg/jadira | bindings/src/main/java/org/jadira/bindings/core/loader/BindingXmlLoader.java | BindingXmlLoader.load | public static BindingConfiguration load(URL location) throws IllegalStateException {
Document doc;
try {
doc = loadDocument(location);
} catch (IOException e) {
throw new IllegalStateException("Cannot load " + location.toExternalForm(), e);
} catch (P... | java | public static BindingConfiguration load(URL location) throws IllegalStateException {
Document doc;
try {
doc = loadDocument(location);
} catch (IOException e) {
throw new IllegalStateException("Cannot load " + location.toExternalForm(), e);
} catch (P... | [
"public",
"static",
"BindingConfiguration",
"load",
"(",
"URL",
"location",
")",
"throws",
"IllegalStateException",
"{",
"Document",
"doc",
";",
"try",
"{",
"doc",
"=",
"loadDocument",
"(",
"location",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{... | Given a configuration URL, produce the corresponding configuration
@param location The URL
@return The relevant {@link BindingConfiguration}
@throws IllegalStateException If the configuration cannot be parsed | [
"Given",
"a",
"configuration",
"URL",
"produce",
"the",
"corresponding",
"configuration"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/bindings/src/main/java/org/jadira/bindings/core/loader/BindingXmlLoader.java#L63-L77 | train |
JadiraOrg/jadira | bindings/src/main/java/org/jadira/bindings/core/loader/BindingXmlLoader.java | BindingXmlLoader.loadDocument | private static Document loadDocument(URL location) throws IOException, ParserConfigurationException, SAXException {
InputStream inputStream = null;
if (location != null) {
URLConnection urlConnection = location.openConnection();
urlConnection.setUseCaches(false);
... | java | private static Document loadDocument(URL location) throws IOException, ParserConfigurationException, SAXException {
InputStream inputStream = null;
if (location != null) {
URLConnection urlConnection = location.openConnection();
urlConnection.setUseCaches(false);
... | [
"private",
"static",
"Document",
"loadDocument",
"(",
"URL",
"location",
")",
"throws",
"IOException",
",",
"ParserConfigurationException",
",",
"SAXException",
"{",
"InputStream",
"inputStream",
"=",
"null",
";",
"if",
"(",
"location",
"!=",
"null",
")",
"{",
"... | Helper method to load a DOM Document from the given configuration URL
@param location The configuration URL
@return A W3C DOM Document
@throws IOException If the configuration cannot be read
@throws ParserConfigurationException If the DOM Parser cannot be initialised
@throws SAXException If the configuraiton cannot be ... | [
"Helper",
"method",
"to",
"load",
"a",
"DOM",
"Document",
"from",
"the",
"given",
"configuration",
"URL"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/bindings/src/main/java/org/jadira/bindings/core/loader/BindingXmlLoader.java#L87-L118 | train |
JadiraOrg/jadira | bindings/src/main/java/org/jadira/bindings/core/loader/BindingXmlLoader.java | BindingXmlLoader.constructDocumentBuilder | private static DocumentBuilder constructDocumentBuilder(List<SAXParseException> errors)
throws ParserConfigurationException {
DocumentBuilderFactory documentBuilderFactory = constructDocumentBuilderFactory();
DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
... | java | private static DocumentBuilder constructDocumentBuilder(List<SAXParseException> errors)
throws ParserConfigurationException {
DocumentBuilderFactory documentBuilderFactory = constructDocumentBuilderFactory();
DocumentBuilder docBuilder = documentBuilderFactory.newDocumentBuilder();
... | [
"private",
"static",
"DocumentBuilder",
"constructDocumentBuilder",
"(",
"List",
"<",
"SAXParseException",
">",
"errors",
")",
"throws",
"ParserConfigurationException",
"{",
"DocumentBuilderFactory",
"documentBuilderFactory",
"=",
"constructDocumentBuilderFactory",
"(",
")",
... | Helper used to construct a document builder
@param errors A list for holding any errors that take place
@return JAXP {@link DocumentBuilder}
@throws ParserConfigurationException If the parser cannot be initialised | [
"Helper",
"used",
"to",
"construct",
"a",
"document",
"builder"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/bindings/src/main/java/org/jadira/bindings/core/loader/BindingXmlLoader.java#L126-L134 | train |
JadiraOrg/jadira | bindings/src/main/java/org/jadira/bindings/core/loader/BindingXmlLoader.java | BindingXmlLoader.parseProviderElement | private static Provider parseProviderElement(Element element) {
Class<?> providerClass = lookupClass(element.getAttribute("class"));
if (providerClass == null) {
throw new IllegalStateException("Referenced class {" + element.getAttribute("class")
+ "} could not be... | java | private static Provider parseProviderElement(Element element) {
Class<?> providerClass = lookupClass(element.getAttribute("class"));
if (providerClass == null) {
throw new IllegalStateException("Referenced class {" + element.getAttribute("class")
+ "} could not be... | [
"private",
"static",
"Provider",
"parseProviderElement",
"(",
"Element",
"element",
")",
"{",
"Class",
"<",
"?",
">",
"providerClass",
"=",
"lookupClass",
"(",
"element",
".",
"getAttribute",
"(",
"\"class\"",
")",
")",
";",
"if",
"(",
"providerClass",
"==",
... | Parse the 'provider' element and its children
@param element The element
@return A {@link Provider} instance for the element | [
"Parse",
"the",
"provider",
"element",
"and",
"its",
"children"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/bindings/src/main/java/org/jadira/bindings/core/loader/BindingXmlLoader.java#L203-L219 | train |
JadiraOrg/jadira | bindings/src/main/java/org/jadira/bindings/core/loader/BindingXmlLoader.java | BindingXmlLoader.parseBinderExtensionElement | private static <T> Extension<T> parseBinderExtensionElement(Element element) {
@SuppressWarnings("unchecked")
Class<T> providerClass = (Class<T>)lookupClass(element.getAttribute("class"));
Class<?> implementationClass = lookupClass(element.getAttribute("implementationClass"));
... | java | private static <T> Extension<T> parseBinderExtensionElement(Element element) {
@SuppressWarnings("unchecked")
Class<T> providerClass = (Class<T>)lookupClass(element.getAttribute("class"));
Class<?> implementationClass = lookupClass(element.getAttribute("implementationClass"));
... | [
"private",
"static",
"<",
"T",
">",
"Extension",
"<",
"T",
">",
"parseBinderExtensionElement",
"(",
"Element",
"element",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Class",
"<",
"T",
">",
"providerClass",
"=",
"(",
"Class",
"<",
"T",
">... | Parse the 'extension' element
@param element The element
@return A {@link Extension} instance for the element | [
"Parse",
"the",
"extension",
"element"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/bindings/src/main/java/org/jadira/bindings/core/loader/BindingXmlLoader.java#L226-L257 | train |
JadiraOrg/jadira | bindings/src/main/java/org/jadira/bindings/core/loader/BindingXmlLoader.java | BindingXmlLoader.lookupClass | private static Class<?> lookupClass(String elementName) {
Class<?> clazz = null;
try {
clazz = ClassLoaderUtils.getClassLoader().loadClass(elementName);
} catch (ClassNotFoundException e) {
return null;
}
return clazz;
} | java | private static Class<?> lookupClass(String elementName) {
Class<?> clazz = null;
try {
clazz = ClassLoaderUtils.getClassLoader().loadClass(elementName);
} catch (ClassNotFoundException e) {
return null;
}
return clazz;
} | [
"private",
"static",
"Class",
"<",
"?",
">",
"lookupClass",
"(",
"String",
"elementName",
")",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"null",
";",
"try",
"{",
"clazz",
"=",
"ClassLoaderUtils",
".",
"getClassLoader",
"(",
")",
".",
"loadClass",
"(",
... | Helper method that given a class-name will create the appropriate Class instance
@param elementName The class name
@return Instance of Class | [
"Helper",
"method",
"that",
"given",
"a",
"class",
"-",
"name",
"will",
"create",
"the",
"appropriate",
"Class",
"instance"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/bindings/src/main/java/org/jadira/bindings/core/loader/BindingXmlLoader.java#L398-L408 | train |
JadiraOrg/jadira | bindings/src/main/java/org/jadira/bindings/core/spring/BindingConverter.java | BindingConverter.matchAnnotationToScope | private <T> Class<? extends Annotation> matchAnnotationToScope(Annotation[] annotations) {
for (Annotation next : annotations) {
Class<? extends Annotation> nextType = next.annotationType();
if (nextType.getAnnotation(BindingScope.class) != null) {
return nextType;
... | java | private <T> Class<? extends Annotation> matchAnnotationToScope(Annotation[] annotations) {
for (Annotation next : annotations) {
Class<? extends Annotation> nextType = next.annotationType();
if (nextType.getAnnotation(BindingScope.class) != null) {
return nextType;
... | [
"private",
"<",
"T",
">",
"Class",
"<",
"?",
"extends",
"Annotation",
">",
"matchAnnotationToScope",
"(",
"Annotation",
"[",
"]",
"annotations",
")",
"{",
"for",
"(",
"Annotation",
"next",
":",
"annotations",
")",
"{",
"Class",
"<",
"?",
"extends",
"Annota... | Helper method for matching and returning a scope annotation
@param annotations Annotations to inspect for a scope annotation
@return The matched annotation | [
"Helper",
"method",
"for",
"matching",
"and",
"returning",
"a",
"scope",
"annotation"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/bindings/src/main/java/org/jadira/bindings/core/spring/BindingConverter.java#L82-L91 | train |
JadiraOrg/jadira | cdt/src/main/java/org/jadira/cdt/exception/WrappedRuntimeException.java | WrappedRuntimeException.constructMessage | protected String constructMessage(String message, Throwable cause) {
if (cause != null) {
StringBuilder strBuilder = new StringBuilder();
if (message != null) {
strBuilder.append(message).append(": ");
}
strBuilder.append("Wrapped exception is {").append(cause);
strBuilder.append("}")... | java | protected String constructMessage(String message, Throwable cause) {
if (cause != null) {
StringBuilder strBuilder = new StringBuilder();
if (message != null) {
strBuilder.append(message).append(": ");
}
strBuilder.append("Wrapped exception is {").append(cause);
strBuilder.append("}")... | [
"protected",
"String",
"constructMessage",
"(",
"String",
"message",
",",
"Throwable",
"cause",
")",
"{",
"if",
"(",
"cause",
"!=",
"null",
")",
"{",
"StringBuilder",
"strBuilder",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"message",
"!=",
"nu... | Constructs an exception String with the given message and incorporating the
causing exception
@param message The message
@param cause The causing exception
@return The exception String | [
"Constructs",
"an",
"exception",
"String",
"with",
"the",
"given",
"message",
"and",
"incorporating",
"the",
"causing",
"exception"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cdt/src/main/java/org/jadira/cdt/exception/WrappedRuntimeException.java#L61-L79 | train |
JadiraOrg/jadira | cdt/src/main/java/org/jadira/cdt/exception/WrappedRuntimeException.java | WrappedRuntimeException.getRootCause | public Throwable getRootCause() {
Throwable rootCause = null;
Throwable nextCause = getCause();
while (nextCause != null && !nextCause.equals(rootCause)) {
rootCause = nextCause;
nextCause = nextCause.getCause();
}
return rootCause;
} | java | public Throwable getRootCause() {
Throwable rootCause = null;
Throwable nextCause = getCause();
while (nextCause != null && !nextCause.equals(rootCause)) {
rootCause = nextCause;
nextCause = nextCause.getCause();
}
return rootCause;
} | [
"public",
"Throwable",
"getRootCause",
"(",
")",
"{",
"Throwable",
"rootCause",
"=",
"null",
";",
"Throwable",
"nextCause",
"=",
"getCause",
"(",
")",
";",
"while",
"(",
"nextCause",
"!=",
"null",
"&&",
"!",
"nextCause",
".",
"equals",
"(",
"rootCause",
")... | Retrieves the ultimate root cause for this exception, or null
@return The root cause | [
"Retrieves",
"the",
"ultimate",
"root",
"cause",
"for",
"this",
"exception",
"or",
"null"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cdt/src/main/java/org/jadira/cdt/exception/WrappedRuntimeException.java#L85-L96 | train |
JadiraOrg/jadira | cdt/src/main/java/org/jadira/cdt/exception/WrappedRuntimeException.java | WrappedRuntimeException.findWrapped | public <E extends Exception> E findWrapped(Class<E> exceptionType) {
if (exceptionType == null) {
return null;
}
Throwable cause = getCause();
while (true) {
if (cause == null) {
return null;
}
if (exceptionType.isInstance(cause)) {
@SuppressWarnings("unchecked") E matc... | java | public <E extends Exception> E findWrapped(Class<E> exceptionType) {
if (exceptionType == null) {
return null;
}
Throwable cause = getCause();
while (true) {
if (cause == null) {
return null;
}
if (exceptionType.isInstance(cause)) {
@SuppressWarnings("unchecked") E matc... | [
"public",
"<",
"E",
"extends",
"Exception",
">",
"E",
"findWrapped",
"(",
"Class",
"<",
"E",
">",
"exceptionType",
")",
"{",
"if",
"(",
"exceptionType",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Throwable",
"cause",
"=",
"getCause",
"(",
")"... | Returns the next parent exception of the given type, or null
@param exceptionType the exception type to match
@param <E> The exception type
@return The matched exception of the target type, or null | [
"Returns",
"the",
"next",
"parent",
"exception",
"of",
"the",
"given",
"type",
"or",
"null"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cdt/src/main/java/org/jadira/cdt/exception/WrappedRuntimeException.java#L104-L137 | train |
JadiraOrg/jadira | usertype.spi/src/main/java/org/jadira/usertype/spi/shared/AbstractUserType.java | AbstractUserType.beforeNullSafeOperation | public void beforeNullSafeOperation(SharedSessionContractImplementor session) {
ConfigurationHelper.setCurrentSessionFactory(session.getFactory());
if (this instanceof IntegratorConfiguredType) {
((IntegratorConfiguredType)this).applyConfiguration(session.getFactory());
}
} | java | public void beforeNullSafeOperation(SharedSessionContractImplementor session) {
ConfigurationHelper.setCurrentSessionFactory(session.getFactory());
if (this instanceof IntegratorConfiguredType) {
((IntegratorConfiguredType)this).applyConfiguration(session.getFactory());
}
} | [
"public",
"void",
"beforeNullSafeOperation",
"(",
"SharedSessionContractImplementor",
"session",
")",
"{",
"ConfigurationHelper",
".",
"setCurrentSessionFactory",
"(",
"session",
".",
"getFactory",
"(",
")",
")",
";",
"if",
"(",
"this",
"instanceof",
"IntegratorConfigur... | Included to allow session state to be applied to the user type
@param session The session | [
"Included",
"to",
"allow",
"session",
"state",
"to",
"be",
"applied",
"to",
"the",
"user",
"type"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/usertype.spi/src/main/java/org/jadira/usertype/spi/shared/AbstractUserType.java#L83-L89 | train |
JadiraOrg/jadira | bindings/src/main/java/org/jadira/bindings/core/binder/BasicBinder.java | BasicBinder.initJdkBindings | private void initJdkBindings() {
registerBinding(AtomicBoolean.class, String.class, new AtomicBooleanStringBinding());
registerBinding(AtomicInteger.class, String.class, new AtomicIntegerStringBinding());
registerBinding(AtomicLong.class, String.class, new AtomicLongStringBinding())... | java | private void initJdkBindings() {
registerBinding(AtomicBoolean.class, String.class, new AtomicBooleanStringBinding());
registerBinding(AtomicInteger.class, String.class, new AtomicIntegerStringBinding());
registerBinding(AtomicLong.class, String.class, new AtomicLongStringBinding())... | [
"private",
"void",
"initJdkBindings",
"(",
")",
"{",
"registerBinding",
"(",
"AtomicBoolean",
".",
"class",
",",
"String",
".",
"class",
",",
"new",
"AtomicBooleanStringBinding",
"(",
")",
")",
";",
"registerBinding",
"(",
"AtomicInteger",
".",
"class",
",",
"... | Initialises standard bindings for Java built in types | [
"Initialises",
"standard",
"bindings",
"for",
"Java",
"built",
"in",
"types"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/bindings/src/main/java/org/jadira/bindings/core/binder/BasicBinder.java#L183-L214 | train |
JadiraOrg/jadira | bindings/src/main/java/org/jadira/bindings/core/binder/BasicBinder.java | BasicBinder.registerConfigurations | protected <X> void registerConfigurations(Enumeration<URL> bindingsConfiguration) {
List<BindingConfiguration> configs = new ArrayList<BindingConfiguration>();
for (URL nextLocation : IterableEnumeration.wrapEnumeration(bindingsConfiguration)) {
// Filter built in bindings - th... | java | protected <X> void registerConfigurations(Enumeration<URL> bindingsConfiguration) {
List<BindingConfiguration> configs = new ArrayList<BindingConfiguration>();
for (URL nextLocation : IterableEnumeration.wrapEnumeration(bindingsConfiguration)) {
// Filter built in bindings - th... | [
"protected",
"<",
"X",
">",
"void",
"registerConfigurations",
"(",
"Enumeration",
"<",
"URL",
">",
"bindingsConfiguration",
")",
"{",
"List",
"<",
"BindingConfiguration",
">",
"configs",
"=",
"new",
"ArrayList",
"<",
"BindingConfiguration",
">",
"(",
")",
";",
... | Registers a set of configurations for the given list of URLs.
This is typically used to process all the various bindings.xml files discovered in
jars on the classpath. It is given protected scope to allow subclasses to register
additional configurations
@param bindingsConfiguration An enumeration of the URLs to process... | [
"Registers",
"a",
"set",
"of",
"configurations",
"for",
"the",
"given",
"list",
"of",
"URLs",
".",
"This",
"is",
"typically",
"used",
"to",
"process",
"all",
"the",
"various",
"bindings",
".",
"xml",
"files",
"discovered",
"in",
"jars",
"on",
"the",
"class... | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/bindings/src/main/java/org/jadira/bindings/core/binder/BasicBinder.java#L267-L304 | train |
JadiraOrg/jadira | bindings/src/main/java/org/jadira/bindings/core/binder/BasicBinder.java | BasicBinder.registerBindingConfigurationEntries | protected void registerBindingConfigurationEntries(Iterable<BindingConfigurationEntry> bindings) {
for (BindingConfigurationEntry nextBinding : bindings) {
try {
registerBindingConfigurationEntry(nextBinding);
} catch (IllegalStateException e) {
// Ignore this - it c... | java | protected void registerBindingConfigurationEntries(Iterable<BindingConfigurationEntry> bindings) {
for (BindingConfigurationEntry nextBinding : bindings) {
try {
registerBindingConfigurationEntry(nextBinding);
} catch (IllegalStateException e) {
// Ignore this - it c... | [
"protected",
"void",
"registerBindingConfigurationEntries",
"(",
"Iterable",
"<",
"BindingConfigurationEntry",
">",
"bindings",
")",
"{",
"for",
"(",
"BindingConfigurationEntry",
"nextBinding",
":",
"bindings",
")",
"{",
"try",
"{",
"registerBindingConfigurationEntry",
"(... | Registers a list of binding configuration entries. A binding configuration entry described in a section of a bindings.xml file
and describes the use of a particular method for databinding.
@param bindings The entries to register | [
"Registers",
"a",
"list",
"of",
"binding",
"configuration",
"entries",
".",
"A",
"binding",
"configuration",
"entry",
"described",
"in",
"a",
"section",
"of",
"a",
"bindings",
".",
"xml",
"file",
"and",
"describes",
"the",
"use",
"of",
"a",
"particular",
"me... | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/bindings/src/main/java/org/jadira/bindings/core/binder/BasicBinder.java#L353-L362 | train |
JadiraOrg/jadira | bindings/src/main/java/org/jadira/bindings/core/binder/BasicBinder.java | BasicBinder.registerAnnotatedClasses | public void registerAnnotatedClasses(Class<?>... classesToInspect) {
for (Class<?> nextClass : classesToInspect) {
Class<?> loopClass = nextClass;
while ((loopClass != Object.class) && (!inspectedClasses.contains(loopClass))) {
attachForAnnotations(loopClass);
loopClass = loopClass.g... | java | public void registerAnnotatedClasses(Class<?>... classesToInspect) {
for (Class<?> nextClass : classesToInspect) {
Class<?> loopClass = nextClass;
while ((loopClass != Object.class) && (!inspectedClasses.contains(loopClass))) {
attachForAnnotations(loopClass);
loopClass = loopClass.g... | [
"public",
"void",
"registerAnnotatedClasses",
"(",
"Class",
"<",
"?",
">",
"...",
"classesToInspect",
")",
"{",
"for",
"(",
"Class",
"<",
"?",
">",
"nextClass",
":",
"classesToInspect",
")",
"{",
"Class",
"<",
"?",
">",
"loopClass",
"=",
"nextClass",
";",
... | Inspect each of the supplied classes, processing any of the annotated methods found
@param classesToInspect The classes to inspect for annotations | [
"Inspect",
"each",
"of",
"the",
"supplied",
"classes",
"processing",
"any",
"of",
"the",
"annotated",
"methods",
"found"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/bindings/src/main/java/org/jadira/bindings/core/binder/BasicBinder.java#L486-L498 | train |
JadiraOrg/jadira | bindings/src/main/java/org/jadira/bindings/core/binder/BasicBinder.java | BasicBinder.registerExtendedBinder | protected <I, T extends I> void registerExtendedBinder(Class<I> iface, T provider) {
extendedBinders.put(iface, provider);
} | java | protected <I, T extends I> void registerExtendedBinder(Class<I> iface, T provider) {
extendedBinders.put(iface, provider);
} | [
"protected",
"<",
"I",
",",
"T",
"extends",
"I",
">",
"void",
"registerExtendedBinder",
"(",
"Class",
"<",
"I",
">",
"iface",
",",
"T",
"provider",
")",
"{",
"extendedBinders",
".",
"put",
"(",
"iface",
",",
"provider",
")",
";",
"}"
] | Register a custom, typesafe binder implementation which can be retrieved later
@param iface The interface for the provider to be registered.
@param provider The implementation.
@param <I> The class to be registered
@param <T> Implementation of the binder type, I. | [
"Register",
"a",
"custom",
"typesafe",
"binder",
"implementation",
"which",
"can",
"be",
"retrieved",
"later"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/bindings/src/main/java/org/jadira/bindings/core/binder/BasicBinder.java#L513-L515 | train |
JadiraOrg/jadira | bindings/src/main/java/org/jadira/bindings/core/binder/BasicBinder.java | BasicBinder.getExtendedBinder | @SuppressWarnings("unchecked")
protected <I> I getExtendedBinder(Class<I> cls) {
return (I) extendedBinders.get(cls);
} | java | @SuppressWarnings("unchecked")
protected <I> I getExtendedBinder(Class<I> cls) {
return (I) extendedBinders.get(cls);
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"protected",
"<",
"I",
">",
"I",
"getExtendedBinder",
"(",
"Class",
"<",
"I",
">",
"cls",
")",
"{",
"return",
"(",
"I",
")",
"extendedBinders",
".",
"get",
"(",
"cls",
")",
";",
"}"
] | Retrieves an extended binder
@param cls The implementation.
@param <I> Interface type for the extended binder
@return The found extended binder | [
"Retrieves",
"an",
"extended",
"binder"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/bindings/src/main/java/org/jadira/bindings/core/binder/BasicBinder.java#L523-L526 | train |
JadiraOrg/jadira | cloning/src/main/java/org/jadira/reflection/core/misc/ClassUtils.java | ClassUtils.isJdkImmutable | public static boolean isJdkImmutable(Class<?> type) {
if (Class.class == type) {
return true;
}
if (String.class == type) {
return true;
}
if (BigInteger.class == type) {
return true;
}
if (BigDecimal.class == type) {
r... | java | public static boolean isJdkImmutable(Class<?> type) {
if (Class.class == type) {
return true;
}
if (String.class == type) {
return true;
}
if (BigInteger.class == type) {
return true;
}
if (BigDecimal.class == type) {
r... | [
"public",
"static",
"boolean",
"isJdkImmutable",
"(",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"if",
"(",
"Class",
".",
"class",
"==",
"type",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"String",
".",
"class",
"==",
"type",
")",
"{",
"return... | Indicate if the class is a known non-primitive, JDK immutable type
@param type Class to test
@return True if the type is an immutable from the JDK class libraries | [
"Indicate",
"if",
"the",
"class",
"is",
"a",
"known",
"non",
"-",
"primitive",
"JDK",
"immutable",
"type"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cloning/src/main/java/org/jadira/reflection/core/misc/ClassUtils.java#L43-L70 | train |
JadiraOrg/jadira | cloning/src/main/java/org/jadira/reflection/core/misc/ClassUtils.java | ClassUtils.isWrapper | public static boolean isWrapper(Class<?> type) {
if (Boolean.class == type) {
return true;
}
if (Byte.class == type) {
return true;
}
if (Character.class == type) {
return true;
}
if (Short.class == type) {
retur... | java | public static boolean isWrapper(Class<?> type) {
if (Boolean.class == type) {
return true;
}
if (Byte.class == type) {
return true;
}
if (Character.class == type) {
return true;
}
if (Short.class == type) {
retur... | [
"public",
"static",
"boolean",
"isWrapper",
"(",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"if",
"(",
"Boolean",
".",
"class",
"==",
"type",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"Byte",
".",
"class",
"==",
"type",
")",
"{",
"return",
... | Indicate if the class is a known primitive wrapper type
@param type Class to test
@return True if the type is a primitive wrapper type | [
"Indicate",
"if",
"the",
"class",
"is",
"a",
"known",
"primitive",
"wrapper",
"type"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cloning/src/main/java/org/jadira/reflection/core/misc/ClassUtils.java#L77-L104 | train |
JadiraOrg/jadira | cloning/src/main/java/org/jadira/reflection/core/misc/ClassUtils.java | ClassUtils.collectInstanceFields | public static Field[] collectInstanceFields(Class<?> c, Class<?> limitExclusive) {
return collectFields(c, 0, Modifier.STATIC, limitExclusive);
} | java | public static Field[] collectInstanceFields(Class<?> c, Class<?> limitExclusive) {
return collectFields(c, 0, Modifier.STATIC, limitExclusive);
} | [
"public",
"static",
"Field",
"[",
"]",
"collectInstanceFields",
"(",
"Class",
"<",
"?",
">",
"c",
",",
"Class",
"<",
"?",
">",
"limitExclusive",
")",
"{",
"return",
"collectFields",
"(",
"c",
",",
"0",
",",
"Modifier",
".",
"STATIC",
",",
"limitExclusive... | Produces an array with all the instance fields of the specified class
@param c The class specified
@param limitExclusive Fields from this class or higher in the hierarchy will not be returned
@return The array of matched Fields | [
"Produces",
"an",
"array",
"with",
"all",
"the",
"instance",
"fields",
"of",
"the",
"specified",
"class"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cloning/src/main/java/org/jadira/reflection/core/misc/ClassUtils.java#L132-L135 | train |
JadiraOrg/jadira | usertype.spi/src/main/java/org/jadira/usertype/spi/repository/JpaSearchRepository.java | JpaSearchRepository.getEntityClass | protected final Class<T> getEntityClass() {
@SuppressWarnings("unchecked")
final Class<T> result = (Class<T>) TypeHelper.getTypeArguments(JpaSearchRepository.class, this.getClass()).get(0);
return result;
} | java | protected final Class<T> getEntityClass() {
@SuppressWarnings("unchecked")
final Class<T> result = (Class<T>) TypeHelper.getTypeArguments(JpaSearchRepository.class, this.getClass()).get(0);
return result;
} | [
"protected",
"final",
"Class",
"<",
"T",
">",
"getEntityClass",
"(",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"final",
"Class",
"<",
"T",
">",
"result",
"=",
"(",
"Class",
"<",
"T",
">",
")",
"TypeHelper",
".",
"getTypeArguments",
"(... | Returns the class for the entity type associated with this repository.
@return Class | [
"Returns",
"the",
"class",
"for",
"the",
"entity",
"type",
"associated",
"with",
"this",
"repository",
"."
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/usertype.spi/src/main/java/org/jadira/usertype/spi/repository/JpaSearchRepository.java#L75-L80 | train |
JadiraOrg/jadira | usertype.spi/src/main/java/org/jadira/usertype/spi/repository/JpaSearchRepository.java | JpaSearchRepository.getIdClass | protected final Class<ID> getIdClass() {
@SuppressWarnings("unchecked")
final Class<ID> result = (Class<ID>) TypeHelper.getTypeArguments(JpaSearchRepository.class, this.getClass()).get(1);
return result;
} | java | protected final Class<ID> getIdClass() {
@SuppressWarnings("unchecked")
final Class<ID> result = (Class<ID>) TypeHelper.getTypeArguments(JpaSearchRepository.class, this.getClass()).get(1);
return result;
} | [
"protected",
"final",
"Class",
"<",
"ID",
">",
"getIdClass",
"(",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"final",
"Class",
"<",
"ID",
">",
"result",
"=",
"(",
"Class",
"<",
"ID",
">",
")",
"TypeHelper",
".",
"getTypeArguments",
"("... | Returns the class for the ID field for the entity type associated with this repository.
@return Class for the ID | [
"Returns",
"the",
"class",
"for",
"the",
"ID",
"field",
"for",
"the",
"entity",
"type",
"associated",
"with",
"this",
"repository",
"."
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/usertype.spi/src/main/java/org/jadira/usertype/spi/repository/JpaSearchRepository.java#L86-L91 | train |
JadiraOrg/jadira | usertype.spi/src/main/java/org/jadira/usertype/spi/repository/JpaSearchRepository.java | JpaSearchRepository.getSingleResult | protected T getSingleResult(Query q) {
try {
@SuppressWarnings("unchecked")
T retVal = (T) q.getSingleResult();
return retVal;
} catch (NoResultException e) {
return null;
}
} | java | protected T getSingleResult(Query q) {
try {
@SuppressWarnings("unchecked")
T retVal = (T) q.getSingleResult();
return retVal;
} catch (NoResultException e) {
return null;
}
} | [
"protected",
"T",
"getSingleResult",
"(",
"Query",
"q",
")",
"{",
"try",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"T",
"retVal",
"=",
"(",
"T",
")",
"q",
".",
"getSingleResult",
"(",
")",
";",
"return",
"retVal",
";",
"}",
"catch",
"(",... | Executes a query that returns a single record. In the case of no result, rather than throwing
an exception, null is returned.
@param q Query to Execute
@return T The instance to return, or null if no result. | [
"Executes",
"a",
"query",
"that",
"returns",
"a",
"single",
"record",
".",
"In",
"the",
"case",
"of",
"no",
"result",
"rather",
"than",
"throwing",
"an",
"exception",
"null",
"is",
"returned",
"."
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/usertype.spi/src/main/java/org/jadira/usertype/spi/repository/JpaSearchRepository.java#L99-L107 | train |
JadiraOrg/jadira | usertype.spi/src/main/java/org/jadira/usertype/spi/utils/reflection/ClassLoaderUtils.java | ClassLoaderUtils.classForName | public static Class<?> classForName(String name) throws ClassNotFoundException {
ClassLoader cl = getClassLoader();
try {
if (cl != null) {
return cl.loadClass(name);
}
} catch (ClassNotFoundException e) {
// Ignore and try using Class.forName()
}
return Class.forName(name);
} | java | public static Class<?> classForName(String name) throws ClassNotFoundException {
ClassLoader cl = getClassLoader();
try {
if (cl != null) {
return cl.loadClass(name);
}
} catch (ClassNotFoundException e) {
// Ignore and try using Class.forName()
}
return Class.forName(name);
} | [
"public",
"static",
"Class",
"<",
"?",
">",
"classForName",
"(",
"String",
"name",
")",
"throws",
"ClassNotFoundException",
"{",
"ClassLoader",
"cl",
"=",
"getClassLoader",
"(",
")",
";",
"try",
"{",
"if",
"(",
"cl",
"!=",
"null",
")",
"{",
"return",
"cl... | Attempts to instantiate the named class, using the context ClassLoader for the current thread,
or Class.forName if this does not work
@param name The class name
@return The Class instance
@throws ClassNotFoundException If the class cannot be found | [
"Attempts",
"to",
"instantiate",
"the",
"named",
"class",
"using",
"the",
"context",
"ClassLoader",
"for",
"the",
"current",
"thread",
"or",
"Class",
".",
"forName",
"if",
"this",
"does",
"not",
"work"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/usertype.spi/src/main/java/org/jadira/usertype/spi/utils/reflection/ClassLoaderUtils.java#L48-L59 | train |
JadiraOrg/jadira | scanner/src/main/java/org/jadira/scanner/core/utils/reflection/ClassLoaderUtils.java | ClassLoaderUtils.classForName | public static Class<?> classForName(String name,
ClassLoader... classLoaders) throws ClassNotFoundException {
ClassLoader[] cls = getClassLoaders(classLoaders);
for (ClassLoader cl : cls) {
try {
if (cl != null) {
return cl.loadClass(name);
}
} catch (ClassNotFoundException e) {
... | java | public static Class<?> classForName(String name,
ClassLoader... classLoaders) throws ClassNotFoundException {
ClassLoader[] cls = getClassLoaders(classLoaders);
for (ClassLoader cl : cls) {
try {
if (cl != null) {
return cl.loadClass(name);
}
} catch (ClassNotFoundException e) {
... | [
"public",
"static",
"Class",
"<",
"?",
">",
"classForName",
"(",
"String",
"name",
",",
"ClassLoader",
"...",
"classLoaders",
")",
"throws",
"ClassNotFoundException",
"{",
"ClassLoader",
"[",
"]",
"cls",
"=",
"getClassLoaders",
"(",
"classLoaders",
")",
";",
"... | Attempts to instantiate the named class, using each of the specified
ClassLoaders in turn or Class.forName if these do not work
@param name The class name
@param classLoaders ClassLoaders to be used
@return The Class instance
@throws ClassNotFoundException If the class cannot be found | [
"Attempts",
"to",
"instantiate",
"the",
"named",
"class",
"using",
"each",
"of",
"the",
"specified",
"ClassLoaders",
"in",
"turn",
"or",
"Class",
".",
"forName",
"if",
"these",
"do",
"not",
"work"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/scanner/src/main/java/org/jadira/scanner/core/utils/reflection/ClassLoaderUtils.java#L63-L79 | train |
JadiraOrg/jadira | cloning/src/main/java/org/jadira/reflection/cloning/implementor/AbstractCloneStrategy.java | AbstractCloneStrategy.performCloneForCloneableMethod | protected <T> T performCloneForCloneableMethod(T object, CloneDriver context) {
Class<?> clazz = object.getClass();
final T result;
try {
MethodHandle handle = context.getCloneMethod(clazz);
result = (T) handle.invoke(object);
} catch (Throwable e) {
throw new IllegalStateException("Could not invoke ... | java | protected <T> T performCloneForCloneableMethod(T object, CloneDriver context) {
Class<?> clazz = object.getClass();
final T result;
try {
MethodHandle handle = context.getCloneMethod(clazz);
result = (T) handle.invoke(object);
} catch (Throwable e) {
throw new IllegalStateException("Could not invoke ... | [
"protected",
"<",
"T",
">",
"T",
"performCloneForCloneableMethod",
"(",
"T",
"object",
",",
"CloneDriver",
"context",
")",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"object",
".",
"getClass",
"(",
")",
";",
"final",
"T",
"result",
";",
"try",
"{",
"Me... | Helper method for performing cloning for objects of classes implementing java.lang.Cloneable
@param object The object to be cloned.
@param context The CloneDriver to be used
@param <T> The type being copied
@return The cloned object | [
"Helper",
"method",
"for",
"performing",
"cloning",
"for",
"objects",
"of",
"classes",
"implementing",
"java",
".",
"lang",
".",
"Cloneable"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cloning/src/main/java/org/jadira/reflection/cloning/implementor/AbstractCloneStrategy.java#L271-L283 | train |
JadiraOrg/jadira | cloning/src/main/java/org/jadira/reflection/cloning/implementor/AbstractCloneStrategy.java | AbstractCloneStrategy.handleCloneField | protected <T> void handleCloneField(T obj, T copy, CloneDriver driver, FieldModel<T> f, IdentityHashMap<Object, Object> referencesToReuse, long stackDepth) {
final Class<?> clazz = f.getFieldClass();
if (clazz.isPrimitive()) {
handleClonePrimitiveField(obj, copy, driver, f, referencesToReuse);
} else if (!dr... | java | protected <T> void handleCloneField(T obj, T copy, CloneDriver driver, FieldModel<T> f, IdentityHashMap<Object, Object> referencesToReuse, long stackDepth) {
final Class<?> clazz = f.getFieldClass();
if (clazz.isPrimitive()) {
handleClonePrimitiveField(obj, copy, driver, f, referencesToReuse);
} else if (!dr... | [
"protected",
"<",
"T",
">",
"void",
"handleCloneField",
"(",
"T",
"obj",
",",
"T",
"copy",
",",
"CloneDriver",
"driver",
",",
"FieldModel",
"<",
"T",
">",
"f",
",",
"IdentityHashMap",
"<",
"Object",
",",
"Object",
">",
"referencesToReuse",
",",
"long",
"... | Clone a Field
@param obj The original object
@param copy The destination object
@param driver The CloneDriver
@param f The FieldModel for the target field
@param referencesToReuse Used for tracking objects that have already been seen
@param stackDepth The current depth of the stack - used to switch from recursion to it... | [
"Clone",
"a",
"Field"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cloning/src/main/java/org/jadira/reflection/cloning/implementor/AbstractCloneStrategy.java#L375-L389 | train |
JadiraOrg/jadira | cloning/src/main/java/org/jadira/reflection/access/model/ClassModel.java | ClassModel.get | @SuppressWarnings("unchecked")
public static final <C> ClassModel<C> get(ClassAccess<C> classAccess) {
Class<?> clazz = classAccess.getType();
String classModelKey = (classAccess.getClass().getName() + ":" + clazz.getName());
ClassModel<C> classModel = (ClassModel<C>)classModels.get(classModelKey)... | java | @SuppressWarnings("unchecked")
public static final <C> ClassModel<C> get(ClassAccess<C> classAccess) {
Class<?> clazz = classAccess.getType();
String classModelKey = (classAccess.getClass().getName() + ":" + clazz.getName());
ClassModel<C> classModel = (ClassModel<C>)classModels.get(classModelKey)... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"final",
"<",
"C",
">",
"ClassModel",
"<",
"C",
">",
"get",
"(",
"ClassAccess",
"<",
"C",
">",
"classAccess",
")",
"{",
"Class",
"<",
"?",
">",
"clazz",
"=",
"classAccess",
".",
"g... | Returns a class model for the given ClassAccess instance. If a ClassModel
already exists, it will be reused.
@param classAccess The ClassAccess
@param <C> The type of class
@return The Field Model | [
"Returns",
"a",
"class",
"model",
"for",
"the",
"given",
"ClassAccess",
"instance",
".",
"If",
"a",
"ClassModel",
"already",
"exists",
"it",
"will",
"be",
"reused",
"."
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cloning/src/main/java/org/jadira/reflection/access/model/ClassModel.java#L67-L90 | train |
JadiraOrg/jadira | cloning/src/main/java/org/jadira/reflection/cloning/BasicCloner.java | BasicCloner.initializeBuiltInImplementors | private void initializeBuiltInImplementors() {
builtInImplementors.put(ArrayList.class, new ArrayListImplementor());
builtInImplementors.put(ConcurrentHashMap.class, new ConcurrentHashMapImplementor());
builtInImplementors.put(GregorianCalendar.class, new GregorianCalendarImplementor());
builtInImplementors.put... | java | private void initializeBuiltInImplementors() {
builtInImplementors.put(ArrayList.class, new ArrayListImplementor());
builtInImplementors.put(ConcurrentHashMap.class, new ConcurrentHashMapImplementor());
builtInImplementors.put(GregorianCalendar.class, new GregorianCalendarImplementor());
builtInImplementors.put... | [
"private",
"void",
"initializeBuiltInImplementors",
"(",
")",
"{",
"builtInImplementors",
".",
"put",
"(",
"ArrayList",
".",
"class",
",",
"new",
"ArrayListImplementor",
"(",
")",
")",
";",
"builtInImplementors",
".",
"put",
"(",
"ConcurrentHashMap",
".",
"class",... | Initialise a set of built in CloneImplementors for commonly used JDK types | [
"Initialise",
"a",
"set",
"of",
"built",
"in",
"CloneImplementors",
"for",
"commonly",
"used",
"JDK",
"types"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cloning/src/main/java/org/jadira/reflection/cloning/BasicCloner.java#L170-L179 | train |
JadiraOrg/jadira | cloning/src/main/java/org/jadira/reflection/cloning/BasicCloner.java | BasicCloner.setImplementors | public void setImplementors(Map<Class<?>, CloneImplementor> implementors) {
// this.implementors = implementors;
this.allImplementors = new HashMap<Class<?>, CloneImplementor>();
allImplementors.putAll(builtInImplementors);
allImplementors.putAll(implementors);
} | java | public void setImplementors(Map<Class<?>, CloneImplementor> implementors) {
// this.implementors = implementors;
this.allImplementors = new HashMap<Class<?>, CloneImplementor>();
allImplementors.putAll(builtInImplementors);
allImplementors.putAll(implementors);
} | [
"public",
"void",
"setImplementors",
"(",
"Map",
"<",
"Class",
"<",
"?",
">",
",",
"CloneImplementor",
">",
"implementors",
")",
"{",
"// this.implementors = implementors;",
"this",
".",
"allImplementors",
"=",
"new",
"HashMap",
"<",
"Class",
"<",
"?",
">",
",... | Sets CloneImplementors to be used.
@param implementors The implementors | [
"Sets",
"CloneImplementors",
"to",
"be",
"used",
"."
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cloning/src/main/java/org/jadira/reflection/cloning/BasicCloner.java#L248-L254 | train |
JadiraOrg/jadira | bindings/src/main/java/org/jadira/bindings/core/utils/string/StringUtils.java | StringUtils.removeWhitespace | public static String removeWhitespace(String string) {
if (string == null || string.length() == 0) {
return string;
} else {
int codePoints = string.codePointCount(0, string.length());
StringBuilder sb = new StringBuilder();
for (int i = 0; i < c... | java | public static String removeWhitespace(String string) {
if (string == null || string.length() == 0) {
return string;
} else {
int codePoints = string.codePointCount(0, string.length());
StringBuilder sb = new StringBuilder();
for (int i = 0; i < c... | [
"public",
"static",
"String",
"removeWhitespace",
"(",
"String",
"string",
")",
"{",
"if",
"(",
"string",
"==",
"null",
"||",
"string",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"string",
";",
"}",
"else",
"{",
"int",
"codePoints",
"=",
... | Removes any whitespace from a String, correctly handling surrogate characters
@param string String to process
@return String with any whitespace removed | [
"Removes",
"any",
"whitespace",
"from",
"a",
"String",
"correctly",
"handling",
"surrogate",
"characters"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/bindings/src/main/java/org/jadira/bindings/core/utils/string/StringUtils.java#L31-L54 | train |
JadiraOrg/jadira | cloning/src/main/java/org/jadira/reflection/access/classloader/AccessClassLoader.java | AccessClassLoader.get | public static final AccessClassLoader get(Class<?> typeToBeExtended) {
ClassLoader loader = typeToBeExtended.getClassLoader();
return get(loader == null ? ClassLoader.getSystemClassLoader() : loader);
} | java | public static final AccessClassLoader get(Class<?> typeToBeExtended) {
ClassLoader loader = typeToBeExtended.getClassLoader();
return get(loader == null ? ClassLoader.getSystemClassLoader() : loader);
} | [
"public",
"static",
"final",
"AccessClassLoader",
"get",
"(",
"Class",
"<",
"?",
">",
"typeToBeExtended",
")",
"{",
"ClassLoader",
"loader",
"=",
"typeToBeExtended",
".",
"getClassLoader",
"(",
")",
";",
"return",
"get",
"(",
"loader",
"==",
"null",
"?",
"Cl... | Creates a new instance using a suitable ClassLoader for the specified class
@param typeToBeExtended The class to use to obtain a ClassLoader
@return A new instance, or an existing instance if one already exists. | [
"Creates",
"a",
"new",
"instance",
"using",
"a",
"suitable",
"ClassLoader",
"for",
"the",
"specified",
"class"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cloning/src/main/java/org/jadira/reflection/access/classloader/AccessClassLoader.java#L51-L55 | train |
JadiraOrg/jadira | cloning/src/main/java/org/jadira/reflection/access/classloader/AccessClassLoader.java | AccessClassLoader.get | public synchronized static final AccessClassLoader get(ClassLoader parent) {
AccessClassLoader loader = (AccessClassLoader) ASM_CLASS_LOADERS.get(parent);
if (loader == null) {
loader = new AccessClassLoader(parent);
ASM_CLASS_LOADERS.put(parent, loader);
}
return loader;
} | java | public synchronized static final AccessClassLoader get(ClassLoader parent) {
AccessClassLoader loader = (AccessClassLoader) ASM_CLASS_LOADERS.get(parent);
if (loader == null) {
loader = new AccessClassLoader(parent);
ASM_CLASS_LOADERS.put(parent, loader);
}
return loader;
} | [
"public",
"synchronized",
"static",
"final",
"AccessClassLoader",
"get",
"(",
"ClassLoader",
"parent",
")",
"{",
"AccessClassLoader",
"loader",
"=",
"(",
"AccessClassLoader",
")",
"ASM_CLASS_LOADERS",
".",
"get",
"(",
"parent",
")",
";",
"if",
"(",
"loader",
"==... | Creates an AccessClassLoader for the given parent
@param parent The parent ClassLoader for this instance
@return A new instance, or an existing instance if one already exists. | [
"Creates",
"an",
"AccessClassLoader",
"for",
"the",
"given",
"parent"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cloning/src/main/java/org/jadira/reflection/access/classloader/AccessClassLoader.java#L62-L69 | train |
JadiraOrg/jadira | cloning/src/main/java/org/jadira/reflection/access/classloader/AccessClassLoader.java | AccessClassLoader.registerClass | public void registerClass(String name, byte[] bytes) {
if (registeredClasses.containsKey(name)) {
throw new IllegalStateException("Attempted to register a class that has been registered already: " + name);
}
registeredClasses.put(name, bytes);
} | java | public void registerClass(String name, byte[] bytes) {
if (registeredClasses.containsKey(name)) {
throw new IllegalStateException("Attempted to register a class that has been registered already: " + name);
}
registeredClasses.put(name, bytes);
} | [
"public",
"void",
"registerClass",
"(",
"String",
"name",
",",
"byte",
"[",
"]",
"bytes",
")",
"{",
"if",
"(",
"registeredClasses",
".",
"containsKey",
"(",
"name",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Attempted to register a class tha... | Registers a class by its name
@param name The name of the class to be registered
@param bytes An array of bytes containing the class | [
"Registers",
"a",
"class",
"by",
"its",
"name"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cloning/src/main/java/org/jadira/reflection/access/classloader/AccessClassLoader.java#L101-L107 | train |
JadiraOrg/jadira | scanner/src/main/java/org/jadira/scanner/core/helper/filenamefilter/AntPathFilter.java | AntPathFilter.isPatterned | public boolean isPatterned() {
final boolean result;
if (pattern.indexOf('*') != -1 || pattern.indexOf('?') != -1) {
result = true;
} else {
result = false;
}
return result;
} | java | public boolean isPatterned() {
final boolean result;
if (pattern.indexOf('*') != -1 || pattern.indexOf('?') != -1) {
result = true;
} else {
result = false;
}
return result;
} | [
"public",
"boolean",
"isPatterned",
"(",
")",
"{",
"final",
"boolean",
"result",
";",
"if",
"(",
"pattern",
".",
"indexOf",
"(",
"'",
"'",
")",
"!=",
"-",
"1",
"||",
"pattern",
".",
"indexOf",
"(",
"'",
"'",
")",
"!=",
"-",
"1",
")",
"{",
"result... | Returns true if the given path resolves a pattern as opposed to a literal path
@return True if pattern containing any * or ? character | [
"Returns",
"true",
"if",
"the",
"given",
"path",
"resolves",
"a",
"pattern",
"as",
"opposed",
"to",
"a",
"literal",
"path"
] | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/scanner/src/main/java/org/jadira/scanner/core/helper/filenamefilter/AntPathFilter.java#L58-L68 | train |
JadiraOrg/jadira | cloning/src/main/java/org/jadira/reflection/access/invokedynamic/InvokeDynamicClassAccess.java | InvokeDynamicClassAccess.get | public static <C> InvokeDynamicClassAccess<C> get(Class<C> clazz) {
@SuppressWarnings("unchecked")
InvokeDynamicClassAccess<C> access = (InvokeDynamicClassAccess<C>) CLASS_ACCESSES.get(clazz);
if (access != null) {
return access;
}
Class<?> enclosingType = c... | java | public static <C> InvokeDynamicClassAccess<C> get(Class<C> clazz) {
@SuppressWarnings("unchecked")
InvokeDynamicClassAccess<C> access = (InvokeDynamicClassAccess<C>) CLASS_ACCESSES.get(clazz);
if (access != null) {
return access;
}
Class<?> enclosingType = c... | [
"public",
"static",
"<",
"C",
">",
"InvokeDynamicClassAccess",
"<",
"C",
">",
"get",
"(",
"Class",
"<",
"C",
">",
"clazz",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"InvokeDynamicClassAccess",
"<",
"C",
">",
"access",
"=",
"(",
"InvokeD... | Get a new instance that can access the given Class. If the ClassAccess for this class
has not been obtained before, then the specific InvokeDynamicClassAccess is created by
generating a specialised subclass of this class and returning it.
@param clazz Class to be accessed
@param <C> The type of class
@return New Invoke... | [
"Get",
"a",
"new",
"instance",
"that",
"can",
"access",
"the",
"given",
"Class",
".",
"If",
"the",
"ClassAccess",
"for",
"this",
"class",
"has",
"not",
"been",
"obtained",
"before",
"then",
"the",
"specific",
"InvokeDynamicClassAccess",
"is",
"created",
"by",
... | d55d0238395f0cb900531f1f08b4b2d87fa9a4f6 | https://github.com/JadiraOrg/jadira/blob/d55d0238395f0cb900531f1f08b4b2d87fa9a4f6/cloning/src/main/java/org/jadira/reflection/access/invokedynamic/InvokeDynamicClassAccess.java#L85-L152 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.