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
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/buffer/MessageBuffer.java
MessageBuffer.sliceAsByteBuffer
public ByteBuffer sliceAsByteBuffer(int index, int length) { if (hasArray()) { return ByteBuffer.wrap((byte[]) base, (int) ((address - ARRAY_BYTE_BASE_OFFSET) + index), length); } else { assert (!isUniversalBuffer); return DirectBufferAccess.newByteBuffer(address, index, length, reference); } }
java
public ByteBuffer sliceAsByteBuffer(int index, int length) { if (hasArray()) { return ByteBuffer.wrap((byte[]) base, (int) ((address - ARRAY_BYTE_BASE_OFFSET) + index), length); } else { assert (!isUniversalBuffer); return DirectBufferAccess.newByteBuffer(address, index, length, reference); } }
[ "public", "ByteBuffer", "sliceAsByteBuffer", "(", "int", "index", ",", "int", "length", ")", "{", "if", "(", "hasArray", "(", ")", ")", "{", "return", "ByteBuffer", ".", "wrap", "(", "(", "byte", "[", "]", ")", "base", ",", "(", "int", ")", "(", "(...
Create a ByteBuffer view of the range [index, index+length) of this memory @param index @param length @return
[ "Create", "a", "ByteBuffer", "view", "of", "the", "range", "[", "index", "index", "+", "length", ")", "of", "this", "memory" ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/buffer/MessageBuffer.java#L570-L579
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/buffer/MessageBuffer.java
MessageBuffer.toByteArray
public byte[] toByteArray() { byte[] b = new byte[size()]; unsafe.copyMemory(base, address, b, ARRAY_BYTE_BASE_OFFSET, size()); return b; }
java
public byte[] toByteArray() { byte[] b = new byte[size()]; unsafe.copyMemory(base, address, b, ARRAY_BYTE_BASE_OFFSET, size()); return b; }
[ "public", "byte", "[", "]", "toByteArray", "(", ")", "{", "byte", "[", "]", "b", "=", "new", "byte", "[", "size", "(", ")", "]", ";", "unsafe", ".", "copyMemory", "(", "base", ",", "address", ",", "b", ",", "ARRAY_BYTE_BASE_OFFSET", ",", "size", "(...
Get a copy of this buffer @return
[ "Get", "a", "copy", "of", "this", "buffer" ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/buffer/MessageBuffer.java#L601-L606
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/buffer/MessageBuffer.java
MessageBuffer.copyTo
public void copyTo(int index, MessageBuffer dst, int offset, int length) { unsafe.copyMemory(base, address + index, dst.base, dst.address + offset, length); }
java
public void copyTo(int index, MessageBuffer dst, int offset, int length) { unsafe.copyMemory(base, address + index, dst.base, dst.address + offset, length); }
[ "public", "void", "copyTo", "(", "int", "index", ",", "MessageBuffer", "dst", ",", "int", "offset", ",", "int", "length", ")", "{", "unsafe", ".", "copyMemory", "(", "base", ",", "address", "+", "index", ",", "dst", ".", "base", ",", "dst", ".", "add...
Copy this buffer contents to another MessageBuffer @param index @param dst @param offset @param length
[ "Copy", "this", "buffer", "contents", "to", "another", "MessageBuffer" ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/buffer/MessageBuffer.java#L626-L629
train
msgpack/msgpack-java
msgpack-jackson/src/main/java/org/msgpack/jackson/dataformat/JsonArrayFormat.java
JsonArrayFormat.findFormat
@Override public JsonFormat.Value findFormat(Annotated ann) { // If the entity contains JsonFormat annotation, give it higher priority. JsonFormat.Value precedenceFormat = super.findFormat(ann); if (precedenceFormat != null) { return precedenceFormat; } return ARRAY_FORMAT; }
java
@Override public JsonFormat.Value findFormat(Annotated ann) { // If the entity contains JsonFormat annotation, give it higher priority. JsonFormat.Value precedenceFormat = super.findFormat(ann); if (precedenceFormat != null) { return precedenceFormat; } return ARRAY_FORMAT; }
[ "@", "Override", "public", "JsonFormat", ".", "Value", "findFormat", "(", "Annotated", "ann", ")", "{", "// If the entity contains JsonFormat annotation, give it higher priority.", "JsonFormat", ".", "Value", "precedenceFormat", "=", "super", ".", "findFormat", "(", "ann"...
Defines array format for serialized entities with ObjectMapper, without actually including the schema
[ "Defines", "array", "format", "for", "serialized", "entities", "with", "ObjectMapper", "without", "actually", "including", "the", "schema" ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-jackson/src/main/java/org/msgpack/jackson/dataformat/JsonArrayFormat.java#L25-L35
train
msgpack/msgpack-java
msgpack-jackson/src/main/java/org/msgpack/jackson/dataformat/JsonArrayFormat.java
JsonArrayFormat.findIgnoreUnknownProperties
@Override public Boolean findIgnoreUnknownProperties(AnnotatedClass ac) { // If the entity contains JsonIgnoreProperties annotation, give it higher priority. final Boolean precedenceIgnoreUnknownProperties = super.findIgnoreUnknownProperties(ac); if (precedenceIgnoreUnknownProperties != null) { return precedenceIgnoreUnknownProperties; } return true; }
java
@Override public Boolean findIgnoreUnknownProperties(AnnotatedClass ac) { // If the entity contains JsonIgnoreProperties annotation, give it higher priority. final Boolean precedenceIgnoreUnknownProperties = super.findIgnoreUnknownProperties(ac); if (precedenceIgnoreUnknownProperties != null) { return precedenceIgnoreUnknownProperties; } return true; }
[ "@", "Override", "public", "Boolean", "findIgnoreUnknownProperties", "(", "AnnotatedClass", "ac", ")", "{", "// If the entity contains JsonIgnoreProperties annotation, give it higher priority.", "final", "Boolean", "precedenceIgnoreUnknownProperties", "=", "super", ".", "findIgnore...
Defines that unknown properties will be ignored, and won't fail the un-marshalling process. Happens in case of de-serialization of a payload that contains more properties than the actual value type
[ "Defines", "that", "unknown", "properties", "will", "be", "ignored", "and", "won", "t", "fail", "the", "un", "-", "marshalling", "process", ".", "Happens", "in", "case", "of", "de", "-", "serialization", "of", "a", "payload", "that", "contains", "more", "p...
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-jackson/src/main/java/org/msgpack/jackson/dataformat/JsonArrayFormat.java#L42-L52
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/buffer/OutputStreamBufferOutput.java
OutputStreamBufferOutput.reset
public OutputStream reset(OutputStream out) throws IOException { OutputStream old = this.out; this.out = out; return old; }
java
public OutputStream reset(OutputStream out) throws IOException { OutputStream old = this.out; this.out = out; return old; }
[ "public", "OutputStream", "reset", "(", "OutputStream", "out", ")", "throws", "IOException", "{", "OutputStream", "old", "=", "this", ".", "out", ";", "this", ".", "out", "=", "out", ";", "return", "old", ";", "}" ]
Reset Stream. This method doesn't close the old stream. @param out new stream @return the old stream
[ "Reset", "Stream", ".", "This", "method", "doesn", "t", "close", "the", "old", "stream", "." ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/buffer/OutputStreamBufferOutput.java#L49-L55
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/buffer/InputStreamBufferInput.java
InputStreamBufferInput.reset
public InputStream reset(InputStream in) throws IOException { InputStream old = this.in; this.in = in; return old; }
java
public InputStream reset(InputStream in) throws IOException { InputStream old = this.in; this.in = in; return old; }
[ "public", "InputStream", "reset", "(", "InputStream", "in", ")", "throws", "IOException", "{", "InputStream", "old", "=", "this", ".", "in", ";", "this", ".", "in", "=", "in", ";", "return", "old", ";", "}" ]
Reset Stream. This method doesn't close the old resource. @param in new stream @return the old resource
[ "Reset", "Stream", ".", "This", "method", "doesn", "t", "close", "the", "old", "resource", "." ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/buffer/InputStreamBufferInput.java#L63-L69
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/buffer/ChannelBufferOutput.java
ChannelBufferOutput.reset
public WritableByteChannel reset(WritableByteChannel channel) throws IOException { WritableByteChannel old = this.channel; this.channel = channel; return old; }
java
public WritableByteChannel reset(WritableByteChannel channel) throws IOException { WritableByteChannel old = this.channel; this.channel = channel; return old; }
[ "public", "WritableByteChannel", "reset", "(", "WritableByteChannel", "channel", ")", "throws", "IOException", "{", "WritableByteChannel", "old", "=", "this", ".", "channel", ";", "this", ".", "channel", "=", "channel", ";", "return", "old", ";", "}" ]
Reset channel. This method doesn't close the old channel. @param channel new channel @return the old channel
[ "Reset", "channel", ".", "This", "method", "doesn", "t", "close", "the", "old", "channel", "." ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/buffer/ChannelBufferOutput.java#L50-L56
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/buffer/ChannelBufferInput.java
ChannelBufferInput.reset
public ReadableByteChannel reset(ReadableByteChannel channel) throws IOException { ReadableByteChannel old = this.channel; this.channel = channel; return old; }
java
public ReadableByteChannel reset(ReadableByteChannel channel) throws IOException { ReadableByteChannel old = this.channel; this.channel = channel; return old; }
[ "public", "ReadableByteChannel", "reset", "(", "ReadableByteChannel", "channel", ")", "throws", "IOException", "{", "ReadableByteChannel", "old", "=", "this", ".", "channel", ";", "this", ".", "channel", "=", "channel", ";", "return", "old", ";", "}" ]
Reset channel. This method doesn't close the old resource. @param channel new channel @return the old resource
[ "Reset", "channel", ".", "This", "method", "doesn", "t", "close", "the", "old", "resource", "." ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/buffer/ChannelBufferInput.java#L52-L58
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java
MessageUnpacker.getNextBuffer
private MessageBuffer getNextBuffer() throws IOException { MessageBuffer next = in.next(); if (next == null) { throw new MessageInsufficientBufferException(); } assert (buffer != null); totalReadBytes += buffer.size(); return next; }
java
private MessageBuffer getNextBuffer() throws IOException { MessageBuffer next = in.next(); if (next == null) { throw new MessageInsufficientBufferException(); } assert (buffer != null); totalReadBytes += buffer.size(); return next; }
[ "private", "MessageBuffer", "getNextBuffer", "(", ")", "throws", "IOException", "{", "MessageBuffer", "next", "=", "in", ".", "next", "(", ")", ";", "if", "(", "next", "==", "null", ")", "{", "throw", "new", "MessageInsufficientBufferException", "(", ")", ";...
Get the next buffer without changing the position @return @throws IOException
[ "Get", "the", "next", "buffer", "without", "changing", "the", "position" ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java#L272-L282
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java
MessageUnpacker.getNextFormat
public MessageFormat getNextFormat() throws IOException { // makes sure that buffer has at least 1 byte if (!ensureBuffer()) { throw new MessageInsufficientBufferException(); } byte b = buffer.getByte(position); return MessageFormat.valueOf(b); }
java
public MessageFormat getNextFormat() throws IOException { // makes sure that buffer has at least 1 byte if (!ensureBuffer()) { throw new MessageInsufficientBufferException(); } byte b = buffer.getByte(position); return MessageFormat.valueOf(b); }
[ "public", "MessageFormat", "getNextFormat", "(", ")", "throws", "IOException", "{", "// makes sure that buffer has at least 1 byte", "if", "(", "!", "ensureBuffer", "(", ")", ")", "{", "throw", "new", "MessageInsufficientBufferException", "(", ")", ";", "}", "byte", ...
Returns format of the next value. <p> Note that this method doesn't consume data from the internal buffer unlike the other unpack methods. Calling this method twice will return the same value. <p> To not throw {@link MessageInsufficientBufferException}, this method should be called only when {@link #hasNext()} returns true. @return the next MessageFormat @throws IOException when underlying input throws IOException @throws MessageInsufficientBufferException when the end of file reached, i.e. {@link #hasNext()} == false.
[ "Returns", "format", "of", "the", "next", "value", "." ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java#L389-L398
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java
MessageUnpacker.readByte
private byte readByte() throws IOException { if (buffer.size() > position) { byte b = buffer.getByte(position); position++; return b; } else { nextBuffer(); if (buffer.size() > 0) { byte b = buffer.getByte(0); position = 1; return b; } return readByte(); } }
java
private byte readByte() throws IOException { if (buffer.size() > position) { byte b = buffer.getByte(position); position++; return b; } else { nextBuffer(); if (buffer.size() > 0) { byte b = buffer.getByte(0); position = 1; return b; } return readByte(); } }
[ "private", "byte", "readByte", "(", ")", "throws", "IOException", "{", "if", "(", "buffer", ".", "size", "(", ")", ">", "position", ")", "{", "byte", "b", "=", "buffer", ".", "getByte", "(", "position", ")", ";", "position", "++", ";", "return", "b",...
Read a byte value at the cursor and proceed the cursor. @return @throws IOException
[ "Read", "a", "byte", "value", "at", "the", "cursor", "and", "proceed", "the", "cursor", "." ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java#L406-L423
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java
MessageUnpacker.skipValue
public void skipValue(int count) throws IOException { while (count > 0) { byte b = readByte(); MessageFormat f = MessageFormat.valueOf(b); switch (f) { case POSFIXINT: case NEGFIXINT: case BOOLEAN: case NIL: break; case FIXMAP: { int mapLen = b & 0x0f; count += mapLen * 2; break; } case FIXARRAY: { int arrayLen = b & 0x0f; count += arrayLen; break; } case FIXSTR: { int strLen = b & 0x1f; skipPayload(strLen); break; } case INT8: case UINT8: skipPayload(1); break; case INT16: case UINT16: skipPayload(2); break; case INT32: case UINT32: case FLOAT32: skipPayload(4); break; case INT64: case UINT64: case FLOAT64: skipPayload(8); break; case BIN8: case STR8: skipPayload(readNextLength8()); break; case BIN16: case STR16: skipPayload(readNextLength16()); break; case BIN32: case STR32: skipPayload(readNextLength32()); break; case FIXEXT1: skipPayload(2); break; case FIXEXT2: skipPayload(3); break; case FIXEXT4: skipPayload(5); break; case FIXEXT8: skipPayload(9); break; case FIXEXT16: skipPayload(17); break; case EXT8: skipPayload(readNextLength8() + 1); break; case EXT16: skipPayload(readNextLength16() + 1); break; case EXT32: skipPayload(readNextLength32() + 1); break; case ARRAY16: count += readNextLength16(); break; case ARRAY32: count += readNextLength32(); break; case MAP16: count += readNextLength16() * 2; break; case MAP32: count += readNextLength32() * 2; // TODO check int overflow break; case NEVER_USED: throw new MessageNeverUsedFormatException("Encountered 0xC1 \"NEVER_USED\" byte"); } count--; } }
java
public void skipValue(int count) throws IOException { while (count > 0) { byte b = readByte(); MessageFormat f = MessageFormat.valueOf(b); switch (f) { case POSFIXINT: case NEGFIXINT: case BOOLEAN: case NIL: break; case FIXMAP: { int mapLen = b & 0x0f; count += mapLen * 2; break; } case FIXARRAY: { int arrayLen = b & 0x0f; count += arrayLen; break; } case FIXSTR: { int strLen = b & 0x1f; skipPayload(strLen); break; } case INT8: case UINT8: skipPayload(1); break; case INT16: case UINT16: skipPayload(2); break; case INT32: case UINT32: case FLOAT32: skipPayload(4); break; case INT64: case UINT64: case FLOAT64: skipPayload(8); break; case BIN8: case STR8: skipPayload(readNextLength8()); break; case BIN16: case STR16: skipPayload(readNextLength16()); break; case BIN32: case STR32: skipPayload(readNextLength32()); break; case FIXEXT1: skipPayload(2); break; case FIXEXT2: skipPayload(3); break; case FIXEXT4: skipPayload(5); break; case FIXEXT8: skipPayload(9); break; case FIXEXT16: skipPayload(17); break; case EXT8: skipPayload(readNextLength8() + 1); break; case EXT16: skipPayload(readNextLength16() + 1); break; case EXT32: skipPayload(readNextLength32() + 1); break; case ARRAY16: count += readNextLength16(); break; case ARRAY32: count += readNextLength32(); break; case MAP16: count += readNextLength16() * 2; break; case MAP32: count += readNextLength32() * 2; // TODO check int overflow break; case NEVER_USED: throw new MessageNeverUsedFormatException("Encountered 0xC1 \"NEVER_USED\" byte"); } count--; } }
[ "public", "void", "skipValue", "(", "int", "count", ")", "throws", "IOException", "{", "while", "(", "count", ">", "0", ")", "{", "byte", "b", "=", "readByte", "(", ")", ";", "MessageFormat", "f", "=", "MessageFormat", ".", "valueOf", "(", "b", ")", ...
Skip next values, then move the cursor at the end of the value @param count number of values to skip @throws IOException
[ "Skip", "next", "values", "then", "move", "the", "cursor", "at", "the", "end", "of", "the", "value" ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java#L477-L576
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java
MessageUnpacker.unexpected
private static MessagePackException unexpected(String expected, byte b) { MessageFormat format = MessageFormat.valueOf(b); if (format == MessageFormat.NEVER_USED) { return new MessageNeverUsedFormatException(String.format("Expected %s, but encountered 0xC1 \"NEVER_USED\" byte", expected)); } else { String name = format.getValueType().name(); String typeName = name.substring(0, 1) + name.substring(1).toLowerCase(); return new MessageTypeException(String.format("Expected %s, but got %s (%02x)", expected, typeName, b)); } }
java
private static MessagePackException unexpected(String expected, byte b) { MessageFormat format = MessageFormat.valueOf(b); if (format == MessageFormat.NEVER_USED) { return new MessageNeverUsedFormatException(String.format("Expected %s, but encountered 0xC1 \"NEVER_USED\" byte", expected)); } else { String name = format.getValueType().name(); String typeName = name.substring(0, 1) + name.substring(1).toLowerCase(); return new MessageTypeException(String.format("Expected %s, but got %s (%02x)", expected, typeName, b)); } }
[ "private", "static", "MessagePackException", "unexpected", "(", "String", "expected", ",", "byte", "b", ")", "{", "MessageFormat", "format", "=", "MessageFormat", ".", "valueOf", "(", "b", ")", ";", "if", "(", "format", "==", "MessageFormat", ".", "NEVER_USED"...
Create an exception for the case when an unexpected byte value is read @param expected @param b @return @throws MessageFormatException
[ "Create", "an", "exception", "for", "the", "case", "when", "an", "unexpected", "byte", "value", "is", "read" ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java#L586-L597
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java
MessageUnpacker.tryUnpackNil
public boolean tryUnpackNil() throws IOException { // makes sure that buffer has at least 1 byte if (!ensureBuffer()) { throw new MessageInsufficientBufferException(); } byte b = buffer.getByte(position); if (b == Code.NIL) { readByte(); return true; } return false; }
java
public boolean tryUnpackNil() throws IOException { // makes sure that buffer has at least 1 byte if (!ensureBuffer()) { throw new MessageInsufficientBufferException(); } byte b = buffer.getByte(position); if (b == Code.NIL) { readByte(); return true; } return false; }
[ "public", "boolean", "tryUnpackNil", "(", ")", "throws", "IOException", "{", "// makes sure that buffer has at least 1 byte", "if", "(", "!", "ensureBuffer", "(", ")", ")", "{", "throw", "new", "MessageInsufficientBufferException", "(", ")", ";", "}", "byte", "b", ...
Peeks a Nil byte and reads it if next byte is a nil value. The difference from {@link unpackNil} is that unpackNil throws an exception if the next byte is not nil value while this tryUnpackNil method returns false without changing position. @return true if a nil value is read @throws MessageInsufficientBufferException when the end of file reached @throws IOException when underlying input throws IOException
[ "Peeks", "a", "Nil", "byte", "and", "reads", "it", "if", "next", "byte", "is", "a", "nil", "value", "." ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java#L744-L757
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java
MessageUnpacker.unpackBoolean
public boolean unpackBoolean() throws IOException { byte b = readByte(); if (b == Code.FALSE) { return false; } else if (b == Code.TRUE) { return true; } throw unexpected("boolean", b); }
java
public boolean unpackBoolean() throws IOException { byte b = readByte(); if (b == Code.FALSE) { return false; } else if (b == Code.TRUE) { return true; } throw unexpected("boolean", b); }
[ "public", "boolean", "unpackBoolean", "(", ")", "throws", "IOException", "{", "byte", "b", "=", "readByte", "(", ")", ";", "if", "(", "b", "==", "Code", ".", "FALSE", ")", "{", "return", "false", ";", "}", "else", "if", "(", "b", "==", "Code", ".",...
Reads true or false. @return the read value @throws MessageTypeException when value is not MessagePack Boolean type @throws IOException when underlying input throws IOException
[ "Reads", "true", "or", "false", "." ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java#L766-L777
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java
MessageUnpacker.unpackShort
public short unpackShort() throws IOException { byte b = readByte(); if (Code.isFixInt(b)) { return (short) b; } switch (b) { case Code.UINT8: // unsigned int 8 byte u8 = readByte(); return (short) (u8 & 0xff); case Code.UINT16: // unsigned int 16 short u16 = readShort(); if (u16 < (short) 0) { throw overflowU16(u16); } return u16; case Code.UINT32: // unsigned int 32 int u32 = readInt(); if (u32 < 0 || u32 > Short.MAX_VALUE) { throw overflowU32(u32); } return (short) u32; case Code.UINT64: // unsigned int 64 long u64 = readLong(); if (u64 < 0L || u64 > Short.MAX_VALUE) { throw overflowU64(u64); } return (short) u64; case Code.INT8: // signed int 8 byte i8 = readByte(); return (short) i8; case Code.INT16: // signed int 16 short i16 = readShort(); return i16; case Code.INT32: // signed int 32 int i32 = readInt(); if (i32 < Short.MIN_VALUE || i32 > Short.MAX_VALUE) { throw overflowI32(i32); } return (short) i32; case Code.INT64: // signed int 64 long i64 = readLong(); if (i64 < Short.MIN_VALUE || i64 > Short.MAX_VALUE) { throw overflowI64(i64); } return (short) i64; } throw unexpected("Integer", b); }
java
public short unpackShort() throws IOException { byte b = readByte(); if (Code.isFixInt(b)) { return (short) b; } switch (b) { case Code.UINT8: // unsigned int 8 byte u8 = readByte(); return (short) (u8 & 0xff); case Code.UINT16: // unsigned int 16 short u16 = readShort(); if (u16 < (short) 0) { throw overflowU16(u16); } return u16; case Code.UINT32: // unsigned int 32 int u32 = readInt(); if (u32 < 0 || u32 > Short.MAX_VALUE) { throw overflowU32(u32); } return (short) u32; case Code.UINT64: // unsigned int 64 long u64 = readLong(); if (u64 < 0L || u64 > Short.MAX_VALUE) { throw overflowU64(u64); } return (short) u64; case Code.INT8: // signed int 8 byte i8 = readByte(); return (short) i8; case Code.INT16: // signed int 16 short i16 = readShort(); return i16; case Code.INT32: // signed int 32 int i32 = readInt(); if (i32 < Short.MIN_VALUE || i32 > Short.MAX_VALUE) { throw overflowI32(i32); } return (short) i32; case Code.INT64: // signed int 64 long i64 = readLong(); if (i64 < Short.MIN_VALUE || i64 > Short.MAX_VALUE) { throw overflowI64(i64); } return (short) i64; } throw unexpected("Integer", b); }
[ "public", "short", "unpackShort", "(", ")", "throws", "IOException", "{", "byte", "b", "=", "readByte", "(", ")", ";", "if", "(", "Code", ".", "isFixInt", "(", "b", ")", ")", "{", "return", "(", "short", ")", "b", ";", "}", "switch", "(", "b", ")...
Reads a short. This method throws {@link MessageIntegerOverflowException} if the value doesn't fit in the range of short. This may happen when {@link #getNextFormat()} returns UINT16, INT32, or larger integer formats. @return the read value @throws MessageIntegerOverflowException when value doesn't fit in the range of short @throws MessageTypeException when value is not MessagePack Integer type @throws IOException when underlying input throws IOException
[ "Reads", "a", "short", "." ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java#L856-L905
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java
MessageUnpacker.unpackLong
public long unpackLong() throws IOException { byte b = readByte(); if (Code.isFixInt(b)) { return (long) b; } switch (b) { case Code.UINT8: // unsigned int 8 byte u8 = readByte(); return (long) (u8 & 0xff); case Code.UINT16: // unsigned int 16 short u16 = readShort(); return (long) (u16 & 0xffff); case Code.UINT32: // unsigned int 32 int u32 = readInt(); if (u32 < 0) { return (long) (u32 & 0x7fffffff) + 0x80000000L; } else { return (long) u32; } case Code.UINT64: // unsigned int 64 long u64 = readLong(); if (u64 < 0L) { throw overflowU64(u64); } return u64; case Code.INT8: // signed int 8 byte i8 = readByte(); return (long) i8; case Code.INT16: // signed int 16 short i16 = readShort(); return (long) i16; case Code.INT32: // signed int 32 int i32 = readInt(); return (long) i32; case Code.INT64: // signed int 64 long i64 = readLong(); return i64; } throw unexpected("Integer", b); }
java
public long unpackLong() throws IOException { byte b = readByte(); if (Code.isFixInt(b)) { return (long) b; } switch (b) { case Code.UINT8: // unsigned int 8 byte u8 = readByte(); return (long) (u8 & 0xff); case Code.UINT16: // unsigned int 16 short u16 = readShort(); return (long) (u16 & 0xffff); case Code.UINT32: // unsigned int 32 int u32 = readInt(); if (u32 < 0) { return (long) (u32 & 0x7fffffff) + 0x80000000L; } else { return (long) u32; } case Code.UINT64: // unsigned int 64 long u64 = readLong(); if (u64 < 0L) { throw overflowU64(u64); } return u64; case Code.INT8: // signed int 8 byte i8 = readByte(); return (long) i8; case Code.INT16: // signed int 16 short i16 = readShort(); return (long) i16; case Code.INT32: // signed int 32 int i32 = readInt(); return (long) i32; case Code.INT64: // signed int 64 long i64 = readLong(); return i64; } throw unexpected("Integer", b); }
[ "public", "long", "unpackLong", "(", ")", "throws", "IOException", "{", "byte", "b", "=", "readByte", "(", ")", ";", "if", "(", "Code", ".", "isFixInt", "(", "b", ")", ")", "{", "return", "(", "long", ")", "b", ";", "}", "switch", "(", "b", ")", ...
Reads a long. This method throws {@link MessageIntegerOverflowException} if the value doesn't fit in the range of long. This may happen when {@link #getNextFormat()} returns UINT64. @return the read value @throws MessageIntegerOverflowException when value doesn't fit in the range of long @throws MessageTypeException when value is not MessagePack Integer type @throws IOException when underlying input throws IOException
[ "Reads", "a", "long", "." ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java#L972-L1014
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java
MessageUnpacker.unpackBigInteger
public BigInteger unpackBigInteger() throws IOException { byte b = readByte(); if (Code.isFixInt(b)) { return BigInteger.valueOf((long) b); } switch (b) { case Code.UINT8: // unsigned int 8 byte u8 = readByte(); return BigInteger.valueOf((long) (u8 & 0xff)); case Code.UINT16: // unsigned int 16 short u16 = readShort(); return BigInteger.valueOf((long) (u16 & 0xffff)); case Code.UINT32: // unsigned int 32 int u32 = readInt(); if (u32 < 0) { return BigInteger.valueOf((long) (u32 & 0x7fffffff) + 0x80000000L); } else { return BigInteger.valueOf((long) u32); } case Code.UINT64: // unsigned int 64 long u64 = readLong(); if (u64 < 0L) { BigInteger bi = BigInteger.valueOf(u64 + Long.MAX_VALUE + 1L).setBit(63); return bi; } else { return BigInteger.valueOf(u64); } case Code.INT8: // signed int 8 byte i8 = readByte(); return BigInteger.valueOf((long) i8); case Code.INT16: // signed int 16 short i16 = readShort(); return BigInteger.valueOf((long) i16); case Code.INT32: // signed int 32 int i32 = readInt(); return BigInteger.valueOf((long) i32); case Code.INT64: // signed int 64 long i64 = readLong(); return BigInteger.valueOf(i64); } throw unexpected("Integer", b); }
java
public BigInteger unpackBigInteger() throws IOException { byte b = readByte(); if (Code.isFixInt(b)) { return BigInteger.valueOf((long) b); } switch (b) { case Code.UINT8: // unsigned int 8 byte u8 = readByte(); return BigInteger.valueOf((long) (u8 & 0xff)); case Code.UINT16: // unsigned int 16 short u16 = readShort(); return BigInteger.valueOf((long) (u16 & 0xffff)); case Code.UINT32: // unsigned int 32 int u32 = readInt(); if (u32 < 0) { return BigInteger.valueOf((long) (u32 & 0x7fffffff) + 0x80000000L); } else { return BigInteger.valueOf((long) u32); } case Code.UINT64: // unsigned int 64 long u64 = readLong(); if (u64 < 0L) { BigInteger bi = BigInteger.valueOf(u64 + Long.MAX_VALUE + 1L).setBit(63); return bi; } else { return BigInteger.valueOf(u64); } case Code.INT8: // signed int 8 byte i8 = readByte(); return BigInteger.valueOf((long) i8); case Code.INT16: // signed int 16 short i16 = readShort(); return BigInteger.valueOf((long) i16); case Code.INT32: // signed int 32 int i32 = readInt(); return BigInteger.valueOf((long) i32); case Code.INT64: // signed int 64 long i64 = readLong(); return BigInteger.valueOf(i64); } throw unexpected("Integer", b); }
[ "public", "BigInteger", "unpackBigInteger", "(", ")", "throws", "IOException", "{", "byte", "b", "=", "readByte", "(", ")", ";", "if", "(", "Code", ".", "isFixInt", "(", "b", ")", ")", "{", "return", "BigInteger", ".", "valueOf", "(", "(", "long", ")",...
Reads a BigInteger. @return the read value @throws MessageTypeException when value is not MessagePack Integer type @throws IOException when underlying input throws IOException
[ "Reads", "a", "BigInteger", "." ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java#L1023-L1068
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java
MessageUnpacker.unpackFloat
public float unpackFloat() throws IOException { byte b = readByte(); switch (b) { case Code.FLOAT32: // float float fv = readFloat(); return fv; case Code.FLOAT64: // double double dv = readDouble(); return (float) dv; } throw unexpected("Float", b); }
java
public float unpackFloat() throws IOException { byte b = readByte(); switch (b) { case Code.FLOAT32: // float float fv = readFloat(); return fv; case Code.FLOAT64: // double double dv = readDouble(); return (float) dv; } throw unexpected("Float", b); }
[ "public", "float", "unpackFloat", "(", ")", "throws", "IOException", "{", "byte", "b", "=", "readByte", "(", ")", ";", "switch", "(", "b", ")", "{", "case", "Code", ".", "FLOAT32", ":", "// float", "float", "fv", "=", "readFloat", "(", ")", ";", "ret...
Reads a float. This method rounds value to the range of float when precision of the read value is larger than the range of float. This may happen when {@link #getNextFormat()} returns FLOAT64. @return the read value @throws MessageTypeException when value is not MessagePack Float type @throws IOException when underlying input throws IOException
[ "Reads", "a", "float", "." ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java#L1079-L1092
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java
MessageUnpacker.unpackArrayHeader
public int unpackArrayHeader() throws IOException { byte b = readByte(); if (Code.isFixedArray(b)) { // fixarray return b & 0x0f; } switch (b) { case Code.ARRAY16: { // array 16 int len = readNextLength16(); return len; } case Code.ARRAY32: { // array 32 int len = readNextLength32(); return len; } } throw unexpected("Array", b); }
java
public int unpackArrayHeader() throws IOException { byte b = readByte(); if (Code.isFixedArray(b)) { // fixarray return b & 0x0f; } switch (b) { case Code.ARRAY16: { // array 16 int len = readNextLength16(); return len; } case Code.ARRAY32: { // array 32 int len = readNextLength32(); return len; } } throw unexpected("Array", b); }
[ "public", "int", "unpackArrayHeader", "(", ")", "throws", "IOException", "{", "byte", "b", "=", "readByte", "(", ")", ";", "if", "(", "Code", ".", "isFixedArray", "(", "b", ")", ")", "{", "// fixarray", "return", "b", "&", "0x0f", ";", "}", "switch", ...
Reads header of an array. <p> This method returns number of elements to be read. After this method call, you call unpacker methods for each element. You don't have to call anything at the end of iteration. @return the size of the array to be read @throws MessageTypeException when value is not MessagePack Array type @throws MessageSizeException when size of the array is larger than 2^31 - 1 @throws IOException when underlying input throws IOException
[ "Reads", "header", "of", "an", "array", "." ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java#L1272-L1290
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java
MessageUnpacker.unpackMapHeader
public int unpackMapHeader() throws IOException { byte b = readByte(); if (Code.isFixedMap(b)) { // fixmap return b & 0x0f; } switch (b) { case Code.MAP16: { // map 16 int len = readNextLength16(); return len; } case Code.MAP32: { // map 32 int len = readNextLength32(); return len; } } throw unexpected("Map", b); }
java
public int unpackMapHeader() throws IOException { byte b = readByte(); if (Code.isFixedMap(b)) { // fixmap return b & 0x0f; } switch (b) { case Code.MAP16: { // map 16 int len = readNextLength16(); return len; } case Code.MAP32: { // map 32 int len = readNextLength32(); return len; } } throw unexpected("Map", b); }
[ "public", "int", "unpackMapHeader", "(", ")", "throws", "IOException", "{", "byte", "b", "=", "readByte", "(", ")", ";", "if", "(", "Code", ".", "isFixedMap", "(", "b", ")", ")", "{", "// fixmap", "return", "b", "&", "0x0f", ";", "}", "switch", "(", ...
Reads header of a map. <p> This method returns number of pairs to be read. After this method call, for each pair, you call unpacker methods for key first, and then value. You will call unpacker methods twice as many time as the returned count. You don't have to call anything at the end of iteration. @return the size of the map to be read @throws MessageTypeException when value is not MessagePack Map type @throws MessageSizeException when size of the map is larger than 2^31 - 1 @throws IOException when underlying input throws IOException
[ "Reads", "header", "of", "a", "map", "." ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java#L1305-L1323
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java
MessageUnpacker.unpackBinaryHeader
public int unpackBinaryHeader() throws IOException { byte b = readByte(); if (Code.isFixedRaw(b)) { // FixRaw return b & 0x1f; } int len = tryReadBinaryHeader(b); if (len >= 0) { return len; } if (allowReadingStringAsBinary) { len = tryReadStringHeader(b); if (len >= 0) { return len; } } throw unexpected("Binary", b); }
java
public int unpackBinaryHeader() throws IOException { byte b = readByte(); if (Code.isFixedRaw(b)) { // FixRaw return b & 0x1f; } int len = tryReadBinaryHeader(b); if (len >= 0) { return len; } if (allowReadingStringAsBinary) { len = tryReadStringHeader(b); if (len >= 0) { return len; } } throw unexpected("Binary", b); }
[ "public", "int", "unpackBinaryHeader", "(", ")", "throws", "IOException", "{", "byte", "b", "=", "readByte", "(", ")", ";", "if", "(", "Code", ".", "isFixedRaw", "(", "b", ")", ")", "{", "// FixRaw", "return", "b", "&", "0x1f", ";", "}", "int", "len"...
Reads header of a binary. <p> This method returns number of bytes to be read. After this method call, you call a readPayload method such as {@link #readPayload(int)} with the returned count. <p> You can divide readPayload method into multiple calls. In this case, you must repeat readPayload methods until total amount of bytes becomes equal to the returned count. @return the size of the map to be read @throws MessageTypeException when value is not MessagePack Map type @throws MessageSizeException when size of the map is larger than 2^31 - 1 @throws IOException when underlying input throws IOException
[ "Reads", "header", "of", "a", "binary", "." ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java#L1446-L1465
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java
MessageUnpacker.readPayloadAsReference
public MessageBuffer readPayloadAsReference(int length) throws IOException { int bufferRemaining = buffer.size() - position; if (bufferRemaining >= length) { MessageBuffer slice = buffer.slice(position, length); position += length; return slice; } MessageBuffer dst = MessageBuffer.allocate(length); readPayload(dst, 0, length); return dst; }
java
public MessageBuffer readPayloadAsReference(int length) throws IOException { int bufferRemaining = buffer.size() - position; if (bufferRemaining >= length) { MessageBuffer slice = buffer.slice(position, length); position += length; return slice; } MessageBuffer dst = MessageBuffer.allocate(length); readPayload(dst, 0, length); return dst; }
[ "public", "MessageBuffer", "readPayloadAsReference", "(", "int", "length", ")", "throws", "IOException", "{", "int", "bufferRemaining", "=", "buffer", ".", "size", "(", ")", "-", "position", ";", "if", "(", "bufferRemaining", ">=", "length", ")", "{", "Message...
Reads payload bytes of binary, extension, or raw string types as a reference to internal buffer. <p> This consumes specified amount of bytes and returns its reference or copy. This method tries to return reference as much as possible because it is faster. However, it may copy data to a newly allocated buffer if reference is not applicable. @param length number of bytes to be read @throws IOException when underlying input throws IOException
[ "Reads", "payload", "bytes", "of", "binary", "extension", "or", "raw", "string", "types", "as", "a", "reference", "to", "internal", "buffer", "." ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/MessageUnpacker.java#L1627-L1639
train
msgpack/msgpack-java
msgpack-core/src/main/java/org/msgpack/core/buffer/ArrayBufferInput.java
ArrayBufferInput.reset
public MessageBuffer reset(MessageBuffer buf) { MessageBuffer old = this.buffer; this.buffer = buf; if (buf == null) { isEmpty = true; } else { isEmpty = false; } return old; }
java
public MessageBuffer reset(MessageBuffer buf) { MessageBuffer old = this.buffer; this.buffer = buf; if (buf == null) { isEmpty = true; } else { isEmpty = false; } return old; }
[ "public", "MessageBuffer", "reset", "(", "MessageBuffer", "buf", ")", "{", "MessageBuffer", "old", "=", "this", ".", "buffer", ";", "this", ".", "buffer", "=", "buf", ";", "if", "(", "buf", "==", "null", ")", "{", "isEmpty", "=", "true", ";", "}", "e...
Reset buffer. This method returns the old buffer. @param buf new buffer. This can be null to make this input empty. @return the old buffer.
[ "Reset", "buffer", ".", "This", "method", "returns", "the", "old", "buffer", "." ]
16e370e348215a72a14c210b42d448d513aee015
https://github.com/msgpack/msgpack-java/blob/16e370e348215a72a14c210b42d448d513aee015/msgpack-core/src/main/java/org/msgpack/core/buffer/ArrayBufferInput.java#L56-L67
train
kochedykov/jlibmodbus
src/com/intelligt/modbus/jlibmodbus/msg/ModbusRequestBuilder.java
ModbusRequestBuilder.buildDiagnostics
public ModbusRequest buildDiagnostics(DiagnosticsSubFunctionCode subFunctionCode, int serverAddress, int data) throws ModbusNumberException { DiagnosticsRequest request = new DiagnosticsRequest(); request.setServerAddress(serverAddress); request.setSubFunctionCode(subFunctionCode); request.setSubFunctionData(data); return request; }
java
public ModbusRequest buildDiagnostics(DiagnosticsSubFunctionCode subFunctionCode, int serverAddress, int data) throws ModbusNumberException { DiagnosticsRequest request = new DiagnosticsRequest(); request.setServerAddress(serverAddress); request.setSubFunctionCode(subFunctionCode); request.setSubFunctionData(data); return request; }
[ "public", "ModbusRequest", "buildDiagnostics", "(", "DiagnosticsSubFunctionCode", "subFunctionCode", ",", "int", "serverAddress", ",", "int", "data", ")", "throws", "ModbusNumberException", "{", "DiagnosticsRequest", "request", "=", "new", "DiagnosticsRequest", "(", ")", ...
The function uses a sub-function code field in the query to define the type of test to be performed. The server echoes both the function code and sub-function code in a normal response. Some of the diagnostics cause data to be returned from the remote device in the data field of a normal response. @param subFunctionCode a sub-function code @param serverAddress a slave address @param data request data field @return DiagnosticsRequest instance @throws ModbusNumberException if server address is in-valid @see DiagnosticsRequest @see DiagnosticsSubFunctionCode
[ "The", "function", "uses", "a", "sub", "-", "function", "code", "field", "in", "the", "query", "to", "define", "the", "type", "of", "test", "to", "be", "performed", ".", "The", "server", "echoes", "both", "the", "function", "code", "and", "sub", "-", "...
197cb39e2649e61a6fe3cb7dc91a701d847e14be
https://github.com/kochedykov/jlibmodbus/blob/197cb39e2649e61a6fe3cb7dc91a701d847e14be/src/com/intelligt/modbus/jlibmodbus/msg/ModbusRequestBuilder.java#L185-L191
train
kochedykov/jlibmodbus
src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java
ModbusMaster.processRequest
synchronized public ModbusResponse processRequest(ModbusRequest request) throws ModbusProtocolException, ModbusIOException { try { sendRequest(request); if (request.getServerAddress() != Modbus.BROADCAST_ID) { do { try { ModbusResponse msg = (ModbusResponse) readResponse(request); request.validateResponse(msg); /* * if you have received an ACKNOWLEDGE, * it means that operation is in processing and you should be waiting for the answer */ if (msg.getModbusExceptionCode() != ModbusExceptionCode.ACKNOWLEDGE) { if (msg.isException()) throw new ModbusProtocolException(msg.getModbusExceptionCode()); return msg; } } catch (ModbusNumberException mne) { Modbus.log().warning(mne.getLocalizedMessage()); } } while (System.currentTimeMillis() - requestTime < getConnection().getReadTimeout()); /* * throw an exception if there is a response timeout */ throw new ModbusIOException("Response timeout."); } else { /* return because slaves do not respond broadcast requests */ broadcastResponse.setFunction(request.getFunction()); return broadcastResponse; } } catch (ModbusIOException mioe) { disconnect(); throw mioe; } }
java
synchronized public ModbusResponse processRequest(ModbusRequest request) throws ModbusProtocolException, ModbusIOException { try { sendRequest(request); if (request.getServerAddress() != Modbus.BROADCAST_ID) { do { try { ModbusResponse msg = (ModbusResponse) readResponse(request); request.validateResponse(msg); /* * if you have received an ACKNOWLEDGE, * it means that operation is in processing and you should be waiting for the answer */ if (msg.getModbusExceptionCode() != ModbusExceptionCode.ACKNOWLEDGE) { if (msg.isException()) throw new ModbusProtocolException(msg.getModbusExceptionCode()); return msg; } } catch (ModbusNumberException mne) { Modbus.log().warning(mne.getLocalizedMessage()); } } while (System.currentTimeMillis() - requestTime < getConnection().getReadTimeout()); /* * throw an exception if there is a response timeout */ throw new ModbusIOException("Response timeout."); } else { /* return because slaves do not respond broadcast requests */ broadcastResponse.setFunction(request.getFunction()); return broadcastResponse; } } catch (ModbusIOException mioe) { disconnect(); throw mioe; } }
[ "synchronized", "public", "ModbusResponse", "processRequest", "(", "ModbusRequest", "request", ")", "throws", "ModbusProtocolException", ",", "ModbusIOException", "{", "try", "{", "sendRequest", "(", "request", ")", ";", "if", "(", "request", ".", "getServerAddress", ...
this function allows you to process your own ModbusRequest. Each request class has a compliant response class for instance ReadHoldingRegistersRequest and ReadHoldingRegistersResponse. If you process an instance of ReadHoldingRegistersRequest this function exactly either returns a ReadHoldingRegistersResponse instance or throws an exception. @param request an instance of ModbusRequest. @return an instance of ModbusResponse. @throws ModbusProtocolException @throws ModbusIOException @see ModbusRequestFactory @see ModbusRequest @see ModbusResponse @see com.intelligt.modbus.jlibmodbus.msg.request @see com.intelligt.modbus.jlibmodbus.msg.request
[ "this", "function", "allows", "you", "to", "process", "your", "own", "ModbusRequest", ".", "Each", "request", "class", "has", "a", "compliant", "response", "class", "for", "instance", "ReadHoldingRegistersRequest", "and", "ReadHoldingRegistersResponse", ".", "If", "...
197cb39e2649e61a6fe3cb7dc91a701d847e14be
https://github.com/kochedykov/jlibmodbus/blob/197cb39e2649e61a6fe3cb7dc91a701d847e14be/src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java#L129-L165
train
kochedykov/jlibmodbus
src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java
ModbusMaster.setResponseTimeout
public void setResponseTimeout(int timeout) { try { getConnection().setReadTimeout(timeout); } catch (Exception e) { Modbus.log().warning(e.getLocalizedMessage()); } }
java
public void setResponseTimeout(int timeout) { try { getConnection().setReadTimeout(timeout); } catch (Exception e) { Modbus.log().warning(e.getLocalizedMessage()); } }
[ "public", "void", "setResponseTimeout", "(", "int", "timeout", ")", "{", "try", "{", "getConnection", "(", ")", ".", "setReadTimeout", "(", "timeout", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "Modbus", ".", "log", "(", ")", ".", "warnin...
ModbusMaster will block for only this amount of time. If the timeout expires, a ModbusTransportException is raised, though the ModbusMaster is still valid. @param timeout the specified timeout, in milliseconds.
[ "ModbusMaster", "will", "block", "for", "only", "this", "amount", "of", "time", ".", "If", "the", "timeout", "expires", "a", "ModbusTransportException", "is", "raised", "though", "the", "ModbusMaster", "is", "still", "valid", "." ]
197cb39e2649e61a6fe3cb7dc91a701d847e14be
https://github.com/kochedykov/jlibmodbus/blob/197cb39e2649e61a6fe3cb7dc91a701d847e14be/src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java#L173-L179
train
kochedykov/jlibmodbus
src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java
ModbusMaster.readHoldingRegisters
final public int[] readHoldingRegisters(int serverAddress, int startAddress, int quantity) throws ModbusProtocolException, ModbusNumberException, ModbusIOException { ModbusRequest request = ModbusRequestBuilder.getInstance().buildReadHoldingRegisters(serverAddress, startAddress, quantity); ReadHoldingRegistersResponse response = (ReadHoldingRegistersResponse) processRequest(request); return response.getRegisters(); }
java
final public int[] readHoldingRegisters(int serverAddress, int startAddress, int quantity) throws ModbusProtocolException, ModbusNumberException, ModbusIOException { ModbusRequest request = ModbusRequestBuilder.getInstance().buildReadHoldingRegisters(serverAddress, startAddress, quantity); ReadHoldingRegistersResponse response = (ReadHoldingRegistersResponse) processRequest(request); return response.getRegisters(); }
[ "final", "public", "int", "[", "]", "readHoldingRegisters", "(", "int", "serverAddress", ",", "int", "startAddress", ",", "int", "quantity", ")", "throws", "ModbusProtocolException", ",", "ModbusNumberException", ",", "ModbusIOException", "{", "ModbusRequest", "reques...
This function code is used to read the contents of a contiguous block of holding registers in a remote device. The Request PDU specifies the starting register address and the number of registers. In the PDU Registers are addressed starting at zero. Therefore registers numbered 1-16 are addressed as 0-15. @param serverAddress a slave address @param startAddress starting register address @param quantity the number of registers @return the register data @throws ModbusProtocolException if modbus-exception is received @throws ModbusNumberException if response is invalid @throws ModbusIOException if remote slave is unavailable
[ "This", "function", "code", "is", "used", "to", "read", "the", "contents", "of", "a", "contiguous", "block", "of", "holding", "registers", "in", "a", "remote", "device", ".", "The", "Request", "PDU", "specifies", "the", "starting", "register", "address", "an...
197cb39e2649e61a6fe3cb7dc91a701d847e14be
https://github.com/kochedykov/jlibmodbus/blob/197cb39e2649e61a6fe3cb7dc91a701d847e14be/src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java#L195-L200
train
kochedykov/jlibmodbus
src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java
ModbusMaster.readInputRegisters
final public int[] readInputRegisters(int serverAddress, int startAddress, int quantity) throws ModbusProtocolException, ModbusNumberException, ModbusIOException { ModbusRequest request = ModbusRequestBuilder.getInstance().buildReadInputRegisters(serverAddress, startAddress, quantity); ReadHoldingRegistersResponse response = (ReadInputRegistersResponse) processRequest(request); return response.getRegisters(); }
java
final public int[] readInputRegisters(int serverAddress, int startAddress, int quantity) throws ModbusProtocolException, ModbusNumberException, ModbusIOException { ModbusRequest request = ModbusRequestBuilder.getInstance().buildReadInputRegisters(serverAddress, startAddress, quantity); ReadHoldingRegistersResponse response = (ReadInputRegistersResponse) processRequest(request); return response.getRegisters(); }
[ "final", "public", "int", "[", "]", "readInputRegisters", "(", "int", "serverAddress", ",", "int", "startAddress", ",", "int", "quantity", ")", "throws", "ModbusProtocolException", ",", "ModbusNumberException", ",", "ModbusIOException", "{", "ModbusRequest", "request"...
This function code is used to read from 1 to 125 contiguous input registers in a remote device. The Request PDU specifies the starting register address and the number of registers. In the PDU Registers are addressed starting at zero. Therefore input registers numbered 1-16 are addressed as 0-15. @param serverAddress a slave address @param startAddress starting register address @param quantity the number of registers @return the register data @throws ModbusProtocolException if modbus-exception is received @throws ModbusNumberException if response is invalid @throws ModbusIOException if remote slave is unavailable
[ "This", "function", "code", "is", "used", "to", "read", "from", "1", "to", "125", "contiguous", "input", "registers", "in", "a", "remote", "device", ".", "The", "Request", "PDU", "specifies", "the", "starting", "register", "address", "and", "the", "number", ...
197cb39e2649e61a6fe3cb7dc91a701d847e14be
https://github.com/kochedykov/jlibmodbus/blob/197cb39e2649e61a6fe3cb7dc91a701d847e14be/src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java#L216-L221
train
kochedykov/jlibmodbus
src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java
ModbusMaster.readCoils
final synchronized public boolean[] readCoils(int serverAddress, int startAddress, int quantity) throws ModbusProtocolException, ModbusNumberException, ModbusIOException { ModbusRequest request = ModbusRequestBuilder.getInstance().buildReadCoils(serverAddress, startAddress, quantity); ReadCoilsResponse response = (ReadCoilsResponse) processRequest(request); return response.getCoils(); }
java
final synchronized public boolean[] readCoils(int serverAddress, int startAddress, int quantity) throws ModbusProtocolException, ModbusNumberException, ModbusIOException { ModbusRequest request = ModbusRequestBuilder.getInstance().buildReadCoils(serverAddress, startAddress, quantity); ReadCoilsResponse response = (ReadCoilsResponse) processRequest(request); return response.getCoils(); }
[ "final", "synchronized", "public", "boolean", "[", "]", "readCoils", "(", "int", "serverAddress", ",", "int", "startAddress", ",", "int", "quantity", ")", "throws", "ModbusProtocolException", ",", "ModbusNumberException", ",", "ModbusIOException", "{", "ModbusRequest"...
This function code is used to read from 1 to 2000 contiguous status of coils in a remote device. The Request PDU specifies the starting address, i.e. the address of the first coil specified, and the number of coils. In the PDU Coils are addressed starting at zero. Therefore coils numbered 1-16 are addressed as 0-15. If the returned output quantity is not a multiple of eight, the remaining coils in the final boolean array will be padded with FALSE. @param serverAddress a slave address @param startAddress the address of the first coil @param quantity the number of coils @return the coils @throws ModbusProtocolException if modbus-exception is received @throws ModbusNumberException if response is invalid @throws ModbusIOException if remote slave is unavailable
[ "This", "function", "code", "is", "used", "to", "read", "from", "1", "to", "2000", "contiguous", "status", "of", "coils", "in", "a", "remote", "device", ".", "The", "Request", "PDU", "specifies", "the", "starting", "address", "i", ".", "e", ".", "the", ...
197cb39e2649e61a6fe3cb7dc91a701d847e14be
https://github.com/kochedykov/jlibmodbus/blob/197cb39e2649e61a6fe3cb7dc91a701d847e14be/src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java#L239-L244
train
kochedykov/jlibmodbus
src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java
ModbusMaster.readDiscreteInputs
final public boolean[] readDiscreteInputs(int serverAddress, int startAddress, int quantity) throws ModbusProtocolException, ModbusNumberException, ModbusIOException { ModbusRequest request = ModbusRequestBuilder.getInstance().buildReadDiscreteInputs(serverAddress, startAddress, quantity); ReadDiscreteInputsResponse response = (ReadDiscreteInputsResponse) processRequest(request); return response.getCoils(); }
java
final public boolean[] readDiscreteInputs(int serverAddress, int startAddress, int quantity) throws ModbusProtocolException, ModbusNumberException, ModbusIOException { ModbusRequest request = ModbusRequestBuilder.getInstance().buildReadDiscreteInputs(serverAddress, startAddress, quantity); ReadDiscreteInputsResponse response = (ReadDiscreteInputsResponse) processRequest(request); return response.getCoils(); }
[ "final", "public", "boolean", "[", "]", "readDiscreteInputs", "(", "int", "serverAddress", ",", "int", "startAddress", ",", "int", "quantity", ")", "throws", "ModbusProtocolException", ",", "ModbusNumberException", ",", "ModbusIOException", "{", "ModbusRequest", "requ...
This function code is used to read from 1 to 2000 contiguous status of discrete inputs in a remote device. The Request PDU specifies the starting address, i.e. the address of the first input specified, and the number of inputs. In the PDU Discrete Inputs are addressed starting at zero. Therefore Discrete inputs numbered 1-16 are addressed as 0-15. If the returned input quantity is not a multiple of eight, the remaining inputs in the final boolean array will be padded with FALSE. @param serverAddress a slave address @param startAddress the address of the first input @param quantity the number of inputs @return the discrete inputs @throws ModbusProtocolException if modbus-exception is received @throws ModbusNumberException if response is invalid @throws ModbusIOException if remote slave is unavailable
[ "This", "function", "code", "is", "used", "to", "read", "from", "1", "to", "2000", "contiguous", "status", "of", "discrete", "inputs", "in", "a", "remote", "device", ".", "The", "Request", "PDU", "specifies", "the", "starting", "address", "i", ".", "e", ...
197cb39e2649e61a6fe3cb7dc91a701d847e14be
https://github.com/kochedykov/jlibmodbus/blob/197cb39e2649e61a6fe3cb7dc91a701d847e14be/src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java#L262-L267
train
kochedykov/jlibmodbus
src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java
ModbusMaster.writeSingleRegister
final public void writeSingleRegister(int serverAddress, int startAddress, int register) throws ModbusProtocolException, ModbusNumberException, ModbusIOException { processRequest(ModbusRequestBuilder.getInstance().buildWriteSingleRegister(serverAddress, startAddress, register)); }
java
final public void writeSingleRegister(int serverAddress, int startAddress, int register) throws ModbusProtocolException, ModbusNumberException, ModbusIOException { processRequest(ModbusRequestBuilder.getInstance().buildWriteSingleRegister(serverAddress, startAddress, register)); }
[ "final", "public", "void", "writeSingleRegister", "(", "int", "serverAddress", ",", "int", "startAddress", ",", "int", "register", ")", "throws", "ModbusProtocolException", ",", "ModbusNumberException", ",", "ModbusIOException", "{", "processRequest", "(", "ModbusReques...
This function code is used to write a single holding register in a remote device. The Request PDU specifies the address of the register to be written. Registers are addressed starting at zero. Therefore register numbered 1 is addressed as 0. @param serverAddress a slave address @param startAddress the address of the register to be written @param register value @throws ModbusProtocolException if modbus-exception is received @throws ModbusNumberException if response is invalid @throws ModbusIOException if remote slave is unavailable
[ "This", "function", "code", "is", "used", "to", "write", "a", "single", "holding", "register", "in", "a", "remote", "device", ".", "The", "Request", "PDU", "specifies", "the", "address", "of", "the", "register", "to", "be", "written", ".", "Registers", "ar...
197cb39e2649e61a6fe3cb7dc91a701d847e14be
https://github.com/kochedykov/jlibmodbus/blob/197cb39e2649e61a6fe3cb7dc91a701d847e14be/src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java#L300-L303
train
kochedykov/jlibmodbus
src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java
ModbusMaster.readWriteMultipleRegisters
final public int[] readWriteMultipleRegisters(int serverAddress, int readAddress, int readQuantity, int writeAddress, int[] registers) throws ModbusProtocolException, ModbusNumberException, ModbusIOException { ModbusRequest request = ModbusRequestBuilder.getInstance().buildReadWriteMultipleRegisters(serverAddress, readAddress, readQuantity, writeAddress, registers); ReadWriteMultipleRegistersResponse response = (ReadWriteMultipleRegistersResponse) processRequest(request); return response.getRegisters(); }
java
final public int[] readWriteMultipleRegisters(int serverAddress, int readAddress, int readQuantity, int writeAddress, int[] registers) throws ModbusProtocolException, ModbusNumberException, ModbusIOException { ModbusRequest request = ModbusRequestBuilder.getInstance().buildReadWriteMultipleRegisters(serverAddress, readAddress, readQuantity, writeAddress, registers); ReadWriteMultipleRegistersResponse response = (ReadWriteMultipleRegistersResponse) processRequest(request); return response.getRegisters(); }
[ "final", "public", "int", "[", "]", "readWriteMultipleRegisters", "(", "int", "serverAddress", ",", "int", "readAddress", ",", "int", "readQuantity", ",", "int", "writeAddress", ",", "int", "[", "]", "registers", ")", "throws", "ModbusProtocolException", ",", "M...
This function code performs a combination of one read operation and one write operation in a single MODBUS transaction. The write operation is performed before the read. Holding registers are addressed starting at zero. Therefore holding registers 1-16 are addressed in the PDU as 0-15. The request specifies the starting address and number of holding registers to be read as well as the starting address, number of holding registers, and the data to be written. @param serverAddress a slave address @param readAddress the address of the registers to be read @param readQuantity the number of registers to be read @param writeAddress the address of the registers to be written @param registers the number of registers to be written @return the register value @throws ModbusProtocolException if modbus-exception is received @throws ModbusNumberException if response is invalid @throws ModbusIOException if remote slave is unavailable
[ "This", "function", "code", "performs", "a", "combination", "of", "one", "read", "operation", "and", "one", "write", "operation", "in", "a", "single", "MODBUS", "transaction", ".", "The", "write", "operation", "is", "performed", "before", "the", "read", ".", ...
197cb39e2649e61a6fe3cb7dc91a701d847e14be
https://github.com/kochedykov/jlibmodbus/blob/197cb39e2649e61a6fe3cb7dc91a701d847e14be/src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java#L361-L366
train
kochedykov/jlibmodbus
src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java
ModbusMaster.readFileRecord
final public ModbusFileRecord[] readFileRecord(int serverAddress, ModbusFileRecord[] records) throws ModbusProtocolException, ModbusNumberException, ModbusIOException { ModbusRequest request = ModbusRequestBuilder.getInstance().buildReadFileRecord(serverAddress, records); ReadFileRecordResponse response = (ReadFileRecordResponse) processRequest(request); return response.getFileRecords(); }
java
final public ModbusFileRecord[] readFileRecord(int serverAddress, ModbusFileRecord[] records) throws ModbusProtocolException, ModbusNumberException, ModbusIOException { ModbusRequest request = ModbusRequestBuilder.getInstance().buildReadFileRecord(serverAddress, records); ReadFileRecordResponse response = (ReadFileRecordResponse) processRequest(request); return response.getFileRecords(); }
[ "final", "public", "ModbusFileRecord", "[", "]", "readFileRecord", "(", "int", "serverAddress", ",", "ModbusFileRecord", "[", "]", "records", ")", "throws", "ModbusProtocolException", ",", "ModbusNumberException", ",", "ModbusIOException", "{", "ModbusRequest", "request...
This function code is used to perform a file record read. A file is an organization of records. Each file contains 10000 records, addressed 0000 to 9999 decimal or 0X0000 to 0X270F. For example, record 12 is addressed as 12. The function can read multiple groups of references. @param serverAddress a slave address @param records array of ModbusFileRecord @return array of ModbusFileRecord has been read @throws ModbusProtocolException if modbus-exception is received @throws ModbusNumberException if response is invalid @throws ModbusIOException if remote slave is unavailable
[ "This", "function", "code", "is", "used", "to", "perform", "a", "file", "record", "read", ".", "A", "file", "is", "an", "organization", "of", "records", ".", "Each", "file", "contains", "10000", "records", "addressed", "0000", "to", "9999", "decimal", "or"...
197cb39e2649e61a6fe3cb7dc91a701d847e14be
https://github.com/kochedykov/jlibmodbus/blob/197cb39e2649e61a6fe3cb7dc91a701d847e14be/src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java#L403-L408
train
kochedykov/jlibmodbus
src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java
ModbusMaster.writeFileRecord
final public void writeFileRecord(int serverAddress, ModbusFileRecord record) throws ModbusProtocolException, ModbusNumberException, ModbusIOException { processRequest(ModbusRequestBuilder.getInstance().buildWriteFileRecord(serverAddress, record)); }
java
final public void writeFileRecord(int serverAddress, ModbusFileRecord record) throws ModbusProtocolException, ModbusNumberException, ModbusIOException { processRequest(ModbusRequestBuilder.getInstance().buildWriteFileRecord(serverAddress, record)); }
[ "final", "public", "void", "writeFileRecord", "(", "int", "serverAddress", ",", "ModbusFileRecord", "record", ")", "throws", "ModbusProtocolException", ",", "ModbusNumberException", ",", "ModbusIOException", "{", "processRequest", "(", "ModbusRequestBuilder", ".", "getIns...
This function code is used to perform a file record write. All Request Data Lengths are provided in terms of number of bytes and all Record Lengths are provided in terms of the number of 16-bit words. A file is an organization of records. Each file contains 10000 records, addressed 0000 to 9999 decimal or 0X0000 to 0X270F. For example, record 12 is addressed as 12. The function can write multiple groups of references. @param serverAddress a server address @param record the ModbusFileRecord to be written @throws ModbusProtocolException if modbus-exception is received @throws ModbusNumberException if response is invalid @throws ModbusIOException if remote slave is unavailable
[ "This", "function", "code", "is", "used", "to", "perform", "a", "file", "record", "write", ".", "All", "Request", "Data", "Lengths", "are", "provided", "in", "terms", "of", "number", "of", "bytes", "and", "all", "Record", "Lengths", "are", "provided", "in"...
197cb39e2649e61a6fe3cb7dc91a701d847e14be
https://github.com/kochedykov/jlibmodbus/blob/197cb39e2649e61a6fe3cb7dc91a701d847e14be/src/com/intelligt/modbus/jlibmodbus/master/ModbusMaster.java#L424-L427
train
kochedykov/jlibmodbus
src/com/intelligt/modbus/jlibmodbus/Modbus.java
Modbus.setLogLevel
static public void setLogLevel(LogLevel level) { logLevel = level; log.setLevel(level.value()); for (Handler handler : log.getHandlers()) { handler.setLevel(level.value()); } }
java
static public void setLogLevel(LogLevel level) { logLevel = level; log.setLevel(level.value()); for (Handler handler : log.getHandlers()) { handler.setLevel(level.value()); } }
[ "static", "public", "void", "setLogLevel", "(", "LogLevel", "level", ")", "{", "logLevel", "=", "level", ";", "log", ".", "setLevel", "(", "level", ".", "value", "(", ")", ")", ";", "for", "(", "Handler", "handler", ":", "log", ".", "getHandlers", "(",...
changes the log level for all loggers used @param level - LogLevel instance @see Modbus.LogLevel
[ "changes", "the", "log", "level", "for", "all", "loggers", "used" ]
197cb39e2649e61a6fe3cb7dc91a701d847e14be
https://github.com/kochedykov/jlibmodbus/blob/197cb39e2649e61a6fe3cb7dc91a701d847e14be/src/com/intelligt/modbus/jlibmodbus/Modbus.java#L127-L133
train
kochedykov/jlibmodbus
src/com/intelligt/modbus/jlibmodbus/Modbus.java
Modbus.checkServerAddress
static public boolean checkServerAddress(int serverAddress) { /* * hook for server address is equals zero: * some of modbus tcp slaves sets the UnitId value to zero, not ignoring value in this field. */ switch (serverAddress) { case 0x00: //Modbus.log().info("Broadcast message"); return true; case 0xFF: //Modbus.log().info("Using 0xFF ModbusTCP default slave id"); return true; default: return !(serverAddress < Modbus.MIN_SERVER_ADDRESS || serverAddress > Modbus.MAX_SERVER_ADDRESS); } }
java
static public boolean checkServerAddress(int serverAddress) { /* * hook for server address is equals zero: * some of modbus tcp slaves sets the UnitId value to zero, not ignoring value in this field. */ switch (serverAddress) { case 0x00: //Modbus.log().info("Broadcast message"); return true; case 0xFF: //Modbus.log().info("Using 0xFF ModbusTCP default slave id"); return true; default: return !(serverAddress < Modbus.MIN_SERVER_ADDRESS || serverAddress > Modbus.MAX_SERVER_ADDRESS); } }
[ "static", "public", "boolean", "checkServerAddress", "(", "int", "serverAddress", ")", "{", "/*\n * hook for server address is equals zero:\n * some of modbus tcp slaves sets the UnitId value to zero, not ignoring value in this field.\n */", "switch", "(", "serverAddress...
validates address of server @param serverAddress - The modbus server address @return "true" if serverAddress is correct, else "false".
[ "validates", "address", "of", "server" ]
197cb39e2649e61a6fe3cb7dc91a701d847e14be
https://github.com/kochedykov/jlibmodbus/blob/197cb39e2649e61a6fe3cb7dc91a701d847e14be/src/com/intelligt/modbus/jlibmodbus/Modbus.java#L174-L189
train
kochedykov/jlibmodbus
src/com/intelligt/modbus/jlibmodbus/net/stream/base/ModbusInputStream.java
ModbusInputStream.readShortBE
public int readShortBE() throws IOException { int h = read(); int l = read(); if (-1 == h || -1 == l) return -1; return DataUtils.toShort(h, l); }
java
public int readShortBE() throws IOException { int h = read(); int l = read(); if (-1 == h || -1 == l) return -1; return DataUtils.toShort(h, l); }
[ "public", "int", "readShortBE", "(", ")", "throws", "IOException", "{", "int", "h", "=", "read", "(", ")", ";", "int", "l", "=", "read", "(", ")", ";", "if", "(", "-", "1", "==", "h", "||", "-", "1", "==", "l", ")", "return", "-", "1", ";", ...
read two bytes in Big Endian Byte Order @return 16-bit value placed in first two bytes of integer value, second two bytes is equal zero. @throws IOException @see ModbusInputStream#readShortLE()
[ "read", "two", "bytes", "in", "Big", "Endian", "Byte", "Order" ]
197cb39e2649e61a6fe3cb7dc91a701d847e14be
https://github.com/kochedykov/jlibmodbus/blob/197cb39e2649e61a6fe3cb7dc91a701d847e14be/src/com/intelligt/modbus/jlibmodbus/net/stream/base/ModbusInputStream.java#L67-L73
train
kochedykov/jlibmodbus
src/com/intelligt/modbus/jlibmodbus/net/stream/base/ModbusInputStream.java
ModbusInputStream.readShortLE
public int readShortLE() throws IOException { int l = read(); int h = read(); if (-1 == h || -1 == l) return -1; return DataUtils.toShort(h, l); }
java
public int readShortLE() throws IOException { int l = read(); int h = read(); if (-1 == h || -1 == l) return -1; return DataUtils.toShort(h, l); }
[ "public", "int", "readShortLE", "(", ")", "throws", "IOException", "{", "int", "l", "=", "read", "(", ")", ";", "int", "h", "=", "read", "(", ")", ";", "if", "(", "-", "1", "==", "h", "||", "-", "1", "==", "l", ")", "return", "-", "1", ";", ...
read two bytes in Little Endian Byte Order @return 16-bit value placed in first two bytes of integer value, second two bytes is equal zero. @throws IOException @see ModbusInputStream#readShortBE()
[ "read", "two", "bytes", "in", "Little", "Endian", "Byte", "Order" ]
197cb39e2649e61a6fe3cb7dc91a701d847e14be
https://github.com/kochedykov/jlibmodbus/blob/197cb39e2649e61a6fe3cb7dc91a701d847e14be/src/com/intelligt/modbus/jlibmodbus/net/stream/base/ModbusInputStream.java#L82-L88
train
AzureAD/azure-activedirectory-library-for-java
src/main/java/com/microsoft/aad/adal4j/AuthenticationContext.java
AuthenticationContext.acquireToken
public Future<AuthenticationResult> acquireToken(final String resource, final UserAssertion userAssertion, final ClientCredential credential, final AuthenticationCallback callback) { this.validateOnBehalfOfRequestInput(resource, userAssertion, credential, true); final ClientAuthentication clientAuth = new ClientSecretPost( new ClientID(credential.getClientId()), new Secret( credential.getClientSecret())); return acquireTokenOnBehalfOf(resource, userAssertion, clientAuth, callback); }
java
public Future<AuthenticationResult> acquireToken(final String resource, final UserAssertion userAssertion, final ClientCredential credential, final AuthenticationCallback callback) { this.validateOnBehalfOfRequestInput(resource, userAssertion, credential, true); final ClientAuthentication clientAuth = new ClientSecretPost( new ClientID(credential.getClientId()), new Secret( credential.getClientSecret())); return acquireTokenOnBehalfOf(resource, userAssertion, clientAuth, callback); }
[ "public", "Future", "<", "AuthenticationResult", ">", "acquireToken", "(", "final", "String", "resource", ",", "final", "UserAssertion", "userAssertion", ",", "final", "ClientCredential", "credential", ",", "final", "AuthenticationCallback", "callback", ")", "{", "thi...
Acquires an access token from the authority on behalf of a user. It requires using a user token previously received. @param resource Identifier of the target resource that is the recipient of the requested token. @param userAssertion userAssertion to use as Authorization grant @param credential The client credential to use for token acquisition. @param callback optional callback object for non-blocking execution. @return A {@link Future} object representing the {@link AuthenticationResult} of the call. It contains Access Token and the Access Token's expiration time. Refresh Token property will be null for this overload. @throws AuthenticationException {@link AuthenticationException}
[ "Acquires", "an", "access", "token", "from", "the", "authority", "on", "behalf", "of", "a", "user", ".", "It", "requires", "using", "a", "user", "token", "previously", "received", "." ]
7f0004fee6faee5818e75623113993a267ceb1c4
https://github.com/AzureAD/azure-activedirectory-library-for-java/blob/7f0004fee6faee5818e75623113993a267ceb1c4/src/main/java/com/microsoft/aad/adal4j/AuthenticationContext.java#L266-L275
train
AzureAD/azure-activedirectory-library-for-java
src/main/java/com/microsoft/aad/adal4j/AuthenticationContext.java
AuthenticationContext.acquireToken
public Future<AuthenticationResult> acquireToken(final String resource, final UserAssertion userAssertion, final AsymmetricKeyCredential credential, final AuthenticationCallback callback) { this.validateOnBehalfOfRequestInput(resource, userAssertion, credential, true); ClientAssertion clientAssertion = JwtHelper .buildJwt(credential, this.authenticationAuthority.getSelfSignedJwtAudience()); final ClientAuthentication clientAuth = createClientAuthFromClientAssertion(clientAssertion); return acquireTokenOnBehalfOf(resource, userAssertion, clientAuth, callback); }
java
public Future<AuthenticationResult> acquireToken(final String resource, final UserAssertion userAssertion, final AsymmetricKeyCredential credential, final AuthenticationCallback callback) { this.validateOnBehalfOfRequestInput(resource, userAssertion, credential, true); ClientAssertion clientAssertion = JwtHelper .buildJwt(credential, this.authenticationAuthority.getSelfSignedJwtAudience()); final ClientAuthentication clientAuth = createClientAuthFromClientAssertion(clientAssertion); return acquireTokenOnBehalfOf(resource, userAssertion, clientAuth, callback); }
[ "public", "Future", "<", "AuthenticationResult", ">", "acquireToken", "(", "final", "String", "resource", ",", "final", "UserAssertion", "userAssertion", ",", "final", "AsymmetricKeyCredential", "credential", ",", "final", "AuthenticationCallback", "callback", ")", "{",...
Acquires an access token from the authority on behalf of a user. It requires using a user token previously received. Uses certificate to authenticate client. @param resource Identifier of the target resource that is the recipient of the requested token. @param userAssertion userAssertion to use as Authorization grant @param credential The certificate based client credential to use for token acquisition. @param callback optional callback object for non-blocking execution. @return A {@link Future} object representing the {@link AuthenticationResult} of the call. It contains Access Token and the Access Token's expiration time. Refresh Token property will be null for this overload. @throws AuthenticationException {@link AuthenticationException}
[ "Acquires", "an", "access", "token", "from", "the", "authority", "on", "behalf", "of", "a", "user", ".", "It", "requires", "using", "a", "user", "token", "previously", "received", ".", "Uses", "certificate", "to", "authenticate", "client", "." ]
7f0004fee6faee5818e75623113993a267ceb1c4
https://github.com/AzureAD/azure-activedirectory-library-for-java/blob/7f0004fee6faee5818e75623113993a267ceb1c4/src/main/java/com/microsoft/aad/adal4j/AuthenticationContext.java#L297-L307
train
AzureAD/azure-activedirectory-library-for-java
src/main/java/com/microsoft/aad/adal4j/AuthenticationContext.java
AuthenticationContext.acquireDeviceCode
public Future<DeviceCode> acquireDeviceCode(final String clientId, final String resource, final AuthenticationCallback<DeviceCode> callback) { validateDeviceCodeRequestInput(clientId, resource); return service.submit( new AcquireDeviceCodeCallable(this, clientId, resource, callback)); }
java
public Future<DeviceCode> acquireDeviceCode(final String clientId, final String resource, final AuthenticationCallback<DeviceCode> callback) { validateDeviceCodeRequestInput(clientId, resource); return service.submit( new AcquireDeviceCodeCallable(this, clientId, resource, callback)); }
[ "public", "Future", "<", "DeviceCode", ">", "acquireDeviceCode", "(", "final", "String", "clientId", ",", "final", "String", "resource", ",", "final", "AuthenticationCallback", "<", "DeviceCode", ">", "callback", ")", "{", "validateDeviceCodeRequestInput", "(", "cli...
Acquires a device code from the authority @param clientId Identifier of the client requesting the token @param resource Identifier of the target resource that is the recipient of the requested token. @param callback optional callback object for non-blocking execution. @return A {@link Future} object representing the {@link DeviceCode} of the call. It contains device code, user code, its expiration date, message which should be displayed to the user. @throws AuthenticationException thrown if the device code is not acquired successfully
[ "Acquires", "a", "device", "code", "from", "the", "authority" ]
7f0004fee6faee5818e75623113993a267ceb1c4
https://github.com/AzureAD/azure-activedirectory-library-for-java/blob/7f0004fee6faee5818e75623113993a267ceb1c4/src/main/java/com/microsoft/aad/adal4j/AuthenticationContext.java#L620-L625
train
AzureAD/azure-activedirectory-library-for-java
src/main/java/com/microsoft/aad/adal4j/AuthenticationContext.java
AuthenticationContext.acquireTokenByDeviceCode
public Future<AuthenticationResult> acquireTokenByDeviceCode( final DeviceCode deviceCode, final AuthenticationCallback callback) throws AuthenticationException { final ClientAuthentication clientAuth = new ClientAuthenticationPost( ClientAuthenticationMethod.NONE, new ClientID(deviceCode.getClientId())); this.validateDeviceCodeRequestInput(deviceCode, clientAuth, deviceCode.getResource()); final AdalDeviceCodeAuthorizationGrant deviceCodeGrant = new AdalDeviceCodeAuthorizationGrant(deviceCode, deviceCode.getResource()); return this.acquireToken(deviceCodeGrant, clientAuth, callback); }
java
public Future<AuthenticationResult> acquireTokenByDeviceCode( final DeviceCode deviceCode, final AuthenticationCallback callback) throws AuthenticationException { final ClientAuthentication clientAuth = new ClientAuthenticationPost( ClientAuthenticationMethod.NONE, new ClientID(deviceCode.getClientId())); this.validateDeviceCodeRequestInput(deviceCode, clientAuth, deviceCode.getResource()); final AdalDeviceCodeAuthorizationGrant deviceCodeGrant = new AdalDeviceCodeAuthorizationGrant(deviceCode, deviceCode.getResource()); return this.acquireToken(deviceCodeGrant, clientAuth, callback); }
[ "public", "Future", "<", "AuthenticationResult", ">", "acquireTokenByDeviceCode", "(", "final", "DeviceCode", "deviceCode", ",", "final", "AuthenticationCallback", "callback", ")", "throws", "AuthenticationException", "{", "final", "ClientAuthentication", "clientAuth", "=",...
Acquires security token from the authority using an device code previously received. @param deviceCode The device code result received from calling acquireDeviceCode. @param callback optional callback object for non-blocking execution. @return A {@link Future} object representing the {@link AuthenticationResult} of the call. It contains AccessToken, Refresh Token and the Access Token's expiration time. @throws AuthenticationException thrown if authorization is pending or another error occurred. If the errorCode of the exception is AdalErrorCode.AUTHORIZATION_PENDING, the call needs to be retried until the AccessToken is returned. DeviceCode.interval - The minimum amount of time in seconds that the client SHOULD wait between polling requests to the token endpoin
[ "Acquires", "security", "token", "from", "the", "authority", "using", "an", "device", "code", "previously", "received", "." ]
7f0004fee6faee5818e75623113993a267ceb1c4
https://github.com/AzureAD/azure-activedirectory-library-for-java/blob/7f0004fee6faee5818e75623113993a267ceb1c4/src/main/java/com/microsoft/aad/adal4j/AuthenticationContext.java#L640-L652
train
AzureAD/azure-activedirectory-library-for-java
src/main/java/com/microsoft/aad/adal4j/AuthenticationContext.java
AuthenticationContext.acquireTokenByRefreshToken
public Future<AuthenticationResult> acquireTokenByRefreshToken( final String refreshToken, final String clientId, final String resource, final AuthenticationCallback callback) { final ClientAuthentication clientAuth = new ClientAuthenticationPost( ClientAuthenticationMethod.NONE, new ClientID(clientId)); final AdalOAuthAuthorizationGrant authGrant = new AdalOAuthAuthorizationGrant( new RefreshTokenGrant(new RefreshToken(refreshToken)), resource); return this.acquireToken(authGrant, clientAuth, callback); }
java
public Future<AuthenticationResult> acquireTokenByRefreshToken( final String refreshToken, final String clientId, final String resource, final AuthenticationCallback callback) { final ClientAuthentication clientAuth = new ClientAuthenticationPost( ClientAuthenticationMethod.NONE, new ClientID(clientId)); final AdalOAuthAuthorizationGrant authGrant = new AdalOAuthAuthorizationGrant( new RefreshTokenGrant(new RefreshToken(refreshToken)), resource); return this.acquireToken(authGrant, clientAuth, callback); }
[ "public", "Future", "<", "AuthenticationResult", ">", "acquireTokenByRefreshToken", "(", "final", "String", "refreshToken", ",", "final", "String", "clientId", ",", "final", "String", "resource", ",", "final", "AuthenticationCallback", "callback", ")", "{", "final", ...
Acquires a security token from the authority using a Refresh Token previously received. This method is suitable for the daemon OAuth2 flow when a client secret is not possible. @param refreshToken Refresh Token to use in the refresh flow. @param clientId Name or ID of the client requesting the token. @param resource Identifier of the target resource that is the recipient of the requested token. If null, token is requested for the same resource refresh token was originally issued for. If passed, resource should match the original resource used to acquire refresh token unless token service supports refresh token for multiple resources. @param callback optional callback object for non-blocking execution. @return A {@link Future} object representing the {@link AuthenticationResult} of the call. It contains Access Token, Refresh Token and the Access Token's expiration time. @throws AuthenticationException thrown if the access token is not refreshed successfully
[ "Acquires", "a", "security", "token", "from", "the", "authority", "using", "a", "Refresh", "Token", "previously", "received", ".", "This", "method", "is", "suitable", "for", "the", "daemon", "OAuth2", "flow", "when", "a", "client", "secret", "is", "not", "po...
7f0004fee6faee5818e75623113993a267ceb1c4
https://github.com/AzureAD/azure-activedirectory-library-for-java/blob/7f0004fee6faee5818e75623113993a267ceb1c4/src/main/java/com/microsoft/aad/adal4j/AuthenticationContext.java#L888-L897
train
AzureAD/azure-activedirectory-library-for-java
src/main/java/com/microsoft/aad/adal4j/AdalDeviceCodeAuthorizationGrant.java
AdalDeviceCodeAuthorizationGrant.toParameters
@Override public Map<String, List<String>> toParameters() { final Map<String, List<String>> outParams = new LinkedHashMap<>(); outParams.put("resource", Collections.singletonList(resource)); outParams.put("grant_type", Collections.singletonList(GRANT_TYPE) ); outParams.put("code", Collections.singletonList(deviceCode.getDeviceCode())); return outParams; }
java
@Override public Map<String, List<String>> toParameters() { final Map<String, List<String>> outParams = new LinkedHashMap<>(); outParams.put("resource", Collections.singletonList(resource)); outParams.put("grant_type", Collections.singletonList(GRANT_TYPE) ); outParams.put("code", Collections.singletonList(deviceCode.getDeviceCode())); return outParams; }
[ "@", "Override", "public", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "toParameters", "(", ")", "{", "final", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "outParams", "=", "new", "LinkedHashMap", "<>", "(", ")", ";", ...
Converts the device code grant to a map of HTTP paramters. @return The map with HTTP parameters.
[ "Converts", "the", "device", "code", "grant", "to", "a", "map", "of", "HTTP", "paramters", "." ]
7f0004fee6faee5818e75623113993a267ceb1c4
https://github.com/AzureAD/azure-activedirectory-library-for-java/blob/7f0004fee6faee5818e75623113993a267ceb1c4/src/main/java/com/microsoft/aad/adal4j/AdalDeviceCodeAuthorizationGrant.java#L63-L71
train
AzureAD/azure-activedirectory-library-for-java
src/samples/web-app-samples-for-adal4j/src/main/java/com/microsoft/aad/adal4jsample/HttpClientHelper.java
HttpClientHelper.processBadRespStr
public static JSONObject processBadRespStr(int responseCode, String responseMsg) throws JSONException { JSONObject response = new JSONObject(); response.put("responseCode", responseCode); if (responseMsg.equalsIgnoreCase("")) { // good response is empty string response.put("responseMsg", ""); } else { // bad response is json string JSONObject errorObject = new JSONObject(responseMsg).optJSONObject("odata.error"); String errorCode = errorObject.optString("code"); String errorMsg = errorObject.optJSONObject("message").optString("value"); response.put("responseCode", responseCode); response.put("errorCode", errorCode); response.put("errorMsg", errorMsg); } return response; }
java
public static JSONObject processBadRespStr(int responseCode, String responseMsg) throws JSONException { JSONObject response = new JSONObject(); response.put("responseCode", responseCode); if (responseMsg.equalsIgnoreCase("")) { // good response is empty string response.put("responseMsg", ""); } else { // bad response is json string JSONObject errorObject = new JSONObject(responseMsg).optJSONObject("odata.error"); String errorCode = errorObject.optString("code"); String errorMsg = errorObject.optJSONObject("message").optString("value"); response.put("responseCode", responseCode); response.put("errorCode", errorCode); response.put("errorMsg", errorMsg); } return response; }
[ "public", "static", "JSONObject", "processBadRespStr", "(", "int", "responseCode", ",", "String", "responseMsg", ")", "throws", "JSONException", "{", "JSONObject", "response", "=", "new", "JSONObject", "(", ")", ";", "response", ".", "put", "(", "\"responseCode\""...
for good response @param responseCode @param responseMsg @return @throws JSONException
[ "for", "good", "response" ]
7f0004fee6faee5818e75623113993a267ceb1c4
https://github.com/AzureAD/azure-activedirectory-library-for-java/blob/7f0004fee6faee5818e75623113993a267ceb1c4/src/samples/web-app-samples-for-adal4j/src/main/java/com/microsoft/aad/adal4jsample/HttpClientHelper.java#L153-L170
train
AzureAD/azure-activedirectory-library-for-java
src/main/java/com/microsoft/aad/adal4j/JwtHelper.java
JwtHelper.buildJwt
static ClientAssertion buildJwt(final AsymmetricKeyCredential credential, final String jwtAudience) throws AuthenticationException { if (credential == null) { throw new IllegalArgumentException("credential is null"); } final long time = System.currentTimeMillis(); final JWTClaimsSet claimsSet = new JWTClaimsSet.Builder() .audience(Collections.singletonList(jwtAudience)) .issuer(credential.getClientId()) .jwtID(UUID.randomUUID().toString()) .notBeforeTime(new Date(time)) .expirationTime(new Date(time + AuthenticationConstants.AAD_JWT_TOKEN_LIFETIME_SECONDS * 1000)) .subject(credential.getClientId()) .build(); SignedJWT jwt; try { JWSHeader.Builder builder = new Builder(JWSAlgorithm.RS256); List<Base64> certs = new ArrayList<Base64>(); certs.add(new Base64(credential.getPublicCertificate())); builder.x509CertChain(certs); builder.x509CertThumbprint(new Base64URL(credential .getPublicCertificateHash())); jwt = new SignedJWT(builder.build(), claimsSet); final RSASSASigner signer = new RSASSASigner(credential.getKey()); jwt.sign(signer); } catch (final Exception e) { throw new AuthenticationException(e); } return new ClientAssertion(jwt.serialize()); }
java
static ClientAssertion buildJwt(final AsymmetricKeyCredential credential, final String jwtAudience) throws AuthenticationException { if (credential == null) { throw new IllegalArgumentException("credential is null"); } final long time = System.currentTimeMillis(); final JWTClaimsSet claimsSet = new JWTClaimsSet.Builder() .audience(Collections.singletonList(jwtAudience)) .issuer(credential.getClientId()) .jwtID(UUID.randomUUID().toString()) .notBeforeTime(new Date(time)) .expirationTime(new Date(time + AuthenticationConstants.AAD_JWT_TOKEN_LIFETIME_SECONDS * 1000)) .subject(credential.getClientId()) .build(); SignedJWT jwt; try { JWSHeader.Builder builder = new Builder(JWSAlgorithm.RS256); List<Base64> certs = new ArrayList<Base64>(); certs.add(new Base64(credential.getPublicCertificate())); builder.x509CertChain(certs); builder.x509CertThumbprint(new Base64URL(credential .getPublicCertificateHash())); jwt = new SignedJWT(builder.build(), claimsSet); final RSASSASigner signer = new RSASSASigner(credential.getKey()); jwt.sign(signer); } catch (final Exception e) { throw new AuthenticationException(e); } return new ClientAssertion(jwt.serialize()); }
[ "static", "ClientAssertion", "buildJwt", "(", "final", "AsymmetricKeyCredential", "credential", ",", "final", "String", "jwtAudience", ")", "throws", "AuthenticationException", "{", "if", "(", "credential", "==", "null", ")", "{", "throw", "new", "IllegalArgumentExcep...
Builds JWT object. @param credential @return @throws AuthenticationException
[ "Builds", "JWT", "object", "." ]
7f0004fee6faee5818e75623113993a267ceb1c4
https://github.com/AzureAD/azure-activedirectory-library-for-java/blob/7f0004fee6faee5818e75623113993a267ceb1c4/src/main/java/com/microsoft/aad/adal4j/JwtHelper.java#L52-L89
train
AzureAD/azure-activedirectory-library-for-java
src/samples/web-app-samples-for-adal4j/src/main/java/com/microsoft/aad/adal4jsample/JSONHelper.java
JSONHelper.fetchDirectoryObjectJSONArray
public static JSONArray fetchDirectoryObjectJSONArray(JSONObject jsonObject) throws Exception { JSONArray jsonArray = new JSONArray(); jsonArray = jsonObject.optJSONObject("responseMsg").optJSONArray("value"); return jsonArray; }
java
public static JSONArray fetchDirectoryObjectJSONArray(JSONObject jsonObject) throws Exception { JSONArray jsonArray = new JSONArray(); jsonArray = jsonObject.optJSONObject("responseMsg").optJSONArray("value"); return jsonArray; }
[ "public", "static", "JSONArray", "fetchDirectoryObjectJSONArray", "(", "JSONObject", "jsonObject", ")", "throws", "Exception", "{", "JSONArray", "jsonArray", "=", "new", "JSONArray", "(", ")", ";", "jsonArray", "=", "jsonObject", ".", "optJSONObject", "(", "\"respon...
This method parses an JSON Array out of a collection of JSON Objects within a string. @param jSonData The JSON String that holds the collection. @return An JSON Array that would contains all the collection object. @throws Exception
[ "This", "method", "parses", "an", "JSON", "Array", "out", "of", "a", "collection", "of", "JSON", "Objects", "within", "a", "string", "." ]
7f0004fee6faee5818e75623113993a267ceb1c4
https://github.com/AzureAD/azure-activedirectory-library-for-java/blob/7f0004fee6faee5818e75623113993a267ceb1c4/src/samples/web-app-samples-for-adal4j/src/main/java/com/microsoft/aad/adal4jsample/JSONHelper.java#L63-L67
train
AzureAD/azure-activedirectory-library-for-java
src/samples/web-app-samples-for-adal4j/src/main/java/com/microsoft/aad/adal4jsample/JSONHelper.java
JSONHelper.fetchDirectoryObjectJSONObject
public static JSONObject fetchDirectoryObjectJSONObject(JSONObject jsonObject) throws Exception { JSONObject jObj = new JSONObject(); jObj = jsonObject.optJSONObject("responseMsg"); return jObj; }
java
public static JSONObject fetchDirectoryObjectJSONObject(JSONObject jsonObject) throws Exception { JSONObject jObj = new JSONObject(); jObj = jsonObject.optJSONObject("responseMsg"); return jObj; }
[ "public", "static", "JSONObject", "fetchDirectoryObjectJSONObject", "(", "JSONObject", "jsonObject", ")", "throws", "Exception", "{", "JSONObject", "jObj", "=", "new", "JSONObject", "(", ")", ";", "jObj", "=", "jsonObject", ".", "optJSONObject", "(", "\"responseMsg\...
This method parses an JSON Object out of a collection of JSON Objects within a string @param jsonObject @return An JSON Object that would contains the DirectoryObject. @throws Exception
[ "This", "method", "parses", "an", "JSON", "Object", "out", "of", "a", "collection", "of", "JSON", "Objects", "within", "a", "string" ]
7f0004fee6faee5818e75623113993a267ceb1c4
https://github.com/AzureAD/azure-activedirectory-library-for-java/blob/7f0004fee6faee5818e75623113993a267ceb1c4/src/samples/web-app-samples-for-adal4j/src/main/java/com/microsoft/aad/adal4jsample/JSONHelper.java#L77-L81
train
AzureAD/azure-activedirectory-library-for-java
src/samples/web-app-samples-for-adal4j/src/main/java/com/microsoft/aad/adal4jsample/JSONHelper.java
JSONHelper.fetchNextSkiptoken
public static String fetchNextSkiptoken(JSONObject jsonObject) throws Exception { String skipToken = ""; // Parse the skip token out of the string. skipToken = jsonObject.optJSONObject("responseMsg").optString("odata.nextLink"); if (!skipToken.equalsIgnoreCase("")) { // Remove the unnecessary prefix from the skip token. int index = skipToken.indexOf("$skiptoken=") + (new String("$skiptoken=")).length(); skipToken = skipToken.substring(index); } return skipToken; }
java
public static String fetchNextSkiptoken(JSONObject jsonObject) throws Exception { String skipToken = ""; // Parse the skip token out of the string. skipToken = jsonObject.optJSONObject("responseMsg").optString("odata.nextLink"); if (!skipToken.equalsIgnoreCase("")) { // Remove the unnecessary prefix from the skip token. int index = skipToken.indexOf("$skiptoken=") + (new String("$skiptoken=")).length(); skipToken = skipToken.substring(index); } return skipToken; }
[ "public", "static", "String", "fetchNextSkiptoken", "(", "JSONObject", "jsonObject", ")", "throws", "Exception", "{", "String", "skipToken", "=", "\"\"", ";", "// Parse the skip token out of the string.\r", "skipToken", "=", "jsonObject", ".", "optJSONObject", "(", "\"r...
This method parses the skip token from a json formatted string. @param jsonData The JSON Formatted String. @return The skipToken. @throws Exception
[ "This", "method", "parses", "the", "skip", "token", "from", "a", "json", "formatted", "string", "." ]
7f0004fee6faee5818e75623113993a267ceb1c4
https://github.com/AzureAD/azure-activedirectory-library-for-java/blob/7f0004fee6faee5818e75623113993a267ceb1c4/src/samples/web-app-samples-for-adal4j/src/main/java/com/microsoft/aad/adal4jsample/JSONHelper.java#L91-L102
train
AzureAD/azure-activedirectory-library-for-java
src/samples/web-app-samples-for-adal4j/src/main/java/com/microsoft/aad/adal4jsample/JSONHelper.java
JSONHelper.createJSONString
public static String createJSONString(HttpServletRequest request, String controller) throws Exception { JSONObject obj = new JSONObject(); try { Field[] allFields = Class.forName( "com.microsoft.windowsazure.activedirectory.sdk.graph.models." + controller).getDeclaredFields(); String[] allFieldStr = new String[allFields.length]; for (int i = 0; i < allFields.length; i++) { allFieldStr[i] = allFields[i].getName(); } List<String> allFieldStringList = Arrays.asList(allFieldStr); Enumeration<String> fields = request.getParameterNames(); while (fields.hasMoreElements()) { String fieldName = fields.nextElement(); String param = request.getParameter(fieldName); if (allFieldStringList.contains(fieldName)) { if (param == null || param.length() == 0) { if (!fieldName.equalsIgnoreCase("password")) { obj.put(fieldName, JSONObject.NULL); } } else { if (fieldName.equalsIgnoreCase("password")) { obj.put("passwordProfile", new JSONObject("{\"password\": \"" + param + "\"}")); } else { obj.put(fieldName, param); } } } } } catch (JSONException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } return obj.toString(); }
java
public static String createJSONString(HttpServletRequest request, String controller) throws Exception { JSONObject obj = new JSONObject(); try { Field[] allFields = Class.forName( "com.microsoft.windowsazure.activedirectory.sdk.graph.models." + controller).getDeclaredFields(); String[] allFieldStr = new String[allFields.length]; for (int i = 0; i < allFields.length; i++) { allFieldStr[i] = allFields[i].getName(); } List<String> allFieldStringList = Arrays.asList(allFieldStr); Enumeration<String> fields = request.getParameterNames(); while (fields.hasMoreElements()) { String fieldName = fields.nextElement(); String param = request.getParameter(fieldName); if (allFieldStringList.contains(fieldName)) { if (param == null || param.length() == 0) { if (!fieldName.equalsIgnoreCase("password")) { obj.put(fieldName, JSONObject.NULL); } } else { if (fieldName.equalsIgnoreCase("password")) { obj.put("passwordProfile", new JSONObject("{\"password\": \"" + param + "\"}")); } else { obj.put(fieldName, param); } } } } } catch (JSONException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } return obj.toString(); }
[ "public", "static", "String", "createJSONString", "(", "HttpServletRequest", "request", ",", "String", "controller", ")", "throws", "Exception", "{", "JSONObject", "obj", "=", "new", "JSONObject", "(", ")", ";", "try", "{", "Field", "[", "]", "allFields", "=",...
This method would create a string consisting of a JSON document with all the necessary elements set from the HttpServletRequest request. @param request The HttpServletRequest @return the string containing the JSON document. @throws Exception If there is any error processing the request.
[ "This", "method", "would", "create", "a", "string", "consisting", "of", "a", "JSON", "document", "with", "all", "the", "necessary", "elements", "set", "from", "the", "HttpServletRequest", "request", "." ]
7f0004fee6faee5818e75623113993a267ceb1c4
https://github.com/AzureAD/azure-activedirectory-library-for-java/blob/7f0004fee6faee5818e75623113993a267ceb1c4/src/samples/web-app-samples-for-adal4j/src/main/java/com/microsoft/aad/adal4jsample/JSONHelper.java#L136-L175
train
AzureAD/azure-activedirectory-library-for-java
src/samples/web-app-samples-for-adal4j/src/main/java/com/microsoft/aad/adal4jsample/JSONHelper.java
JSONHelper.convertJSONObjectToDirectoryObject
public static <T> void convertJSONObjectToDirectoryObject(JSONObject jsonObject, T destObject) throws Exception { // Get the list of all the field names. Field[] fieldList = destObject.getClass().getDeclaredFields(); // For all the declared field. for (int i = 0; i < fieldList.length; i++) { // If the field is of type String, that is // if it is a simple attribute. if (fieldList[i].getType().equals(String.class)) { // Invoke the corresponding set method of the destObject using // the argument taken from the jsonObject. destObject .getClass() .getMethod(String.format("set%s", WordUtils.capitalize(fieldList[i].getName())), new Class[] { String.class }) .invoke(destObject, new Object[] { jsonObject.optString(fieldList[i].getName()) }); } } }
java
public static <T> void convertJSONObjectToDirectoryObject(JSONObject jsonObject, T destObject) throws Exception { // Get the list of all the field names. Field[] fieldList = destObject.getClass().getDeclaredFields(); // For all the declared field. for (int i = 0; i < fieldList.length; i++) { // If the field is of type String, that is // if it is a simple attribute. if (fieldList[i].getType().equals(String.class)) { // Invoke the corresponding set method of the destObject using // the argument taken from the jsonObject. destObject .getClass() .getMethod(String.format("set%s", WordUtils.capitalize(fieldList[i].getName())), new Class[] { String.class }) .invoke(destObject, new Object[] { jsonObject.optString(fieldList[i].getName()) }); } } }
[ "public", "static", "<", "T", ">", "void", "convertJSONObjectToDirectoryObject", "(", "JSONObject", "jsonObject", ",", "T", "destObject", ")", "throws", "Exception", "{", "// Get the list of all the field names.\r", "Field", "[", "]", "fieldList", "=", "destObject", "...
This is a generic method that copies the simple attribute values from an argument jsonObject to an argument generic object. @param jsonObject The jsonObject from where the attributes are to be copied. @param destObject The object where the attributes should be copied into. @throws Exception Throws a Exception when the operation are unsuccessful.
[ "This", "is", "a", "generic", "method", "that", "copies", "the", "simple", "attribute", "values", "from", "an", "argument", "jsonObject", "to", "an", "argument", "generic", "object", "." ]
7f0004fee6faee5818e75623113993a267ceb1c4
https://github.com/AzureAD/azure-activedirectory-library-for-java/blob/7f0004fee6faee5818e75623113993a267ceb1c4/src/samples/web-app-samples-for-adal4j/src/main/java/com/microsoft/aad/adal4jsample/JSONHelper.java#L207-L226
train
AzureAD/azure-activedirectory-library-for-java
src/main/java/com/microsoft/aad/adal4j/AsymmetricKeyCredential.java
AsymmetricKeyCredential.getPublicCertificateHash
public String getPublicCertificateHash() throws CertificateEncodingException, NoSuchAlgorithmException { return Base64.encodeBase64String(AsymmetricKeyCredential .getHash(this.publicCertificate.getEncoded())); }
java
public String getPublicCertificateHash() throws CertificateEncodingException, NoSuchAlgorithmException { return Base64.encodeBase64String(AsymmetricKeyCredential .getHash(this.publicCertificate.getEncoded())); }
[ "public", "String", "getPublicCertificateHash", "(", ")", "throws", "CertificateEncodingException", ",", "NoSuchAlgorithmException", "{", "return", "Base64", ".", "encodeBase64String", "(", "AsymmetricKeyCredential", ".", "getHash", "(", "this", ".", "publicCertificate", ...
Base64 encoded hash of the the public certificate. @return base64 encoded string @throws CertificateEncodingException if an encoding error occurs @throws NoSuchAlgorithmException if requested algorithm is not available in the environment
[ "Base64", "encoded", "hash", "of", "the", "the", "public", "certificate", "." ]
7f0004fee6faee5818e75623113993a267ceb1c4
https://github.com/AzureAD/azure-activedirectory-library-for-java/blob/7f0004fee6faee5818e75623113993a267ceb1c4/src/main/java/com/microsoft/aad/adal4j/AsymmetricKeyCredential.java#L122-L126
train
AzureAD/azure-activedirectory-library-for-java
src/main/java/com/microsoft/aad/adal4j/DeviceCodeTokenErrorResponse.java
DeviceCodeTokenErrorResponse.isDeviceCodeError
public boolean isDeviceCodeError() { ErrorObject errorObject = getErrorObject(); if (errorObject == null) { return false; } String code = errorObject.getCode(); if (code == null) { return false; } switch (code) { case "authorization_pending": case "slow_down": case "access_denied": case "code_expired": return true; default: return false; } }
java
public boolean isDeviceCodeError() { ErrorObject errorObject = getErrorObject(); if (errorObject == null) { return false; } String code = errorObject.getCode(); if (code == null) { return false; } switch (code) { case "authorization_pending": case "slow_down": case "access_denied": case "code_expired": return true; default: return false; } }
[ "public", "boolean", "isDeviceCodeError", "(", ")", "{", "ErrorObject", "errorObject", "=", "getErrorObject", "(", ")", ";", "if", "(", "errorObject", "==", "null", ")", "{", "return", "false", ";", "}", "String", "code", "=", "errorObject", ".", "getCode", ...
Checks if is a device code error. @return true if is one of the well known device code error code, otherwise false.
[ "Checks", "if", "is", "a", "device", "code", "error", "." ]
7f0004fee6faee5818e75623113993a267ceb1c4
https://github.com/AzureAD/azure-activedirectory-library-for-java/blob/7f0004fee6faee5818e75623113993a267ceb1c4/src/main/java/com/microsoft/aad/adal4j/DeviceCodeTokenErrorResponse.java#L51-L69
train
AzureAD/azure-activedirectory-library-for-java
src/samples/web-app-samples-for-adal4j/src/main/java/com/microsoft/aad/adal4jsample/BasicFilter.java
BasicFilter.validateState
private StateData validateState(HttpSession session, String state) throws Exception { if (StringUtils.isNotEmpty(state)) { StateData stateDataInSession = removeStateFromSession(session, state); if (stateDataInSession != null) { return stateDataInSession; } } throw new Exception(FAILED_TO_VALIDATE_MESSAGE + "could not validate state"); }
java
private StateData validateState(HttpSession session, String state) throws Exception { if (StringUtils.isNotEmpty(state)) { StateData stateDataInSession = removeStateFromSession(session, state); if (stateDataInSession != null) { return stateDataInSession; } } throw new Exception(FAILED_TO_VALIDATE_MESSAGE + "could not validate state"); }
[ "private", "StateData", "validateState", "(", "HttpSession", "session", ",", "String", "state", ")", "throws", "Exception", "{", "if", "(", "StringUtils", ".", "isNotEmpty", "(", "state", ")", ")", "{", "StateData", "stateDataInSession", "=", "removeStateFromSessi...
make sure that state is stored in the session, delete it from session - should be used only once @param session @param state @throws Exception
[ "make", "sure", "that", "state", "is", "stored", "in", "the", "session", "delete", "it", "from", "session", "-", "should", "be", "used", "only", "once" ]
7f0004fee6faee5818e75623113993a267ceb1c4
https://github.com/AzureAD/azure-activedirectory-library-for-java/blob/7f0004fee6faee5818e75623113993a267ceb1c4/src/samples/web-app-samples-for-adal4j/src/main/java/com/microsoft/aad/adal4jsample/BasicFilter.java#L182-L190
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/core/LdapRdn.java
LdapRdn.getLdapEncoded
public String getLdapEncoded() { if (components.size() == 0) { throw new IndexOutOfBoundsException("No components in Rdn."); } StringBuffer sb = new StringBuffer(DEFAULT_BUFFER_SIZE); for (Iterator iter = components.values().iterator(); iter.hasNext();) { LdapRdnComponent component = (LdapRdnComponent) iter.next(); sb.append(component.encodeLdap()); if (iter.hasNext()) { sb.append("+"); } } return sb.toString(); }
java
public String getLdapEncoded() { if (components.size() == 0) { throw new IndexOutOfBoundsException("No components in Rdn."); } StringBuffer sb = new StringBuffer(DEFAULT_BUFFER_SIZE); for (Iterator iter = components.values().iterator(); iter.hasNext();) { LdapRdnComponent component = (LdapRdnComponent) iter.next(); sb.append(component.encodeLdap()); if (iter.hasNext()) { sb.append("+"); } } return sb.toString(); }
[ "public", "String", "getLdapEncoded", "(", ")", "{", "if", "(", "components", ".", "size", "(", ")", "==", "0", ")", "{", "throw", "new", "IndexOutOfBoundsException", "(", "\"No components in Rdn.\"", ")", ";", "}", "StringBuffer", "sb", "=", "new", "StringB...
Get a properly rfc2253-encoded String representation of this LdapRdn. @return an escaped String corresponding to this LdapRdn. @throws IndexOutOfBoundsException if there are no components in this Rdn.
[ "Get", "a", "properly", "rfc2253", "-", "encoded", "String", "representation", "of", "this", "LdapRdn", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/core/LdapRdn.java#L136-L150
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/core/LdapRdn.java
LdapRdn.encodeUrl
public String encodeUrl() { StringBuffer sb = new StringBuffer(DEFAULT_BUFFER_SIZE); for (Iterator iter = components.values().iterator(); iter.hasNext();) { LdapRdnComponent component = (LdapRdnComponent) iter.next(); sb.append(component.encodeUrl()); if (iter.hasNext()) { sb.append("+"); } } return sb.toString(); }
java
public String encodeUrl() { StringBuffer sb = new StringBuffer(DEFAULT_BUFFER_SIZE); for (Iterator iter = components.values().iterator(); iter.hasNext();) { LdapRdnComponent component = (LdapRdnComponent) iter.next(); sb.append(component.encodeUrl()); if (iter.hasNext()) { sb.append("+"); } } return sb.toString(); }
[ "public", "String", "encodeUrl", "(", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", "DEFAULT_BUFFER_SIZE", ")", ";", "for", "(", "Iterator", "iter", "=", "components", ".", "values", "(", ")", ".", "iterator", "(", ")", ";", "iter", "....
Get a String representation of this LdapRdn for use in urls. @return a String representation of this LdapRdn for use in urls.
[ "Get", "a", "String", "representation", "of", "this", "LdapRdn", "for", "use", "in", "urls", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/core/LdapRdn.java#L157-L168
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/core/LdapRdn.java
LdapRdn.compareTo
public int compareTo(Object obj) { LdapRdn that = (LdapRdn) obj; if(this.components.size() != that.components.size()) { return this.components.size() - that.components.size(); } Set<Map.Entry<String,LdapRdnComponent>> theseEntries = this.components.entrySet(); for (Map.Entry<String, LdapRdnComponent> oneEntry : theseEntries) { LdapRdnComponent thatEntry = that.components.get(oneEntry.getKey()); if(thatEntry == null) { return -1; } int compared = oneEntry.getValue().compareTo(thatEntry); if(compared != 0) { return compared; } } return 0; }
java
public int compareTo(Object obj) { LdapRdn that = (LdapRdn) obj; if(this.components.size() != that.components.size()) { return this.components.size() - that.components.size(); } Set<Map.Entry<String,LdapRdnComponent>> theseEntries = this.components.entrySet(); for (Map.Entry<String, LdapRdnComponent> oneEntry : theseEntries) { LdapRdnComponent thatEntry = that.components.get(oneEntry.getKey()); if(thatEntry == null) { return -1; } int compared = oneEntry.getValue().compareTo(thatEntry); if(compared != 0) { return compared; } } return 0; }
[ "public", "int", "compareTo", "(", "Object", "obj", ")", "{", "LdapRdn", "that", "=", "(", "LdapRdn", ")", "obj", ";", "if", "(", "this", ".", "components", ".", "size", "(", ")", "!=", "that", ".", "components", ".", "size", "(", ")", ")", "{", ...
Compare this LdapRdn to another object. @param obj the object to compare to. @throws ClassCastException if the supplied object is not an LdapRdn instance.
[ "Compare", "this", "LdapRdn", "to", "another", "object", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/core/LdapRdn.java#L177-L198
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/core/LdapRdn.java
LdapRdn.immutableLdapRdn
public LdapRdn immutableLdapRdn() { Map<String, LdapRdnComponent> mapWithImmutableRdns = new LinkedHashMap<String, LdapRdnComponent>(components.size()); for (Iterator iterator = components.values().iterator(); iterator.hasNext();) { LdapRdnComponent rdnComponent = (LdapRdnComponent) iterator.next(); mapWithImmutableRdns.put(rdnComponent.getKey(), rdnComponent.immutableLdapRdnComponent()); } Map<String, LdapRdnComponent> unmodifiableMapOfImmutableRdns = Collections.unmodifiableMap(mapWithImmutableRdns); LdapRdn immutableRdn = new LdapRdn(); immutableRdn.components = unmodifiableMapOfImmutableRdns; return immutableRdn; }
java
public LdapRdn immutableLdapRdn() { Map<String, LdapRdnComponent> mapWithImmutableRdns = new LinkedHashMap<String, LdapRdnComponent>(components.size()); for (Iterator iterator = components.values().iterator(); iterator.hasNext();) { LdapRdnComponent rdnComponent = (LdapRdnComponent) iterator.next(); mapWithImmutableRdns.put(rdnComponent.getKey(), rdnComponent.immutableLdapRdnComponent()); } Map<String, LdapRdnComponent> unmodifiableMapOfImmutableRdns = Collections.unmodifiableMap(mapWithImmutableRdns); LdapRdn immutableRdn = new LdapRdn(); immutableRdn.components = unmodifiableMapOfImmutableRdns; return immutableRdn; }
[ "public", "LdapRdn", "immutableLdapRdn", "(", ")", "{", "Map", "<", "String", ",", "LdapRdnComponent", ">", "mapWithImmutableRdns", "=", "new", "LinkedHashMap", "<", "String", ",", "LdapRdnComponent", ">", "(", "components", ".", "size", "(", ")", ")", ";", ...
Create an immutable copy of this instance. It will not be possible to add or remove components or modify the keys and values of these components. @return an immutable copy of this instance. @since 1.3
[ "Create", "an", "immutable", "copy", "of", "this", "instance", ".", "It", "will", "not", "be", "possible", "to", "add", "or", "remove", "components", "or", "modify", "the", "keys", "and", "values", "of", "these", "components", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/core/LdapRdn.java#L297-L307
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareDirContextInvocationHandler.java
TransactionAwareDirContextInvocationHandler.doCloseConnection
void doCloseConnection(DirContext context, ContextSource contextSource) throws javax.naming.NamingException { DirContextHolder transactionContextHolder = (DirContextHolder) TransactionSynchronizationManager .getResource(contextSource); if (transactionContextHolder == null || transactionContextHolder.getCtx() != context) { log.debug("Closing context"); // This is not the transactional context or the transaction is // no longer active - we should close it. context.close(); } else { log.debug("Leaving transactional context open"); } }
java
void doCloseConnection(DirContext context, ContextSource contextSource) throws javax.naming.NamingException { DirContextHolder transactionContextHolder = (DirContextHolder) TransactionSynchronizationManager .getResource(contextSource); if (transactionContextHolder == null || transactionContextHolder.getCtx() != context) { log.debug("Closing context"); // This is not the transactional context or the transaction is // no longer active - we should close it. context.close(); } else { log.debug("Leaving transactional context open"); } }
[ "void", "doCloseConnection", "(", "DirContext", "context", ",", "ContextSource", "contextSource", ")", "throws", "javax", ".", "naming", ".", "NamingException", "{", "DirContextHolder", "transactionContextHolder", "=", "(", "DirContextHolder", ")", "TransactionSynchroniza...
Close the supplied context, but only if it is not associated with the current transaction. @param context the DirContext to close. @param contextSource the ContextSource bound to the transaction. @throws NamingException
[ "Close", "the", "supplied", "context", "but", "only", "if", "it", "is", "not", "associated", "with", "the", "current", "transaction", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/transaction/compensating/manager/TransactionAwareDirContextInvocationHandler.java#L107-L120
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/core/LdapRdnComponent.java
LdapRdnComponent.encodeLdap
protected String encodeLdap() { StringBuffer buff = new StringBuffer(key.length() + value.length() * 2); buff.append(key); buff.append('='); buff.append(LdapEncoder.nameEncode(value)); return buff.toString(); }
java
protected String encodeLdap() { StringBuffer buff = new StringBuffer(key.length() + value.length() * 2); buff.append(key); buff.append('='); buff.append(LdapEncoder.nameEncode(value)); return buff.toString(); }
[ "protected", "String", "encodeLdap", "(", ")", "{", "StringBuffer", "buff", "=", "new", "StringBuffer", "(", "key", ".", "length", "(", ")", "+", "value", ".", "length", "(", ")", "*", "2", ")", ";", "buff", ".", "append", "(", "key", ")", ";", "bu...
Encode key and value to ldap. @return Properly ldap escaped rdn.
[ "Encode", "key", "and", "value", "to", "ldap", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/core/LdapRdnComponent.java#L145-L153
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/core/LdapRdnComponent.java
LdapRdnComponent.encodeUrl
public String encodeUrl() { // Use the URI class to properly URL encode the value. try { URI valueUri = new URI(null, null, value, null); return key + "=" + valueUri.toString(); } catch (URISyntaxException e) { // This should really never happen... return key + "=" + "value"; } }
java
public String encodeUrl() { // Use the URI class to properly URL encode the value. try { URI valueUri = new URI(null, null, value, null); return key + "=" + valueUri.toString(); } catch (URISyntaxException e) { // This should really never happen... return key + "=" + "value"; } }
[ "public", "String", "encodeUrl", "(", ")", "{", "// Use the URI class to properly URL encode the value.", "try", "{", "URI", "valueUri", "=", "new", "URI", "(", "null", ",", "null", ",", "value", ",", "null", ")", ";", "return", "key", "+", "\"=\"", "+", "va...
Get a String representation of this instance for use in URLs. @return a properly URL encoded representation of this instancs.
[ "Get", "a", "String", "representation", "of", "this", "instance", "for", "use", "in", "URLs", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/core/LdapRdnComponent.java#L176-L186
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/core/LdapRdnComponent.java
LdapRdnComponent.compareTo
public int compareTo(Object obj) { LdapRdnComponent that = (LdapRdnComponent) obj; // It's safe to compare directly against key and value, // because they are validated not to be null on instance creation. int keyCompare = this.key.toLowerCase().compareTo(that.key.toLowerCase()); if(keyCompare == 0) { return this.value.toLowerCase().compareTo(that.value.toLowerCase()); } else { return keyCompare; } }
java
public int compareTo(Object obj) { LdapRdnComponent that = (LdapRdnComponent) obj; // It's safe to compare directly against key and value, // because they are validated not to be null on instance creation. int keyCompare = this.key.toLowerCase().compareTo(that.key.toLowerCase()); if(keyCompare == 0) { return this.value.toLowerCase().compareTo(that.value.toLowerCase()); } else { return keyCompare; } }
[ "public", "int", "compareTo", "(", "Object", "obj", ")", "{", "LdapRdnComponent", "that", "=", "(", "LdapRdnComponent", ")", "obj", ";", "// It's safe to compare directly against key and value,", "// because they are validated not to be null on instance creation.", "int", "keyC...
Compare this instance to the supplied object. @param obj the object to compare to. @throws ClassCastException if the object is not possible to cast to an LdapRdnComponent.
[ "Compare", "this", "instance", "to", "the", "supplied", "object", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/core/LdapRdnComponent.java#L225-L236
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/support/LdapUtils.java
LdapUtils.collectAttributeValues
public static void collectAttributeValues(Attributes attributes, String name, Collection<Object> collection) { collectAttributeValues(attributes, name, collection, Object.class); }
java
public static void collectAttributeValues(Attributes attributes, String name, Collection<Object> collection) { collectAttributeValues(attributes, name, collection, Object.class); }
[ "public", "static", "void", "collectAttributeValues", "(", "Attributes", "attributes", ",", "String", "name", ",", "Collection", "<", "Object", ">", "collection", ")", "{", "collectAttributeValues", "(", "attributes", ",", "name", ",", "collection", ",", "Object",...
Collect all the values of a the specified attribute from the supplied Attributes. @param attributes The Attributes; not <code>null</code>. @param name The name of the Attribute to get values for. @param collection the collection to collect the values in. @throws NoSuchAttributeException if no attribute with the specified name exists. @since 1.3
[ "Collect", "all", "the", "values", "of", "a", "the", "specified", "attribute", "from", "the", "supplied", "Attributes", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/support/LdapUtils.java#L258-L260
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/support/LdapUtils.java
LdapUtils.collectAttributeValues
public static <T> void collectAttributeValues( Attributes attributes, String name, Collection<T> collection, Class<T> clazz) { Assert.notNull(attributes, "Attributes must not be null"); Assert.hasText(name, "Name must not be empty"); Assert.notNull(collection, "Collection must not be null"); Attribute attribute = attributes.get(name); if (attribute == null) { throw new NoSuchAttributeException("No attribute with name '" + name + "'"); } iterateAttributeValues(attribute, new CollectingAttributeValueCallbackHandler<T>(collection, clazz)); }
java
public static <T> void collectAttributeValues( Attributes attributes, String name, Collection<T> collection, Class<T> clazz) { Assert.notNull(attributes, "Attributes must not be null"); Assert.hasText(name, "Name must not be empty"); Assert.notNull(collection, "Collection must not be null"); Attribute attribute = attributes.get(name); if (attribute == null) { throw new NoSuchAttributeException("No attribute with name '" + name + "'"); } iterateAttributeValues(attribute, new CollectingAttributeValueCallbackHandler<T>(collection, clazz)); }
[ "public", "static", "<", "T", ">", "void", "collectAttributeValues", "(", "Attributes", "attributes", ",", "String", "name", ",", "Collection", "<", "T", ">", "collection", ",", "Class", "<", "T", ">", "clazz", ")", "{", "Assert", ".", "notNull", "(", "a...
Collect all the values of a the specified attribute from the supplied Attributes as the specified class. @param attributes The Attributes; not <code>null</code>. @param name The name of the Attribute to get values for. @param collection the collection to collect the values in. @param clazz the class of the collected attribute values @throws NoSuchAttributeException if no attribute with the specified name exists. @throws IllegalArgumentException if an attribute value cannot be cast to the specified class. @since 2.0
[ "Collect", "all", "the", "values", "of", "a", "the", "specified", "attribute", "from", "the", "supplied", "Attributes", "as", "the", "specified", "class", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/support/LdapUtils.java#L275-L289
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/support/LdapUtils.java
LdapUtils.iterateAttributeValues
public static void iterateAttributeValues(Attribute attribute, AttributeValueCallbackHandler callbackHandler) { Assert.notNull(attribute, "Attribute must not be null"); Assert.notNull(callbackHandler, "callbackHandler must not be null"); if (attribute instanceof Iterable) { int i = 0; for (Object obj : (Iterable) attribute) { handleAttributeValue(attribute.getID(), obj, i, callbackHandler); i++; } } else { for (int i = 0; i < attribute.size(); i++) { try { handleAttributeValue(attribute.getID(), attribute.get(i), i, callbackHandler); } catch (javax.naming.NamingException e) { throw convertLdapException(e); } } } }
java
public static void iterateAttributeValues(Attribute attribute, AttributeValueCallbackHandler callbackHandler) { Assert.notNull(attribute, "Attribute must not be null"); Assert.notNull(callbackHandler, "callbackHandler must not be null"); if (attribute instanceof Iterable) { int i = 0; for (Object obj : (Iterable) attribute) { handleAttributeValue(attribute.getID(), obj, i, callbackHandler); i++; } } else { for (int i = 0; i < attribute.size(); i++) { try { handleAttributeValue(attribute.getID(), attribute.get(i), i, callbackHandler); } catch (javax.naming.NamingException e) { throw convertLdapException(e); } } } }
[ "public", "static", "void", "iterateAttributeValues", "(", "Attribute", "attribute", ",", "AttributeValueCallbackHandler", "callbackHandler", ")", "{", "Assert", ".", "notNull", "(", "attribute", ",", "\"Attribute must not be null\"", ")", ";", "Assert", ".", "notNull",...
Iterate through all the values of the specified Attribute calling back to the specified callbackHandler. @param attribute the Attribute to work with; not <code>null</code>. @param callbackHandler the callbackHandler; not <code>null</code>. @since 1.3
[ "Iterate", "through", "all", "the", "values", "of", "the", "specified", "Attribute", "calling", "back", "to", "the", "specified", "callbackHandler", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/support/LdapUtils.java#L298-L318
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/support/LdapUtils.java
LdapUtils.newLdapName
public static LdapName newLdapName(String distinguishedName) { Assert.notNull(distinguishedName, "distinguishedName must not be null"); try { return new LdapName(distinguishedName); } catch (InvalidNameException e) { throw convertLdapException(e); } }
java
public static LdapName newLdapName(String distinguishedName) { Assert.notNull(distinguishedName, "distinguishedName must not be null"); try { return new LdapName(distinguishedName); } catch (InvalidNameException e) { throw convertLdapException(e); } }
[ "public", "static", "LdapName", "newLdapName", "(", "String", "distinguishedName", ")", "{", "Assert", ".", "notNull", "(", "distinguishedName", ",", "\"distinguishedName must not be null\"", ")", ";", "try", "{", "return", "new", "LdapName", "(", "distinguishedName",...
Construct a new LdapName instance from the supplied distinguished name string. @param distinguishedName the string to parse for constructing an LdapName instance. @return a new LdapName instance. @throws org.springframework.ldap.InvalidNameException to wrap any InvalidNameExceptions thrown by LdapName. @since 2.0
[ "Construct", "a", "new", "LdapName", "instance", "from", "the", "supplied", "distinguished", "name", "string", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/support/LdapUtils.java#L410-L418
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/support/LdapUtils.java
LdapUtils.getRdn
public static Rdn getRdn(Name name, String key) { Assert.notNull(name, "name must not be null"); Assert.hasText(key, "key must not be blank"); LdapName ldapName = returnOrConstructLdapNameFromName(name); List<Rdn> rdns = ldapName.getRdns(); for (Rdn rdn : rdns) { NamingEnumeration<String> ids = rdn.toAttributes().getIDs(); while (ids.hasMoreElements()) { String id = ids.nextElement(); if(key.equalsIgnoreCase(id)) { return rdn; } } } throw new NoSuchElementException("No Rdn with the requested key: '" + key + "'"); }
java
public static Rdn getRdn(Name name, String key) { Assert.notNull(name, "name must not be null"); Assert.hasText(key, "key must not be blank"); LdapName ldapName = returnOrConstructLdapNameFromName(name); List<Rdn> rdns = ldapName.getRdns(); for (Rdn rdn : rdns) { NamingEnumeration<String> ids = rdn.toAttributes().getIDs(); while (ids.hasMoreElements()) { String id = ids.nextElement(); if(key.equalsIgnoreCase(id)) { return rdn; } } } throw new NoSuchElementException("No Rdn with the requested key: '" + key + "'"); }
[ "public", "static", "Rdn", "getRdn", "(", "Name", "name", ",", "String", "key", ")", "{", "Assert", ".", "notNull", "(", "name", ",", "\"name must not be null\"", ")", ";", "Assert", ".", "hasText", "(", "key", ",", "\"key must not be blank\"", ")", ";", "...
Find the Rdn with the requested key in the supplied Name. @param name the Name in which to search for the key. @param key the attribute key to search for. @return the rdn corresponding to the <b>first</b> occurrence of the requested key. @throws NoSuchElementException if no corresponding entry is found. @since 2.0
[ "Find", "the", "Rdn", "with", "the", "requested", "key", "in", "the", "supplied", "Name", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/support/LdapUtils.java#L506-L524
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/support/LdapUtils.java
LdapUtils.getValue
public static Object getValue(Name name, String key) { NamingEnumeration<? extends Attribute> allAttributes = getRdn(name, key).toAttributes().getAll(); while (allAttributes.hasMoreElements()) { Attribute oneAttribute = allAttributes.nextElement(); if(key.equalsIgnoreCase(oneAttribute.getID())) { try { return oneAttribute.get(); } catch (javax.naming.NamingException e) { throw convertLdapException(e); } } } // This really shouldn't happen throw new NoSuchElementException("No Rdn with the requested key: '" + key + "'"); }
java
public static Object getValue(Name name, String key) { NamingEnumeration<? extends Attribute> allAttributes = getRdn(name, key).toAttributes().getAll(); while (allAttributes.hasMoreElements()) { Attribute oneAttribute = allAttributes.nextElement(); if(key.equalsIgnoreCase(oneAttribute.getID())) { try { return oneAttribute.get(); } catch (javax.naming.NamingException e) { throw convertLdapException(e); } } } // This really shouldn't happen throw new NoSuchElementException("No Rdn with the requested key: '" + key + "'"); }
[ "public", "static", "Object", "getValue", "(", "Name", "name", ",", "String", "key", ")", "{", "NamingEnumeration", "<", "?", "extends", "Attribute", ">", "allAttributes", "=", "getRdn", "(", "name", ",", "key", ")", ".", "toAttributes", "(", ")", ".", "...
Get the value of the Rdn with the requested key in the supplied Name. @param name the Name in which to search for the key. @param key the attribute key to search for. @return the value of the rdn corresponding to the <b>first</b> occurrence of the requested key. @throws NoSuchElementException if no corresponding entry is found. @since 2.0
[ "Get", "the", "value", "of", "the", "Rdn", "with", "the", "requested", "key", "in", "the", "supplied", "Name", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/support/LdapUtils.java#L535-L550
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/support/LdapUtils.java
LdapUtils.getValue
public static Object getValue(Name name, int index) { Assert.notNull(name, "name must not be null"); LdapName ldapName = returnOrConstructLdapNameFromName(name); Rdn rdn = ldapName.getRdn(index); if(rdn.size() > 1) { LOGGER.warn("Rdn at position " + index + " of dn '" + name + "' is multi-value - returned value is not to be trusted. " + "Consider using name-based getValue method instead"); } return rdn.getValue(); }
java
public static Object getValue(Name name, int index) { Assert.notNull(name, "name must not be null"); LdapName ldapName = returnOrConstructLdapNameFromName(name); Rdn rdn = ldapName.getRdn(index); if(rdn.size() > 1) { LOGGER.warn("Rdn at position " + index + " of dn '" + name + "' is multi-value - returned value is not to be trusted. " + "Consider using name-based getValue method instead"); } return rdn.getValue(); }
[ "public", "static", "Object", "getValue", "(", "Name", "name", ",", "int", "index", ")", "{", "Assert", ".", "notNull", "(", "name", ",", "\"name must not be null\"", ")", ";", "LdapName", "ldapName", "=", "returnOrConstructLdapNameFromName", "(", "name", ")", ...
Get the value of the Rdn at the requested index in the supplied Name. @param name the Name to work on. @param index The 0-based index of the rdn value to retrieve. Must be in the range [0,size()). @return the value of the rdn at the requested index. @throws IndexOutOfBoundsException if index is outside the specified range. @since 2.0
[ "Get", "the", "value", "of", "the", "Rdn", "at", "the", "requested", "index", "in", "the", "supplied", "Name", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/support/LdapUtils.java#L561-L572
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/support/LdapUtils.java
LdapUtils.getStringValue
public static String getStringValue(Name name, String key) { return (String) getValue(name, key); }
java
public static String getStringValue(Name name, String key) { return (String) getValue(name, key); }
[ "public", "static", "String", "getStringValue", "(", "Name", "name", ",", "String", "key", ")", "{", "return", "(", "String", ")", "getValue", "(", "name", ",", "key", ")", ";", "}" ]
Get the value of the Rdn with the requested key in the supplied Name as a String. @param name the Name in which to search for the key. @param key the attribute key to search for. @return the String value of the rdn corresponding to the <b>first</b> occurrence of the requested key. @throws NoSuchElementException if no corresponding entry is found. @throws ClassCastException if the value of the requested component is not a String. @since 2.0
[ "Get", "the", "value", "of", "the", "Rdn", "with", "the", "requested", "key", "in", "the", "supplied", "Name", "as", "a", "String", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/support/LdapUtils.java#L598-L600
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/support/LdapUtils.java
LdapUtils.numberToBytes
static byte[] numberToBytes(String number, int length, boolean bigEndian) { BigInteger bi = new BigInteger(number); byte[] bytes = bi.toByteArray(); int remaining = length - bytes.length; if (remaining < 0) { bytes = Arrays.copyOfRange(bytes, -remaining, bytes.length); } else { byte[] fill = new byte[remaining]; bytes = addAll(fill, bytes); } if (!bigEndian) { reverse(bytes); } return bytes; }
java
static byte[] numberToBytes(String number, int length, boolean bigEndian) { BigInteger bi = new BigInteger(number); byte[] bytes = bi.toByteArray(); int remaining = length - bytes.length; if (remaining < 0) { bytes = Arrays.copyOfRange(bytes, -remaining, bytes.length); } else { byte[] fill = new byte[remaining]; bytes = addAll(fill, bytes); } if (!bigEndian) { reverse(bytes); } return bytes; }
[ "static", "byte", "[", "]", "numberToBytes", "(", "String", "number", ",", "int", "length", ",", "boolean", "bigEndian", ")", "{", "BigInteger", "bi", "=", "new", "BigInteger", "(", "number", ")", ";", "byte", "[", "]", "bytes", "=", "bi", ".", "toByte...
Converts the given number to a binary representation of the specified length and "endian-ness". @param number String with number to convert @param length How long the resulting binary array should be @param bigEndian <code>true</code> if big endian (5=0005), or <code>false</code> if little endian (5=5000) @return byte array containing the binary result in the given order
[ "Converts", "the", "given", "number", "to", "a", "binary", "representation", "of", "the", "specified", "length", "and", "endian", "-", "ness", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/support/LdapUtils.java#L725-L739
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/support/LdapUtils.java
LdapUtils.toHexString
static String toHexString(final byte b) { String hexString = Integer.toHexString(b & 0xFF); if (hexString.length() % 2 != 0) { // Pad with 0 hexString = "0" + hexString; } return hexString; }
java
static String toHexString(final byte b) { String hexString = Integer.toHexString(b & 0xFF); if (hexString.length() % 2 != 0) { // Pad with 0 hexString = "0" + hexString; } return hexString; }
[ "static", "String", "toHexString", "(", "final", "byte", "b", ")", "{", "String", "hexString", "=", "Integer", ".", "toHexString", "(", "b", "&", "0xFF", ")", ";", "if", "(", "hexString", ".", "length", "(", ")", "%", "2", "!=", "0", ")", "{", "// ...
Converts a byte into its hexadecimal representation, padding with a leading zero to get an even number of characters. @param b value to convert @return hex string, possibly padded with a zero
[ "Converts", "a", "byte", "into", "its", "hexadecimal", "representation", "padding", "with", "a", "leading", "zero", "to", "get", "an", "even", "number", "of", "characters", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/support/LdapUtils.java#L761-L768
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/support/LdapUtils.java
LdapUtils.toHexString
static String toHexString(final byte[] b) { StringBuffer sb = new StringBuffer("{"); for (int i = 0; i < b.length; i++) { sb.append(toHexString(b[i])); if (i < b.length - 1) { sb.append(","); } } sb.append("}"); return sb.toString(); }
java
static String toHexString(final byte[] b) { StringBuffer sb = new StringBuffer("{"); for (int i = 0; i < b.length; i++) { sb.append(toHexString(b[i])); if (i < b.length - 1) { sb.append(","); } } sb.append("}"); return sb.toString(); }
[ "static", "String", "toHexString", "(", "final", "byte", "[", "]", "b", ")", "{", "StringBuffer", "sb", "=", "new", "StringBuffer", "(", "\"{\"", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "b", ".", "length", ";", "i", "++", ")", ...
Converts a byte array into its hexadecimal representation, padding each with a leading zero to get an even number of characters. @param b values to convert @return hex string, possibly with elements padded with a zero
[ "Converts", "a", "byte", "array", "into", "its", "hexadecimal", "representation", "padding", "each", "with", "a", "leading", "zero", "to", "get", "an", "even", "number", "of", "characters", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/support/LdapUtils.java#L777-L787
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/pool2/DelegatingContext.java
DelegatingContext.getInnermostDelegateContext
public Context getInnermostDelegateContext() { final Context delegateContext = this.getDelegateContext(); if (delegateContext instanceof DelegatingContext) { return ((DelegatingContext)delegateContext).getInnermostDelegateContext(); } return delegateContext; }
java
public Context getInnermostDelegateContext() { final Context delegateContext = this.getDelegateContext(); if (delegateContext instanceof DelegatingContext) { return ((DelegatingContext)delegateContext).getInnermostDelegateContext(); } return delegateContext; }
[ "public", "Context", "getInnermostDelegateContext", "(", ")", "{", "final", "Context", "delegateContext", "=", "this", ".", "getDelegateContext", "(", ")", ";", "if", "(", "delegateContext", "instanceof", "DelegatingContext", ")", "{", "return", "(", "(", "Delegat...
Recursivley inspect delegates until a non-delegating context is found. @return The innermost (real) Context that is being delegated to.
[ "Recursivley", "inspect", "delegates", "until", "a", "non", "-", "delegating", "context", "is", "found", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/pool2/DelegatingContext.java#L73-L81
train
spring-projects/spring-ldap
ldif/ldif-core/src/main/java/org/springframework/ldap/schema/BasicSchemaSpecification.java
BasicSchemaSpecification.isSatisfiedBy
public boolean isSatisfiedBy(LdapAttributes record) throws NamingException { if (record != null) { //DN is required. LdapName dn = record.getName(); if (dn != null) { //objectClass definition is required. if (record.get("objectClass") != null) { //Naming attribute is required. Rdn rdn = dn.getRdn(dn.size() - 1); if (record.get(rdn.getType()) != null) { Object object = record.get(rdn.getType()).get(); if (object instanceof String) { String value = (String) object; if (((String)rdn.getValue()).equalsIgnoreCase(value)) { return true; } } else if(object instanceof byte[]) { String rdnValue = LdapEncoder.printBase64Binary(((String)rdn.getValue()).getBytes()); String attributeValue = LdapEncoder.printBase64Binary((byte[]) object); if (rdnValue.equals(attributeValue)) return true; } } } } }
java
public boolean isSatisfiedBy(LdapAttributes record) throws NamingException { if (record != null) { //DN is required. LdapName dn = record.getName(); if (dn != null) { //objectClass definition is required. if (record.get("objectClass") != null) { //Naming attribute is required. Rdn rdn = dn.getRdn(dn.size() - 1); if (record.get(rdn.getType()) != null) { Object object = record.get(rdn.getType()).get(); if (object instanceof String) { String value = (String) object; if (((String)rdn.getValue()).equalsIgnoreCase(value)) { return true; } } else if(object instanceof byte[]) { String rdnValue = LdapEncoder.printBase64Binary(((String)rdn.getValue()).getBytes()); String attributeValue = LdapEncoder.printBase64Binary((byte[]) object); if (rdnValue.equals(attributeValue)) return true; } } } } }
[ "public", "boolean", "isSatisfiedBy", "(", "LdapAttributes", "record", ")", "throws", "NamingException", "{", "if", "(", "record", "!=", "null", ")", "{", "//DN is required.\r", "LdapName", "dn", "=", "record", ".", "getName", "(", ")", ";", "if", "(", "dn",...
Determines if the policy is satisfied by the supplied LdapAttributes object. @throws NamingException
[ "Determines", "if", "the", "policy", "is", "satisfied", "by", "the", "supplied", "LdapAttributes", "object", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/ldif/ldif-core/src/main/java/org/springframework/ldap/schema/BasicSchemaSpecification.java#L31-L59
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/core/support/SingleContextSource.java
SingleContextSource.destroy
public void destroy() { try { ctx.close(); } catch (javax.naming.NamingException e) { LOG.warn("Error when closing", e); } }
java
public void destroy() { try { ctx.close(); } catch (javax.naming.NamingException e) { LOG.warn("Error when closing", e); } }
[ "public", "void", "destroy", "(", ")", "{", "try", "{", "ctx", ".", "close", "(", ")", ";", "}", "catch", "(", "javax", ".", "naming", ".", "NamingException", "e", ")", "{", "LOG", ".", "warn", "(", "\"Error when closing\"", ",", "e", ")", ";", "}"...
Destroy method that allows the target DirContext to be cleaned up when the SingleContextSource is not going to be used any more.
[ "Destroy", "method", "that", "allows", "the", "target", "DirContext", "to", "be", "cleaned", "up", "when", "the", "SingleContextSource", "is", "not", "going", "to", "be", "used", "any", "more", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/core/support/SingleContextSource.java#L90-L97
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/core/DistinguishedName.java
DistinguishedName.parse
protected final void parse(String path) { DnParser parser = DefaultDnParserFactory.createDnParser(unmangleCompositeName(path)); DistinguishedName dn; try { dn = parser.dn(); } catch (ParseException e) { throw new BadLdapGrammarException("Failed to parse DN", e); } catch (TokenMgrError e) { throw new BadLdapGrammarException("Failed to parse DN", e); } this.names = dn.names; }
java
protected final void parse(String path) { DnParser parser = DefaultDnParserFactory.createDnParser(unmangleCompositeName(path)); DistinguishedName dn; try { dn = parser.dn(); } catch (ParseException e) { throw new BadLdapGrammarException("Failed to parse DN", e); } catch (TokenMgrError e) { throw new BadLdapGrammarException("Failed to parse DN", e); } this.names = dn.names; }
[ "protected", "final", "void", "parse", "(", "String", "path", ")", "{", "DnParser", "parser", "=", "DefaultDnParserFactory", ".", "createDnParser", "(", "unmangleCompositeName", "(", "path", ")", ")", ";", "DistinguishedName", "dn", ";", "try", "{", "dn", "=",...
Parse the supplied String and make this instance represent the corresponding distinguished name. @param path the LDAP path to parse.
[ "Parse", "the", "supplied", "String", "and", "make", "this", "instance", "represent", "the", "corresponding", "distinguished", "name", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/core/DistinguishedName.java#L222-L235
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/core/DistinguishedName.java
DistinguishedName.toUrl
public String toUrl() { StringBuffer buffer = new StringBuffer(DEFAULT_BUFFER_SIZE); for (int i = names.size() - 1; i >= 0; i--) { LdapRdn n = (LdapRdn) names.get(i); buffer.append(n.encodeUrl()); if (i > 0) { buffer.append(","); } } return buffer.toString(); }
java
public String toUrl() { StringBuffer buffer = new StringBuffer(DEFAULT_BUFFER_SIZE); for (int i = names.size() - 1; i >= 0; i--) { LdapRdn n = (LdapRdn) names.get(i); buffer.append(n.encodeUrl()); if (i > 0) { buffer.append(","); } } return buffer.toString(); }
[ "public", "String", "toUrl", "(", ")", "{", "StringBuffer", "buffer", "=", "new", "StringBuffer", "(", "DEFAULT_BUFFER_SIZE", ")", ";", "for", "(", "int", "i", "=", "names", ".", "size", "(", ")", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")",...
Builds a complete LDAP path, ldap and url encoded. Separates only with ",". @return the LDAP path, for use in an url.
[ "Builds", "a", "complete", "LDAP", "path", "ldap", "and", "url", "encoded", ".", "Separates", "only", "with", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/core/DistinguishedName.java#L391-L402
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/core/DistinguishedName.java
DistinguishedName.compareTo
public int compareTo(Object obj) { DistinguishedName that = (DistinguishedName) obj; ListComparator comparator = new ListComparator(); return comparator.compare(this.names, that.names); }
java
public int compareTo(Object obj) { DistinguishedName that = (DistinguishedName) obj; ListComparator comparator = new ListComparator(); return comparator.compare(this.names, that.names); }
[ "public", "int", "compareTo", "(", "Object", "obj", ")", "{", "DistinguishedName", "that", "=", "(", "DistinguishedName", ")", "obj", ";", "ListComparator", "comparator", "=", "new", "ListComparator", "(", ")", ";", "return", "comparator", ".", "compare", "(",...
Compare this instance to another object. Note that the comparison is done in order of significance, so the most significant Rdn is compared first, then the second and so on. @see javax.naming.Name#compareTo(java.lang.Object)
[ "Compare", "this", "instance", "to", "another", "object", ".", "Note", "that", "the", "comparison", "is", "done", "in", "order", "of", "significance", "so", "the", "most", "significant", "Rdn", "is", "compared", "first", "then", "the", "second", "and", "so",...
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/core/DistinguishedName.java#L577-L581
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/core/DistinguishedName.java
DistinguishedName.immutableDistinguishedName
public DistinguishedName immutableDistinguishedName() { List listWithImmutableRdns = new ArrayList(names.size()); for (Iterator iterator = names.iterator(); iterator.hasNext();) { LdapRdn rdn = (LdapRdn) iterator.next(); listWithImmutableRdns.add(rdn.immutableLdapRdn()); } return new DistinguishedName(Collections.unmodifiableList(listWithImmutableRdns)); }
java
public DistinguishedName immutableDistinguishedName() { List listWithImmutableRdns = new ArrayList(names.size()); for (Iterator iterator = names.iterator(); iterator.hasNext();) { LdapRdn rdn = (LdapRdn) iterator.next(); listWithImmutableRdns.add(rdn.immutableLdapRdn()); } return new DistinguishedName(Collections.unmodifiableList(listWithImmutableRdns)); }
[ "public", "DistinguishedName", "immutableDistinguishedName", "(", ")", "{", "List", "listWithImmutableRdns", "=", "new", "ArrayList", "(", "names", ".", "size", "(", ")", ")", ";", "for", "(", "Iterator", "iterator", "=", "names", ".", "iterator", "(", ")", ...
Return an immutable copy of this instance. It will not be possible to add or remove any Rdns to or from the returned instance, and the respective Rdns will also be immutable in turn. @return a copy of this instance backed by an immutable list. @since 1.2
[ "Return", "an", "immutable", "copy", "of", "this", "instance", ".", "It", "will", "not", "be", "possible", "to", "add", "or", "remove", "any", "Rdns", "to", "or", "from", "the", "returned", "instance", "and", "the", "respective", "Rdns", "will", "also", ...
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/core/DistinguishedName.java#L840-L848
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/odm/core/impl/AttributeMetaData.java
AttributeMetaData.processAttributeAnnotation
private boolean processAttributeAnnotation(Field field) { // Default to no syntax specified syntax = ""; // Default to a String based attribute isBinary = false; // Default name of attribute to the name of the field name = new CaseIgnoreString(field.getName()); // We have not yet found the @Attribute annotation boolean foundAnnotation=false; // Grab the @Attribute annotation Attribute attribute = field.getAnnotation(Attribute.class); List<String> attrList = new ArrayList<String>(); // Did we find the annotation? if (attribute != null) { // Pull attribute name, syntax and whether attribute is binary // from the annotation foundAnnotation=true; String localAttributeName = attribute.name(); // Would be more efficient to use !isEmpty - but that then makes us Java 6 dependent if (localAttributeName != null && localAttributeName.length()>0) { name = new CaseIgnoreString(localAttributeName); attrList.add(localAttributeName); } syntax = attribute.syntax(); isBinary = attribute.type() == Attribute.Type.BINARY; isReadOnly = attribute.readonly(); } attributes = attrList.toArray(new String[attrList.size()]); isObjectClass=name.equals(OBJECT_CLASS_ATTRIBUTE_CI); return foundAnnotation; }
java
private boolean processAttributeAnnotation(Field field) { // Default to no syntax specified syntax = ""; // Default to a String based attribute isBinary = false; // Default name of attribute to the name of the field name = new CaseIgnoreString(field.getName()); // We have not yet found the @Attribute annotation boolean foundAnnotation=false; // Grab the @Attribute annotation Attribute attribute = field.getAnnotation(Attribute.class); List<String> attrList = new ArrayList<String>(); // Did we find the annotation? if (attribute != null) { // Pull attribute name, syntax and whether attribute is binary // from the annotation foundAnnotation=true; String localAttributeName = attribute.name(); // Would be more efficient to use !isEmpty - but that then makes us Java 6 dependent if (localAttributeName != null && localAttributeName.length()>0) { name = new CaseIgnoreString(localAttributeName); attrList.add(localAttributeName); } syntax = attribute.syntax(); isBinary = attribute.type() == Attribute.Type.BINARY; isReadOnly = attribute.readonly(); } attributes = attrList.toArray(new String[attrList.size()]); isObjectClass=name.equals(OBJECT_CLASS_ATTRIBUTE_CI); return foundAnnotation; }
[ "private", "boolean", "processAttributeAnnotation", "(", "Field", "field", ")", "{", "// Default to no syntax specified\r", "syntax", "=", "\"\"", ";", "// Default to a String based attribute\r", "isBinary", "=", "false", ";", "// Default name of attribute to the name of the fiel...
syntax, isBinary, isObjectClass and name.
[ "syntax", "isBinary", "isObjectClass", "and", "name", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/odm/core/impl/AttributeMetaData.java#L86-L123
train
spring-projects/spring-ldap
odm/src/main/java/org/springframework/ldap/odm/tools/SchemaToJava.java
SchemaToJava.readSyntaxMap
private static Map<String, String> readSyntaxMap(File syntaxMapFile) throws IOException { Map<String, String> result = new HashMap<String, String>(); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(syntaxMapFile)); String line; while ((line = reader.readLine()) != null) { String trimmed = line.trim(); if (trimmed.length() > 0) { if (trimmed.charAt(0) != '#') { String[] parts = trimmed.split(","); if (parts.length != 2) { throw new IOException(String.format("Failed to parse line \"%1$s\"", trimmed)); } String partOne = parts[0].trim(); String partTwo = parts[1].trim(); if (partOne.length() == 0 || partTwo.length() == 0) { throw new IOException(String.format("Failed to parse line \"%1$s\"", trimmed)); } result.put(partOne, partTwo); } } } } finally { if (reader != null) { reader.close(); } } return result; }
java
private static Map<String, String> readSyntaxMap(File syntaxMapFile) throws IOException { Map<String, String> result = new HashMap<String, String>(); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(syntaxMapFile)); String line; while ((line = reader.readLine()) != null) { String trimmed = line.trim(); if (trimmed.length() > 0) { if (trimmed.charAt(0) != '#') { String[] parts = trimmed.split(","); if (parts.length != 2) { throw new IOException(String.format("Failed to parse line \"%1$s\"", trimmed)); } String partOne = parts[0].trim(); String partTwo = parts[1].trim(); if (partOne.length() == 0 || partTwo.length() == 0) { throw new IOException(String.format("Failed to parse line \"%1$s\"", trimmed)); } result.put(partOne, partTwo); } } } } finally { if (reader != null) { reader.close(); } } return result; }
[ "private", "static", "Map", "<", "String", ",", "String", ">", "readSyntaxMap", "(", "File", "syntaxMapFile", ")", "throws", "IOException", "{", "Map", "<", "String", ",", "String", ">", "result", "=", "new", "HashMap", "<", "String", ",", "String", ">", ...
Read mappings of LDAP syntaxes to Java classes.
[ "Read", "mappings", "of", "LDAP", "syntaxes", "to", "Java", "classes", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/odm/src/main/java/org/springframework/ldap/odm/tools/SchemaToJava.java#L195-L230
train
spring-projects/spring-ldap
odm/src/main/java/org/springframework/ldap/odm/tools/SchemaToJava.java
SchemaToJava.readSchema
private static ObjectSchema readSchema(String url, String user, String pass, SyntaxToJavaClass syntaxToJavaClass, Set<String> binarySet, Set<String> objectClasses) throws NamingException, ClassNotFoundException { // Set up environment Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.PROVIDER_URL, url); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); if (user != null) { env.put(Context.SECURITY_PRINCIPAL, user); } if (pass != null) { env.put(Context.SECURITY_CREDENTIALS, pass); } DirContext context = new InitialDirContext(env); DirContext schemaContext = context.getSchema(""); SchemaReader reader = new SchemaReader(schemaContext, syntaxToJavaClass, binarySet); ObjectSchema schema = reader.getObjectSchema(objectClasses); if (LOG.isDebugEnabled()) { LOG.debug(String.format("Schema - %1$s", schema.toString())); } return schema; }
java
private static ObjectSchema readSchema(String url, String user, String pass, SyntaxToJavaClass syntaxToJavaClass, Set<String> binarySet, Set<String> objectClasses) throws NamingException, ClassNotFoundException { // Set up environment Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.PROVIDER_URL, url); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); if (user != null) { env.put(Context.SECURITY_PRINCIPAL, user); } if (pass != null) { env.put(Context.SECURITY_CREDENTIALS, pass); } DirContext context = new InitialDirContext(env); DirContext schemaContext = context.getSchema(""); SchemaReader reader = new SchemaReader(schemaContext, syntaxToJavaClass, binarySet); ObjectSchema schema = reader.getObjectSchema(objectClasses); if (LOG.isDebugEnabled()) { LOG.debug(String.format("Schema - %1$s", schema.toString())); } return schema; }
[ "private", "static", "ObjectSchema", "readSchema", "(", "String", "url", ",", "String", "user", ",", "String", "pass", ",", "SyntaxToJavaClass", "syntaxToJavaClass", ",", "Set", "<", "String", ">", "binarySet", ",", "Set", "<", "String", ">", "objectClasses", ...
Bind to the directory, read and process the schema
[ "Bind", "to", "the", "directory", "read", "and", "process", "the", "schema" ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/odm/src/main/java/org/springframework/ldap/odm/tools/SchemaToJava.java#L233-L258
train
spring-projects/spring-ldap
odm/src/main/java/org/springframework/ldap/odm/tools/SchemaToJava.java
SchemaToJava.createCode
private static void createCode(String packageName, String className, ObjectSchema schema, Set<SyntaxToJavaClass.ClassInfo> imports, File outputFile) throws IOException, TemplateException { Configuration freeMarkerConfiguration = new Configuration(); freeMarkerConfiguration.setClassForTemplateLoading(DEFAULT_LOADER_CLASS, ""); freeMarkerConfiguration.setObjectWrapper(new DefaultObjectWrapper()); // Build the model for FreeMarker Map<String, Object> model = new HashMap<String, Object>(); model.put("package", packageName); model.put("class", className); model.put("schema", schema); model.put("imports", imports); // Have FreeMarker process the model with the template Template template = freeMarkerConfiguration.getTemplate(TEMPLATE_FILE); if (LOG.isDebugEnabled()) { Writer out = new OutputStreamWriter(System.out); template.process(model, out); out.flush(); } LOG.debug(String.format("Writing java to: %1$s", outputFile.getAbsolutePath())); FileOutputStream outputStream=new FileOutputStream(outputFile); Writer out = new OutputStreamWriter(outputStream); template.process(model, out); out.flush(); out.close(); }
java
private static void createCode(String packageName, String className, ObjectSchema schema, Set<SyntaxToJavaClass.ClassInfo> imports, File outputFile) throws IOException, TemplateException { Configuration freeMarkerConfiguration = new Configuration(); freeMarkerConfiguration.setClassForTemplateLoading(DEFAULT_LOADER_CLASS, ""); freeMarkerConfiguration.setObjectWrapper(new DefaultObjectWrapper()); // Build the model for FreeMarker Map<String, Object> model = new HashMap<String, Object>(); model.put("package", packageName); model.put("class", className); model.put("schema", schema); model.put("imports", imports); // Have FreeMarker process the model with the template Template template = freeMarkerConfiguration.getTemplate(TEMPLATE_FILE); if (LOG.isDebugEnabled()) { Writer out = new OutputStreamWriter(System.out); template.process(model, out); out.flush(); } LOG.debug(String.format("Writing java to: %1$s", outputFile.getAbsolutePath())); FileOutputStream outputStream=new FileOutputStream(outputFile); Writer out = new OutputStreamWriter(outputStream); template.process(model, out); out.flush(); out.close(); }
[ "private", "static", "void", "createCode", "(", "String", "packageName", ",", "String", "className", ",", "ObjectSchema", "schema", ",", "Set", "<", "SyntaxToJavaClass", ".", "ClassInfo", ">", "imports", ",", "File", "outputFile", ")", "throws", "IOException", "...
Create the Java
[ "Create", "the", "Java" ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/odm/src/main/java/org/springframework/ldap/odm/tools/SchemaToJava.java#L261-L293
train
spring-projects/spring-ldap
odm/src/main/java/org/springframework/ldap/odm/tools/SchemaToJava.java
SchemaToJava.makeOutputFile
private static File makeOutputFile(String outputDir, String packageName, String className) throws IOException { // Convert the package name to a path Pattern pattern=Pattern.compile("\\."); Matcher matcher=pattern.matcher(packageName); String sepToUse=File.separator; if (sepToUse.equals("\\")) { sepToUse="\\\\"; } // Try to create the necessary directories String directoryPath=outputDir+File.separator+matcher.replaceAll(sepToUse); File directory=new File(directoryPath); File outputFile=new File(directory, className+".java"); LOG.debug(String.format("Attempting to create output file at %1$s", outputFile.getAbsolutePath())); try { directory.mkdirs(); outputFile.createNewFile(); } catch (SecurityException se) { throw new IOException(String.format("Can't write to output file %1$s", outputFile.getAbsoluteFile()), se); } catch (IOException ioe) { throw new IOException(String.format("Can't write to output file %1$s", outputFile.getAbsoluteFile()), ioe); } return outputFile; }
java
private static File makeOutputFile(String outputDir, String packageName, String className) throws IOException { // Convert the package name to a path Pattern pattern=Pattern.compile("\\."); Matcher matcher=pattern.matcher(packageName); String sepToUse=File.separator; if (sepToUse.equals("\\")) { sepToUse="\\\\"; } // Try to create the necessary directories String directoryPath=outputDir+File.separator+matcher.replaceAll(sepToUse); File directory=new File(directoryPath); File outputFile=new File(directory, className+".java"); LOG.debug(String.format("Attempting to create output file at %1$s", outputFile.getAbsolutePath())); try { directory.mkdirs(); outputFile.createNewFile(); } catch (SecurityException se) { throw new IOException(String.format("Can't write to output file %1$s", outputFile.getAbsoluteFile()), se); } catch (IOException ioe) { throw new IOException(String.format("Can't write to output file %1$s", outputFile.getAbsoluteFile()), ioe); } return outputFile; }
[ "private", "static", "File", "makeOutputFile", "(", "String", "outputDir", ",", "String", "packageName", ",", "String", "className", ")", "throws", "IOException", "{", "// Convert the package name to a path", "Pattern", "pattern", "=", "Pattern", ".", "compile", "(", ...
Create the output file for the generated code along with all intervening directories
[ "Create", "the", "output", "file", "for", "the", "generated", "code", "along", "with", "all", "intervening", "directories" ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/odm/src/main/java/org/springframework/ldap/odm/tools/SchemaToJava.java#L296-L324
train
spring-projects/spring-ldap
odm/src/main/java/org/springframework/ldap/odm/tools/SchemaReader.java
SchemaReader.getObjectSchema
public ObjectSchema getObjectSchema(Set<String> objectClasses) throws NamingException, ClassNotFoundException { ObjectSchema result = new ObjectSchema(); createObjectClass(objectClasses, schemaContext, result); return result; }
java
public ObjectSchema getObjectSchema(Set<String> objectClasses) throws NamingException, ClassNotFoundException { ObjectSchema result = new ObjectSchema(); createObjectClass(objectClasses, schemaContext, result); return result; }
[ "public", "ObjectSchema", "getObjectSchema", "(", "Set", "<", "String", ">", "objectClasses", ")", "throws", "NamingException", ",", "ClassNotFoundException", "{", "ObjectSchema", "result", "=", "new", "ObjectSchema", "(", ")", ";", "createObjectClass", "(", "object...
Get the object schema for the given object classes
[ "Get", "the", "object", "schema", "for", "the", "given", "object", "classes" ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/odm/src/main/java/org/springframework/ldap/odm/tools/SchemaReader.java#L44-L50
train
spring-projects/spring-ldap
odm/src/main/java/org/springframework/ldap/odm/tools/SchemaReader.java
SchemaReader.createObjectClass
private void createObjectClass(Set<String> objectClasses, DirContext schemaContext, ObjectSchema schema) throws NamingException, ClassNotFoundException { // Super classes Set<String> supList = new HashSet<String>(); // For each of the given object classes for (String objectClass : objectClasses) { // Add to set of included object classes schema.addObjectClass(objectClass); // Grab the LDAP schema of the object class Attributes attributes = schemaContext.getAttributes("ClassDefinition/" + objectClass); NamingEnumeration<? extends Attribute> valuesEnumeration = attributes.getAll(); // Loop through each of the attributes while (valuesEnumeration.hasMoreElements()) { Attribute currentAttribute = valuesEnumeration.nextElement(); // Get the attribute name and lower case it (as this is all case indep) String currentId = currentAttribute.getID().toUpperCase(); // Is this a MUST, MAY or SUP attribute SchemaAttributeType type = getSchemaAttributeType(currentId); // Loop through all the values NamingEnumeration<?> currentValues = currentAttribute.getAll(); while (currentValues.hasMoreElements()) { String currentValue = (String)currentValues.nextElement(); switch (type) { case SUP: // Its a super class String lowerCased=currentValue.toLowerCase(); if (!schema.getObjectClass().contains(lowerCased)) { supList.add(lowerCased); } break; case MUST: // Add must attribute schema.addMust(createAttributeSchema(currentValue, schemaContext)); break; case MAY: // Add may attribute schema.addMay(createAttributeSchema(currentValue, schemaContext)); break; default: // Nothing to do } } } // Recurse for super classes createObjectClass(supList, schemaContext, schema); } }
java
private void createObjectClass(Set<String> objectClasses, DirContext schemaContext, ObjectSchema schema) throws NamingException, ClassNotFoundException { // Super classes Set<String> supList = new HashSet<String>(); // For each of the given object classes for (String objectClass : objectClasses) { // Add to set of included object classes schema.addObjectClass(objectClass); // Grab the LDAP schema of the object class Attributes attributes = schemaContext.getAttributes("ClassDefinition/" + objectClass); NamingEnumeration<? extends Attribute> valuesEnumeration = attributes.getAll(); // Loop through each of the attributes while (valuesEnumeration.hasMoreElements()) { Attribute currentAttribute = valuesEnumeration.nextElement(); // Get the attribute name and lower case it (as this is all case indep) String currentId = currentAttribute.getID().toUpperCase(); // Is this a MUST, MAY or SUP attribute SchemaAttributeType type = getSchemaAttributeType(currentId); // Loop through all the values NamingEnumeration<?> currentValues = currentAttribute.getAll(); while (currentValues.hasMoreElements()) { String currentValue = (String)currentValues.nextElement(); switch (type) { case SUP: // Its a super class String lowerCased=currentValue.toLowerCase(); if (!schema.getObjectClass().contains(lowerCased)) { supList.add(lowerCased); } break; case MUST: // Add must attribute schema.addMust(createAttributeSchema(currentValue, schemaContext)); break; case MAY: // Add may attribute schema.addMay(createAttributeSchema(currentValue, schemaContext)); break; default: // Nothing to do } } } // Recurse for super classes createObjectClass(supList, schemaContext, schema); } }
[ "private", "void", "createObjectClass", "(", "Set", "<", "String", ">", "objectClasses", ",", "DirContext", "schemaContext", ",", "ObjectSchema", "schema", ")", "throws", "NamingException", ",", "ClassNotFoundException", "{", "// Super classes\r", "Set", "<", "String"...
Recursively extract schema from the directory and process it
[ "Recursively", "extract", "schema", "from", "the", "directory", "and", "process", "it" ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/odm/src/main/java/org/springframework/ldap/odm/tools/SchemaReader.java#L131-L185
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java
AbstractContextSource.closeContext
private void closeContext(DirContext ctx) { if (ctx != null) { try { ctx.close(); } catch (Exception e) { LOG.debug("Exception closing context", e); } } }
java
private void closeContext(DirContext ctx) { if (ctx != null) { try { ctx.close(); } catch (Exception e) { LOG.debug("Exception closing context", e); } } }
[ "private", "void", "closeContext", "(", "DirContext", "ctx", ")", "{", "if", "(", "ctx", "!=", "null", ")", "{", "try", "{", "ctx", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOG", ".", "debug", "(", "\"Exception c...
Close the context and swallow any exceptions. @param ctx the DirContext to close.
[ "Close", "the", "context", "and", "swallow", "any", "exceptions", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java#L206-L215
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java
AbstractContextSource.createContext
protected DirContext createContext(Hashtable<String, Object> environment) { DirContext ctx = null; try { ctx = getDirContextInstance(environment); if (LOG.isInfoEnabled()) { Hashtable<?, ?> ctxEnv = ctx.getEnvironment(); String ldapUrl = (String) ctxEnv.get(Context.PROVIDER_URL); LOG.debug("Got Ldap context on server '" + ldapUrl + "'"); } return ctx; } catch (NamingException e) { closeContext(ctx); throw LdapUtils.convertLdapException(e); } }
java
protected DirContext createContext(Hashtable<String, Object> environment) { DirContext ctx = null; try { ctx = getDirContextInstance(environment); if (LOG.isInfoEnabled()) { Hashtable<?, ?> ctxEnv = ctx.getEnvironment(); String ldapUrl = (String) ctxEnv.get(Context.PROVIDER_URL); LOG.debug("Got Ldap context on server '" + ldapUrl + "'"); } return ctx; } catch (NamingException e) { closeContext(ctx); throw LdapUtils.convertLdapException(e); } }
[ "protected", "DirContext", "createContext", "(", "Hashtable", "<", "String", ",", "Object", ">", "environment", ")", "{", "DirContext", "ctx", "=", "null", ";", "try", "{", "ctx", "=", "getDirContextInstance", "(", "environment", ")", ";", "if", "(", "LOG", ...
Create a DirContext using the supplied environment. @param environment the LDAP environment to use when creating the <code>DirContext</code>. @return a new DirContext implementation initialized with the supplied environment.
[ "Create", "a", "DirContext", "using", "the", "supplied", "environment", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java#L339-L357
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java
AbstractContextSource.afterPropertiesSet
public void afterPropertiesSet() { if (ObjectUtils.isEmpty(urls)) { throw new IllegalArgumentException("At least one server url must be set"); } if (authenticationSource == null) { LOG.debug("AuthenticationSource not set - " + "using default implementation"); if (!StringUtils.hasText(userDn)) { LOG.info("Property 'userDn' not set - " + "anonymous context will be used for read-write operations"); anonymousReadOnly = true; } else if (!StringUtils.hasText(password)) { LOG.info("Property 'password' not set - " + "blank password will be used"); } authenticationSource = new SimpleAuthenticationSource(); } if (cacheEnvironmentProperties) { anonymousEnv = setupAnonymousEnv(); } }
java
public void afterPropertiesSet() { if (ObjectUtils.isEmpty(urls)) { throw new IllegalArgumentException("At least one server url must be set"); } if (authenticationSource == null) { LOG.debug("AuthenticationSource not set - " + "using default implementation"); if (!StringUtils.hasText(userDn)) { LOG.info("Property 'userDn' not set - " + "anonymous context will be used for read-write operations"); anonymousReadOnly = true; } else if (!StringUtils.hasText(password)) { LOG.info("Property 'password' not set - " + "blank password will be used"); } authenticationSource = new SimpleAuthenticationSource(); } if (cacheEnvironmentProperties) { anonymousEnv = setupAnonymousEnv(); } }
[ "public", "void", "afterPropertiesSet", "(", ")", "{", "if", "(", "ObjectUtils", ".", "isEmpty", "(", "urls", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"At least one server url must be set\"", ")", ";", "}", "if", "(", "authenticationSource...
Checks that all necessary data is set and that there is no compatibility issues, after which the instance is initialized. Note that you need to call this method explicitly after setting all desired properties if using the class outside of a Spring Context.
[ "Checks", "that", "all", "necessary", "data", "is", "set", "and", "that", "there", "is", "no", "compatibility", "issues", "after", "which", "the", "instance", "is", "initialized", ".", "Note", "that", "you", "need", "to", "call", "this", "method", "explicitl...
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java#L407-L427
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java
AbstractContextSource.setBaseEnvironmentProperties
public void setBaseEnvironmentProperties(Map<String, Object> baseEnvironmentProperties) { this.baseEnv = new Hashtable<String, Object>(baseEnvironmentProperties); }
java
public void setBaseEnvironmentProperties(Map<String, Object> baseEnvironmentProperties) { this.baseEnv = new Hashtable<String, Object>(baseEnvironmentProperties); }
[ "public", "void", "setBaseEnvironmentProperties", "(", "Map", "<", "String", ",", "Object", ">", "baseEnvironmentProperties", ")", "{", "this", ".", "baseEnv", "=", "new", "Hashtable", "<", "String", ",", "Object", ">", "(", "baseEnvironmentProperties", ")", ";"...
If any custom environment properties are needed, these can be set using this method. @param baseEnvironmentProperties the base environment properties that should always be used when creating new Context instances.
[ "If", "any", "custom", "environment", "properties", "are", "needed", "these", "can", "be", "set", "using", "this", "method", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/core/support/AbstractContextSource.java#L567-L569
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/support/LdapNameBuilder.java
LdapNameBuilder.add
public LdapNameBuilder add(Name name) { Assert.notNull(name, "name must not be null"); try { ldapName.addAll(ldapName.size(), name); return this; } catch (InvalidNameException e) { throw new org.springframework.ldap.InvalidNameException(e); } }
java
public LdapNameBuilder add(Name name) { Assert.notNull(name, "name must not be null"); try { ldapName.addAll(ldapName.size(), name); return this; } catch (InvalidNameException e) { throw new org.springframework.ldap.InvalidNameException(e); } }
[ "public", "LdapNameBuilder", "add", "(", "Name", "name", ")", "{", "Assert", ".", "notNull", "(", "name", ",", "\"name must not be null\"", ")", ";", "try", "{", "ldapName", ".", "addAll", "(", "ldapName", ".", "size", "(", ")", ",", "name", ")", ";", ...
Append the specified name to the currently built LdapName. @param name the name to add. @return this builder.
[ "Append", "the", "specified", "name", "to", "the", "currently", "built", "LdapName", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/support/LdapNameBuilder.java#L101-L110
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/support/LdapNameBuilder.java
LdapNameBuilder.add
public LdapNameBuilder add(String name) { Assert.notNull(name, "name must not be null"); return add(LdapUtils.newLdapName(name)); }
java
public LdapNameBuilder add(String name) { Assert.notNull(name, "name must not be null"); return add(LdapUtils.newLdapName(name)); }
[ "public", "LdapNameBuilder", "add", "(", "String", "name", ")", "{", "Assert", ".", "notNull", "(", "name", ",", "\"name must not be null\"", ")", ";", "return", "add", "(", "LdapUtils", ".", "newLdapName", "(", "name", ")", ")", ";", "}" ]
Append the LdapName represented by the specified string to the currently built LdapName. @param name the name to add. @return this builder.
[ "Append", "the", "LdapName", "represented", "by", "the", "specified", "string", "to", "the", "currently", "built", "LdapName", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/support/LdapNameBuilder.java#L118-L122
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/core/LdapTemplate.java
LdapTemplate.deleteRecursively
protected void deleteRecursively(DirContext ctx, Name name) { NamingEnumeration enumeration = null; try { enumeration = ctx.listBindings(name); while (enumeration.hasMore()) { Binding binding = (Binding) enumeration.next(); LdapName childName = LdapUtils.newLdapName(binding.getName()); childName.addAll(0, name); deleteRecursively(ctx, childName); } ctx.unbind(name); if (LOG.isDebugEnabled()) { LOG.debug("Entry " + name + " deleted"); } } catch (javax.naming.NamingException e) { throw LdapUtils.convertLdapException(e); } finally { try { enumeration.close(); } catch (Exception e) { // Never mind this } } }
java
protected void deleteRecursively(DirContext ctx, Name name) { NamingEnumeration enumeration = null; try { enumeration = ctx.listBindings(name); while (enumeration.hasMore()) { Binding binding = (Binding) enumeration.next(); LdapName childName = LdapUtils.newLdapName(binding.getName()); childName.addAll(0, name); deleteRecursively(ctx, childName); } ctx.unbind(name); if (LOG.isDebugEnabled()) { LOG.debug("Entry " + name + " deleted"); } } catch (javax.naming.NamingException e) { throw LdapUtils.convertLdapException(e); } finally { try { enumeration.close(); } catch (Exception e) { // Never mind this } } }
[ "protected", "void", "deleteRecursively", "(", "DirContext", "ctx", ",", "Name", "name", ")", "{", "NamingEnumeration", "enumeration", "=", "null", ";", "try", "{", "enumeration", "=", "ctx", ".", "listBindings", "(", "name", ")", ";", "while", "(", "enumera...
Delete all subcontexts including the current one recursively. @param ctx The context to use for deleting. @param name The starting point to delete recursively. @throws NamingException if any error occurs
[ "Delete", "all", "subcontexts", "including", "the", "current", "one", "recursively", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java#L1096-L1123
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/core/LdapTemplate.java
LdapTemplate.assureReturnObjFlagSet
private void assureReturnObjFlagSet(SearchControls controls) { Assert.notNull(controls, "controls must not be null"); if (!controls.getReturningObjFlag()) { LOG.debug("The returnObjFlag of supplied SearchControls is not set" + " but a ContextMapper is used - setting flag to true"); controls.setReturningObjFlag(true); } }
java
private void assureReturnObjFlagSet(SearchControls controls) { Assert.notNull(controls, "controls must not be null"); if (!controls.getReturningObjFlag()) { LOG.debug("The returnObjFlag of supplied SearchControls is not set" + " but a ContextMapper is used - setting flag to true"); controls.setReturningObjFlag(true); } }
[ "private", "void", "assureReturnObjFlagSet", "(", "SearchControls", "controls", ")", "{", "Assert", ".", "notNull", "(", "controls", ",", "\"controls must not be null\"", ")", ";", "if", "(", "!", "controls", ".", "getReturningObjFlag", "(", ")", ")", "{", "LOG"...
Make sure the returnObjFlag is set in the supplied SearchControls. Set it and log if it's not set. @param controls the SearchControls to check.
[ "Make", "sure", "the", "returnObjFlag", "is", "set", "in", "the", "supplied", "SearchControls", ".", "Set", "it", "and", "log", "if", "it", "s", "not", "set", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/core/LdapTemplate.java#L1241-L1248
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/pool/DelegatingDirContext.java
DelegatingDirContext.getInnermostDelegateDirContext
public DirContext getInnermostDelegateDirContext() { final DirContext delegateDirContext = this.getDelegateDirContext(); if (delegateDirContext instanceof DelegatingDirContext) { return ((DelegatingDirContext)delegateDirContext).getInnermostDelegateDirContext(); } return delegateDirContext; }
java
public DirContext getInnermostDelegateDirContext() { final DirContext delegateDirContext = this.getDelegateDirContext(); if (delegateDirContext instanceof DelegatingDirContext) { return ((DelegatingDirContext)delegateDirContext).getInnermostDelegateDirContext(); } return delegateDirContext; }
[ "public", "DirContext", "getInnermostDelegateDirContext", "(", ")", "{", "final", "DirContext", "delegateDirContext", "=", "this", ".", "getDelegateDirContext", "(", ")", ";", "if", "(", "delegateDirContext", "instanceof", "DelegatingDirContext", ")", "{", "return", "...
Recursivley inspect delegates until a non-delegating dir context is found. @return The innermost (real) DirContext that is being delegated to.
[ "Recursivley", "inspect", "delegates", "until", "a", "non", "-", "delegating", "dir", "context", "is", "found", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/pool/DelegatingDirContext.java#L78-L86
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/transaction/compensating/LdapTransactionUtils.java
LdapTransactionUtils.getFirstArgumentAsName
public static Name getFirstArgumentAsName(Object[] args) { Assert.notEmpty(args); Object firstArg = args[0]; return getArgumentAsName(firstArg); }
java
public static Name getFirstArgumentAsName(Object[] args) { Assert.notEmpty(args); Object firstArg = args[0]; return getArgumentAsName(firstArg); }
[ "public", "static", "Name", "getFirstArgumentAsName", "(", "Object", "[", "]", "args", ")", "{", "Assert", ".", "notEmpty", "(", "args", ")", ";", "Object", "firstArg", "=", "args", "[", "0", "]", ";", "return", "getArgumentAsName", "(", "firstArg", ")", ...
Get the first parameter in the argument list as a Name. @param args arguments supplied to a ldap operation. @return a Name representation of the first argument, or the Name itself if it is a name.
[ "Get", "the", "first", "parameter", "in", "the", "argument", "list", "as", "a", "Name", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/transaction/compensating/LdapTransactionUtils.java#L57-L62
train
spring-projects/spring-ldap
core/src/main/java/org/springframework/ldap/transaction/compensating/LdapTransactionUtils.java
LdapTransactionUtils.getArgumentAsName
public static Name getArgumentAsName(Object arg) { if (arg instanceof String) { return LdapUtils.newLdapName((String) arg); } else if (arg instanceof Name) { return (Name) arg; } else { throw new IllegalArgumentException( "First argument needs to be a Name or a String representation thereof"); } }
java
public static Name getArgumentAsName(Object arg) { if (arg instanceof String) { return LdapUtils.newLdapName((String) arg); } else if (arg instanceof Name) { return (Name) arg; } else { throw new IllegalArgumentException( "First argument needs to be a Name or a String representation thereof"); } }
[ "public", "static", "Name", "getArgumentAsName", "(", "Object", "arg", ")", "{", "if", "(", "arg", "instanceof", "String", ")", "{", "return", "LdapUtils", ".", "newLdapName", "(", "(", "String", ")", "arg", ")", ";", "}", "else", "if", "(", "arg", "in...
Get the argument as a Name. @param arg an argument supplied to an Ldap operation. @return a Name representation of the argument, or the Name itself if it is a Name.
[ "Get", "the", "argument", "as", "a", "Name", "." ]
15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0
https://github.com/spring-projects/spring-ldap/blob/15142d4ae18a9dc6b363a1ebf085e2bda9d9a4c0/core/src/main/java/org/springframework/ldap/transaction/compensating/LdapTransactionUtils.java#L72-L81
train