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
urbanairship/datacube
src/main/java/com/urbanairship/datacube/metrics/Metrics.java
Metrics.gauge
public static <T> void gauge(MetricNameDetails nameDetails, final Callable<T> impl) { gauge(nameDetails, new Gauge<T>() { @Override public T getValue() { try { return impl.call(); } catch (Exception ex) { ...
java
public static <T> void gauge(MetricNameDetails nameDetails, final Callable<T> impl) { gauge(nameDetails, new Gauge<T>() { @Override public T getValue() { try { return impl.call(); } catch (Exception ex) { ...
[ "public", "static", "<", "T", ">", "void", "gauge", "(", "MetricNameDetails", "nameDetails", ",", "final", "Callable", "<", "T", ">", "impl", ")", "{", "gauge", "(", "nameDetails", ",", "new", "Gauge", "<", "T", ">", "(", ")", "{", "@", "Override", "...
This doesn't make a ton of sense given the above but it will likely be cleaner in Java8. Also avoids having to catch an exception in a Gauge implementation.
[ "This", "doesn", "t", "make", "a", "ton", "of", "sense", "given", "the", "above", "but", "it", "will", "likely", "be", "cleaner", "in", "Java8", ".", "Also", "avoids", "having", "to", "catch", "an", "exception", "in", "a", "Gauge", "implementation", "." ...
89c6b68744cc384c8b49f921cdb0a0f9f414ada6
https://github.com/urbanairship/datacube/blob/89c6b68744cc384c8b49f921cdb0a0f9f414ada6/src/main/java/com/urbanairship/datacube/metrics/Metrics.java#L148-L160
train
urbanairship/datacube
src/main/java/com/urbanairship/datacube/backfill/BackfillUtil.java
BackfillUtil.getSplitKeys
public static byte[][] getSplitKeys(Pair<byte[][],byte[][]> regionStartsEnds) { byte[][] starts = regionStartsEnds.getFirst(); List<byte[]> splitKeys = new ArrayList<byte[]>(); for(int i=1; i<starts.length; i++) { splitKeys.add(starts[i]); } return splitKeys....
java
public static byte[][] getSplitKeys(Pair<byte[][],byte[][]> regionStartsEnds) { byte[][] starts = regionStartsEnds.getFirst(); List<byte[]> splitKeys = new ArrayList<byte[]>(); for(int i=1; i<starts.length; i++) { splitKeys.add(starts[i]); } return splitKeys....
[ "public", "static", "byte", "[", "]", "[", "]", "getSplitKeys", "(", "Pair", "<", "byte", "[", "]", "[", "]", ",", "byte", "[", "]", "[", "]", ">", "regionStartsEnds", ")", "{", "byte", "[", "]", "[", "]", "starts", "=", "regionStartsEnds", ".", ...
Get the non-null non-null non-zero-length row keys that divide the regions
[ "Get", "the", "non", "-", "null", "non", "-", "null", "non", "-", "zero", "-", "length", "row", "keys", "that", "divide", "the", "regions" ]
89c6b68744cc384c8b49f921cdb0a0f9f414ada6
https://github.com/urbanairship/datacube/blob/89c6b68744cc384c8b49f921cdb0a0f9f414ada6/src/main/java/com/urbanairship/datacube/backfill/BackfillUtil.java#L16-L24
train
urbanairship/datacube
src/main/java/com/urbanairship/datacube/dbharnesses/HbaseBatchIncrementer.java
HbaseBatchIncrementer.processBatchCallresults
private Map<BoxedByteArray, byte[]> processBatchCallresults(List<Map.Entry<BoxedByteArray, T>> entries, Object[] objects) { Map<BoxedByteArray, byte[]> successes = new HashMap<>(); for (int i = 0; i < objects.length; ++i) { if (objects[i] != null && objects[i] instanceof Result) { ...
java
private Map<BoxedByteArray, byte[]> processBatchCallresults(List<Map.Entry<BoxedByteArray, T>> entries, Object[] objects) { Map<BoxedByteArray, byte[]> successes = new HashMap<>(); for (int i = 0; i < objects.length; ++i) { if (objects[i] != null && objects[i] instanceof Result) { ...
[ "private", "Map", "<", "BoxedByteArray", ",", "byte", "[", "]", ">", "processBatchCallresults", "(", "List", "<", "Map", ".", "Entry", "<", "BoxedByteArray", ",", "T", ">", ">", "entries", ",", "Object", "[", "]", "objects", ")", "{", "Map", "<", "Boxe...
Converts the datacube request objects and an array of objects returned from an hbase batch call into the map we use to track success. @param entries The map entries we used to construct the increment request against hbase. @param objects The response to the batch operation @return A map from the serialized {@link Add...
[ "Converts", "the", "datacube", "request", "objects", "and", "an", "array", "of", "objects", "returned", "from", "an", "hbase", "batch", "call", "into", "the", "map", "we", "use", "to", "track", "success", "." ]
89c6b68744cc384c8b49f921cdb0a0f9f414ada6
https://github.com/urbanairship/datacube/blob/89c6b68744cc384c8b49f921cdb0a0f9f414ada6/src/main/java/com/urbanairship/datacube/dbharnesses/HbaseBatchIncrementer.java#L149-L159
train
urbanairship/datacube
src/main/java/com/urbanairship/datacube/DataCubeIo.java
DataCubeIo.runBatch
private Future<?> runBatch(Batch<T> batch) throws InterruptedException { while (true) { try { runBatchMeter.mark(); if (perRollupMetrics) { batch.getMap().forEach((addr, op) -> { if (addr.getSourceRollup().isPresent()) { ...
java
private Future<?> runBatch(Batch<T> batch) throws InterruptedException { while (true) { try { runBatchMeter.mark(); if (perRollupMetrics) { batch.getMap().forEach((addr, op) -> { if (addr.getSourceRollup().isPresent()) { ...
[ "private", "Future", "<", "?", ">", "runBatch", "(", "Batch", "<", "T", ">", "batch", ")", "throws", "InterruptedException", "{", "while", "(", "true", ")", "{", "try", "{", "runBatchMeter", ".", "mark", "(", ")", ";", "if", "(", "perRollupMetrics", ")...
Hand off a batch to the DbHarness layer, retrying on FullQueueException.
[ "Hand", "off", "a", "batch", "to", "the", "DbHarness", "layer", "retrying", "on", "FullQueueException", "." ]
89c6b68744cc384c8b49f921cdb0a0f9f414ada6
https://github.com/urbanairship/datacube/blob/89c6b68744cc384c8b49f921cdb0a0f9f414ada6/src/main/java/com/urbanairship/datacube/DataCubeIo.java#L234-L255
train
urbanairship/datacube
src/main/java/com/urbanairship/datacube/dbharnesses/HBaseDbHarness.java
HBaseDbHarness.runBatchAsync
@Override public Future<?> runBatchAsync(Batch<T> batch, AfterExecute<T> afterExecute) throws FullQueueException { /* * Since ThreadPoolExecutor throws RejectedExecutionException when its queue is full, * we have to backoff and retry if execute() throws RejectedExecutionHandler. ...
java
@Override public Future<?> runBatchAsync(Batch<T> batch, AfterExecute<T> afterExecute) throws FullQueueException { /* * Since ThreadPoolExecutor throws RejectedExecutionException when its queue is full, * we have to backoff and retry if execute() throws RejectedExecutionHandler. ...
[ "@", "Override", "public", "Future", "<", "?", ">", "runBatchAsync", "(", "Batch", "<", "T", ">", "batch", ",", "AfterExecute", "<", "T", ">", "afterExecute", ")", "throws", "FullQueueException", "{", "/* \n * Since ThreadPoolExecutor throws RejectedExecutionE...
Hands off the given batch to the flush executor to be sent to the database soon. Doesn't throw IOException, since batches are just asynchronously submitted for execution, but will throw AsyncException if some previous batch had a RuntimeException. @return a Future that the caller can use to detect when the database IO...
[ "Hands", "off", "the", "given", "batch", "to", "the", "flush", "executor", "to", "be", "sent", "to", "the", "database", "soon", ".", "Doesn", "t", "throw", "IOException", "since", "batches", "are", "just", "asynchronously", "submitted", "for", "execution", "...
89c6b68744cc384c8b49f921cdb0a0f9f414ada6
https://github.com/urbanairship/datacube/blob/89c6b68744cc384c8b49f921cdb0a0f9f414ada6/src/main/java/com/urbanairship/datacube/dbharnesses/HBaseDbHarness.java#L224-L243
train
urbanairship/datacube
src/main/java/com/urbanairship/datacube/DataCube.java
DataCube.getWrites
public Batch<T> getWrites(WriteBuilder writeBuilder, T op) { Map<Address, T> outputMap = Maps.newHashMap(); for (Rollup rollup : rollups) { List<Set<byte[]>> coordSets = new ArrayList<Set<byte[]>>(rollup.getComponents().size()); boolean dimensionHadNoBucket...
java
public Batch<T> getWrites(WriteBuilder writeBuilder, T op) { Map<Address, T> outputMap = Maps.newHashMap(); for (Rollup rollup : rollups) { List<Set<byte[]>> coordSets = new ArrayList<Set<byte[]>>(rollup.getComponents().size()); boolean dimensionHadNoBucket...
[ "public", "Batch", "<", "T", ">", "getWrites", "(", "WriteBuilder", "writeBuilder", ",", "T", "op", ")", "{", "Map", "<", "Address", ",", "T", ">", "outputMap", "=", "Maps", ".", "newHashMap", "(", ")", ";", "for", "(", "Rollup", "rollup", ":", "roll...
Get a batch of writes that, when applied to the database, will make the change given by "op".
[ "Get", "a", "batch", "of", "writes", "that", "when", "applied", "to", "the", "database", "will", "make", "the", "change", "given", "by", "op", "." ]
89c6b68744cc384c8b49f921cdb0a0f9f414ada6
https://github.com/urbanairship/datacube/blob/89c6b68744cc384c8b49f921cdb0a0f9f414ada6/src/main/java/com/urbanairship/datacube/DataCube.java#L94-L156
train
urbanairship/datacube
src/main/java/com/urbanairship/datacube/backfill/HBaseBackfillMerger.java
HBaseBackfillMerger.scansThisCubeOnly
public static List<Scan> scansThisCubeOnly(byte[] keyPrefix, byte[][] splitKeys) throws IOException { Scan copyScan = new Scan(); copyScan.setCaching(5000); copyScan.setCacheBlocks(false); // Hack: generate a key that probably comes after a...
java
public static List<Scan> scansThisCubeOnly(byte[] keyPrefix, byte[][] splitKeys) throws IOException { Scan copyScan = new Scan(); copyScan.setCaching(5000); copyScan.setCacheBlocks(false); // Hack: generate a key that probably comes after a...
[ "public", "static", "List", "<", "Scan", ">", "scansThisCubeOnly", "(", "byte", "[", "]", "keyPrefix", ",", "byte", "[", "]", "[", "]", "splitKeys", ")", "throws", "IOException", "{", "Scan", "copyScan", "=", "new", "Scan", "(", ")", ";", "copyScan", "...
Get a collection of Scans, one per region, that cover the range of the table having the given key prefix. Thes will be used as the map task input splits.
[ "Get", "a", "collection", "of", "Scans", "one", "per", "region", "that", "cover", "the", "range", "of", "the", "table", "having", "the", "given", "key", "prefix", ".", "Thes", "will", "be", "used", "as", "the", "map", "task", "input", "splits", "." ]
89c6b68744cc384c8b49f921cdb0a0f9f414ada6
https://github.com/urbanairship/datacube/blob/89c6b68744cc384c8b49f921cdb0a0f9f414ada6/src/main/java/com/urbanairship/datacube/backfill/HBaseBackfillMerger.java#L160-L193
train
urbanairship/datacube
src/main/java/com/urbanairship/datacube/backfill/HBaseBackfillMerger.java
HBaseBackfillMerger.truncateScan
private static final Scan truncateScan(Scan scan, byte[] rangeStart, byte[] rangeEnd) { byte[] scanStart = scan.getStartRow(); byte[] scanEnd = scan.getStopRow(); if (scanEnd.length > 0 && bytesCompare(scanEnd, rangeStart) <= 0) { // The entire scan range is before the entire cube k...
java
private static final Scan truncateScan(Scan scan, byte[] rangeStart, byte[] rangeEnd) { byte[] scanStart = scan.getStartRow(); byte[] scanEnd = scan.getStopRow(); if (scanEnd.length > 0 && bytesCompare(scanEnd, rangeStart) <= 0) { // The entire scan range is before the entire cube k...
[ "private", "static", "final", "Scan", "truncateScan", "(", "Scan", "scan", ",", "byte", "[", "]", "rangeStart", ",", "byte", "[", "]", "rangeEnd", ")", "{", "byte", "[", "]", "scanStart", "=", "scan", ".", "getStartRow", "(", ")", ";", "byte", "[", "...
Given a scan and a key range, return a new Scan whose range is truncated to only include keys in that range. Returns null if the Scan does not overlap the given range.
[ "Given", "a", "scan", "and", "a", "key", "range", "return", "a", "new", "Scan", "whose", "range", "is", "truncated", "to", "only", "include", "keys", "in", "that", "range", ".", "Returns", "null", "if", "the", "Scan", "does", "not", "overlap", "the", "...
89c6b68744cc384c8b49f921cdb0a0f9f414ada6
https://github.com/urbanairship/datacube/blob/89c6b68744cc384c8b49f921cdb0a0f9f414ada6/src/main/java/com/urbanairship/datacube/backfill/HBaseBackfillMerger.java#L199-L230
train
urbanairship/datacube
src/main/java/com/urbanairship/datacube/dbharnesses/MapDbHarness.java
MapDbHarness.runBatchAsync
@SuppressWarnings("unchecked") @Override public Future<?> runBatchAsync(Batch<T> batch, AfterExecute<T> afterExecute) { for (Map.Entry<Address, T> entry : batch.getMap().entrySet()) { Address address = entry.getKey(); T opFromBatch = entry.getValue(); BoxedByteArray...
java
@SuppressWarnings("unchecked") @Override public Future<?> runBatchAsync(Batch<T> batch, AfterExecute<T> afterExecute) { for (Map.Entry<Address, T> entry : batch.getMap().entrySet()) { Address address = entry.getKey(); T opFromBatch = entry.getValue(); BoxedByteArray...
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "@", "Override", "public", "Future", "<", "?", ">", "runBatchAsync", "(", "Batch", "<", "T", ">", "batch", ",", "AfterExecute", "<", "T", ">", "afterExecute", ")", "{", "for", "(", "Map", ".", "Entry", ...
Actually synchronous and not asyncronous, which is allowed.
[ "Actually", "synchronous", "and", "not", "asyncronous", "which", "is", "allowed", "." ]
89c6b68744cc384c8b49f921cdb0a0f9f414ada6
https://github.com/urbanairship/datacube/blob/89c6b68744cc384c8b49f921cdb0a0f9f414ada6/src/main/java/com/urbanairship/datacube/dbharnesses/MapDbHarness.java#L60-L138
train
urbanairship/datacube
src/main/java/com/urbanairship/datacube/MergeIterator.java
MergeIterator.next
@Override public ListMultimap<Iterator<T>, T> next() { ListMultimap<Iterator<T>, T> results = ArrayListMultimap.create(); while (true) { HeapEntry heapEntry = heap.poll(); if (heapEntry == null) { break; // heap is empty } results.put(i...
java
@Override public ListMultimap<Iterator<T>, T> next() { ListMultimap<Iterator<T>, T> results = ArrayListMultimap.create(); while (true) { HeapEntry heapEntry = heap.poll(); if (heapEntry == null) { break; // heap is empty } results.put(i...
[ "@", "Override", "public", "ListMultimap", "<", "Iterator", "<", "T", ">", ",", "T", ">", "next", "(", ")", "{", "ListMultimap", "<", "Iterator", "<", "T", ">", ",", "T", ">", "results", "=", "ArrayListMultimap", ".", "create", "(", ")", ";", "while"...
Get the next group of results that compare equal. @return a ListMultimap containing the next batch of results that compare equal. The values are grouped together by the iterator they came from. So the map keys are iterators, and the map values are items that came from that iterator.
[ "Get", "the", "next", "group", "of", "results", "that", "compare", "equal", "." ]
89c6b68744cc384c8b49f921cdb0a0f9f414ada6
https://github.com/urbanairship/datacube/blob/89c6b68744cc384c8b49f921cdb0a0f9f414ada6/src/main/java/com/urbanairship/datacube/MergeIterator.java#L89-L123
train
urbanairship/datacube
src/main/java/com/urbanairship/datacube/MergeIterator.java
MergeIterator.nextWrapper
private T nextWrapper(Iterator<T> it) { try { if (trace != null) { trace.add(new TraceEntry(System.nanoTime(), System.currentTimeMillis(), NextOrHasNext.NEXT, debugLabels.get(it))); } return it.next(); } catch (RuntimeException ...
java
private T nextWrapper(Iterator<T> it) { try { if (trace != null) { trace.add(new TraceEntry(System.nanoTime(), System.currentTimeMillis(), NextOrHasNext.NEXT, debugLabels.get(it))); } return it.next(); } catch (RuntimeException ...
[ "private", "T", "nextWrapper", "(", "Iterator", "<", "T", ">", "it", ")", "{", "try", "{", "if", "(", "trace", "!=", "null", ")", "{", "trace", ".", "add", "(", "new", "TraceEntry", "(", "System", ".", "nanoTime", "(", ")", ",", "System", ".", "c...
Get and return the next value from an iterator, and add a tracing record if enabled. Logs tracing info if a RuntimeException occurs.
[ "Get", "and", "return", "the", "next", "value", "from", "an", "iterator", "and", "add", "a", "tracing", "record", "if", "enabled", ".", "Logs", "tracing", "info", "if", "a", "RuntimeException", "occurs", "." ]
89c6b68744cc384c8b49f921cdb0a0f9f414ada6
https://github.com/urbanairship/datacube/blob/89c6b68744cc384c8b49f921cdb0a0f9f414ada6/src/main/java/com/urbanairship/datacube/MergeIterator.java#L157-L168
train
urbanairship/datacube
src/main/java/com/urbanairship/datacube/metrics/ObjectNameFactoryImpl.java
ObjectNameFactoryImpl.createMetrics3Name
private ObjectName createMetrics3Name(String domain, String name) throws MalformedObjectNameException { try { return new ObjectName(domain, "name", name); } catch (MalformedObjectNameException e) { return new ObjectName(domain, "name", ObjectName.quote(name)); } }
java
private ObjectName createMetrics3Name(String domain, String name) throws MalformedObjectNameException { try { return new ObjectName(domain, "name", name); } catch (MalformedObjectNameException e) { return new ObjectName(domain, "name", ObjectName.quote(name)); } }
[ "private", "ObjectName", "createMetrics3Name", "(", "String", "domain", ",", "String", "name", ")", "throws", "MalformedObjectNameException", "{", "try", "{", "return", "new", "ObjectName", "(", "domain", ",", "\"name\"", ",", "name", ")", ";", "}", "catch", "...
Default behavior of Metrics 3 library, for fallback
[ "Default", "behavior", "of", "Metrics", "3", "library", "for", "fallback" ]
89c6b68744cc384c8b49f921cdb0a0f9f414ada6
https://github.com/urbanairship/datacube/blob/89c6b68744cc384c8b49f921cdb0a0f9f414ada6/src/main/java/com/urbanairship/datacube/metrics/ObjectNameFactoryImpl.java#L36-L42
train
urbanairship/datacube
src/main/java/com/urbanairship/datacube/backfill/HBaseBackfillMergeMapper.java
HBaseBackfillMergeMapper.getDeserializer
@SuppressWarnings("unchecked") private static Deserializer<?> getDeserializer(Configuration conf) { String deserializerClassName = conf.get(HBaseBackfillMerger.CONFKEY_DESERIALIZER); if (deserializerClassName == null) { throw new RuntimeException("Configuration didn't set " + deserialize...
java
@SuppressWarnings("unchecked") private static Deserializer<?> getDeserializer(Configuration conf) { String deserializerClassName = conf.get(HBaseBackfillMerger.CONFKEY_DESERIALIZER); if (deserializerClassName == null) { throw new RuntimeException("Configuration didn't set " + deserialize...
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "private", "static", "Deserializer", "<", "?", ">", "getDeserializer", "(", "Configuration", "conf", ")", "{", "String", "deserializerClassName", "=", "conf", ".", "get", "(", "HBaseBackfillMerger", ".", "CONFKEY...
Get the deserializer class name from the job config, instantiate it, and return the instance. @throws RuntimeException if something goes wrong.
[ "Get", "the", "deserializer", "class", "name", "from", "the", "job", "config", "instantiate", "it", "and", "return", "the", "instance", "." ]
89c6b68744cc384c8b49f921cdb0a0f9f414ada6
https://github.com/urbanairship/datacube/blob/89c6b68744cc384c8b49f921cdb0a0f9f414ada6/src/main/java/com/urbanairship/datacube/backfill/HBaseBackfillMergeMapper.java#L140-L161
train
urbanairship/datacube
src/main/java/com/urbanairship/datacube/Util.java
Util.intToBytesWithLen
public static byte[] intToBytesWithLen(int x, int len) { if(len <= 4) { return trailingBytes(intToBytes(x), len); } else { ByteBuffer bb = ByteBuffer.allocate(len); bb.position(len-4); bb.putInt(x); assert bb.remaining() == 0; retur...
java
public static byte[] intToBytesWithLen(int x, int len) { if(len <= 4) { return trailingBytes(intToBytes(x), len); } else { ByteBuffer bb = ByteBuffer.allocate(len); bb.position(len-4); bb.putInt(x); assert bb.remaining() == 0; retur...
[ "public", "static", "byte", "[", "]", "intToBytesWithLen", "(", "int", "x", ",", "int", "len", ")", "{", "if", "(", "len", "<=", "4", ")", "{", "return", "trailingBytes", "(", "intToBytes", "(", "x", ")", ",", "len", ")", ";", "}", "else", "{", "...
Write a big-endian integer into the least significant bytes of a byte array.
[ "Write", "a", "big", "-", "endian", "integer", "into", "the", "least", "significant", "bytes", "of", "a", "byte", "array", "." ]
89c6b68744cc384c8b49f921cdb0a0f9f414ada6
https://github.com/urbanairship/datacube/blob/89c6b68744cc384c8b49f921cdb0a0f9f414ada6/src/main/java/com/urbanairship/datacube/Util.java#L25-L35
train
urbanairship/datacube
src/main/java/com/urbanairship/datacube/Util.java
Util.hashByteArray
public static byte hashByteArray(byte[] array, int startInclusive, int endExclusive) { if (array == null) { return 0; } int range = endExclusive - startInclusive; if (range < 0) { throw new IllegalArgumentException(startInclusive + " > " + endExclusive); ...
java
public static byte hashByteArray(byte[] array, int startInclusive, int endExclusive) { if (array == null) { return 0; } int range = endExclusive - startInclusive; if (range < 0) { throw new IllegalArgumentException(startInclusive + " > " + endExclusive); ...
[ "public", "static", "byte", "hashByteArray", "(", "byte", "[", "]", "array", ",", "int", "startInclusive", ",", "int", "endExclusive", ")", "{", "if", "(", "array", "==", "null", ")", "{", "return", "0", ";", "}", "int", "range", "=", "endExclusive", "...
A utility to allow hashing of a portion of an array without having to copy it. @param array @param startInclusive @param endExclusive @return hash byte
[ "A", "utility", "to", "allow", "hashing", "of", "a", "portion", "of", "an", "array", "without", "having", "to", "copy", "it", "." ]
89c6b68744cc384c8b49f921cdb0a0f9f414ada6
https://github.com/urbanairship/datacube/blob/89c6b68744cc384c8b49f921cdb0a0f9f414ada6/src/main/java/com/urbanairship/datacube/Util.java#L87-L103
train
kohsuke/com4j
runtime/src/main/java/com4j/EventProxy.java
EventProxy.close
public void close() { if(nativeProxy!=0) { new Task<Void>() { public Void call() { Native.unadvise(nativeProxy); return null; } }.execute(); nativeProxy = 0; } }
java
public void close() { if(nativeProxy!=0) { new Task<Void>() { public Void call() { Native.unadvise(nativeProxy); return null; } }.execute(); nativeProxy = 0; } }
[ "public", "void", "close", "(", ")", "{", "if", "(", "nativeProxy", "!=", "0", ")", "{", "new", "Task", "<", "Void", ">", "(", ")", "{", "public", "Void", "call", "(", ")", "{", "Native", ".", "unadvise", "(", "nativeProxy", ")", ";", "return", "...
Terminates the event subscription.
[ "Terminates", "the", "event", "subscription", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/runtime/src/main/java/com4j/EventProxy.java#L46-L56
train
kohsuke/com4j
runtime/src/main/java/com4j/EventProxy.java
EventProxy.getDescriptor
private static <T> EventInterfaceDescriptor<T> getDescriptor(Class<T> t) { EventInterfaceDescriptor<T> r = descriptors.get(t); if(r==null) { r = new EventInterfaceDescriptor<T>(t); descriptors.put(t,r); } return r; }
java
private static <T> EventInterfaceDescriptor<T> getDescriptor(Class<T> t) { EventInterfaceDescriptor<T> r = descriptors.get(t); if(r==null) { r = new EventInterfaceDescriptor<T>(t); descriptors.put(t,r); } return r; }
[ "private", "static", "<", "T", ">", "EventInterfaceDescriptor", "<", "T", ">", "getDescriptor", "(", "Class", "<", "T", ">", "t", ")", "{", "EventInterfaceDescriptor", "<", "T", ">", "r", "=", "descriptors", ".", "get", "(", "t", ")", ";", "if", "(", ...
Gets the descriptor for the given type.
[ "Gets", "the", "descriptor", "for", "the", "given", "type", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/runtime/src/main/java/com4j/EventProxy.java#L96-L103
train
kohsuke/com4j
runtime/src/main/java/com4j/ComThread.java
ComThread.collectGarbage
private void collectGarbage() { // dispose unused objects if any NativePointerPhantomReference toCollect; while((toCollect = (NativePointerPhantomReference)collectableObjects.poll()) != null) { liveComObjects.remove(toCollect); toCollect.clear(); toCollect.releaseNative(); } }
java
private void collectGarbage() { // dispose unused objects if any NativePointerPhantomReference toCollect; while((toCollect = (NativePointerPhantomReference)collectableObjects.poll()) != null) { liveComObjects.remove(toCollect); toCollect.clear(); toCollect.releaseNative(); } }
[ "private", "void", "collectGarbage", "(", ")", "{", "// dispose unused objects if any", "NativePointerPhantomReference", "toCollect", ";", "while", "(", "(", "toCollect", "=", "(", "NativePointerPhantomReference", ")", "collectableObjects", ".", "poll", "(", ")", ")", ...
Cleans up any left over references
[ "Cleans", "up", "any", "left", "over", "references" ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/runtime/src/main/java/com4j/ComThread.java#L198-L206
train
kohsuke/com4j
tlbimp/src/main/java/com4j/tlbimp/TypeBinding.java
TypeBinding.getTypeString
private static String getTypeString(IType t) { if(t==null) return "null"; IPtrType pt = t.queryInterface(IPtrType.class); if(pt!=null) return getTypeString(pt.getPointedAtType())+"*"; IPrimitiveType prim = t.queryInterface(IPrimitiveType.class); if(prim!...
java
private static String getTypeString(IType t) { if(t==null) return "null"; IPtrType pt = t.queryInterface(IPtrType.class); if(pt!=null) return getTypeString(pt.getPointedAtType())+"*"; IPrimitiveType prim = t.queryInterface(IPrimitiveType.class); if(prim!...
[ "private", "static", "String", "getTypeString", "(", "IType", "t", ")", "{", "if", "(", "t", "==", "null", ")", "return", "\"null\"", ";", "IPtrType", "pt", "=", "t", ".", "queryInterface", "(", "IPtrType", ".", "class", ")", ";", "if", "(", "pt", "!...
Returns a human-readable identifier of the type, but it's not necessarily a correct Java id. This is mainly for debugging.
[ "Returns", "a", "human", "-", "readable", "identifier", "of", "the", "type", "but", "it", "s", "not", "necessarily", "a", "correct", "Java", "id", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/tlbimp/src/main/java/com4j/tlbimp/TypeBinding.java#L228-L250
train
kohsuke/com4j
tlbimp/src/main/java/com4j/tlbimp/IndentingWriter.java
CancellableWriter.commit
public void commit() throws IOException { if(!marked) throw new IllegalStateException(); marked = false; super.append(buffer); buffer.setLength(0); }
java
public void commit() throws IOException { if(!marked) throw new IllegalStateException(); marked = false; super.append(buffer); buffer.setLength(0); }
[ "public", "void", "commit", "(", ")", "throws", "IOException", "{", "if", "(", "!", "marked", ")", "throw", "new", "IllegalStateException", "(", ")", ";", "marked", "=", "false", ";", "super", ".", "append", "(", "buffer", ")", ";", "buffer", ".", "set...
Write the pending data.
[ "Write", "the", "pending", "data", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/tlbimp/src/main/java/com4j/tlbimp/IndentingWriter.java#L244-L249
train
kohsuke/com4j
tlbimp/src/main/java/com4j/tlbimp/Generator.java
Generator.generate
public void generate( IWTypeLib lib ) throws BindingException, IOException { LibBinder tli = getTypeLibInfo(lib); if(referenceResolver.suppress(lib)) return; // skip code generation if(generatedTypeLibs.add(tli)) tli.generate(); }
java
public void generate( IWTypeLib lib ) throws BindingException, IOException { LibBinder tli = getTypeLibInfo(lib); if(referenceResolver.suppress(lib)) return; // skip code generation if(generatedTypeLibs.add(tli)) tli.generate(); }
[ "public", "void", "generate", "(", "IWTypeLib", "lib", ")", "throws", "BindingException", ",", "IOException", "{", "LibBinder", "tli", "=", "getTypeLibInfo", "(", "lib", ")", ";", "if", "(", "referenceResolver", ".", "suppress", "(", "lib", ")", ")", "return...
Call this method repeatedly to generate classes from each type library.
[ "Call", "this", "method", "repeatedly", "to", "generate", "classes", "from", "each", "type", "library", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/tlbimp/src/main/java/com4j/tlbimp/Generator.java#L107-L113
train
kohsuke/com4j
tlbimp/src/main/java/com4j/tlbimp/Generator.java
Generator.finish
public void finish() throws IOException { //Map<String,Set<TypeLibInfo>> byPackage = new HashMap<String,Set<TypeLibInfo>>(); //for( TypeLibInfo tli : generatedTypeLibs ) { // Set<TypeLibInfo> s = byPackage.get(tli.packageName); // if(s==null) // byPackage.put(tli.pac...
java
public void finish() throws IOException { //Map<String,Set<TypeLibInfo>> byPackage = new HashMap<String,Set<TypeLibInfo>>(); //for( TypeLibInfo tli : generatedTypeLibs ) { // Set<TypeLibInfo> s = byPackage.get(tli.packageName); // if(s==null) // byPackage.put(tli.pac...
[ "public", "void", "finish", "(", ")", "throws", "IOException", "{", "//Map<String,Set<TypeLibInfo>> byPackage = new HashMap<String,Set<TypeLibInfo>>();", "//for( TypeLibInfo tli : generatedTypeLibs ) {", "// Set<TypeLibInfo> s = byPackage.get(tli.packageName);", "// if(s==null)", "// ...
Finally call this method to wrap things up. <p> In particular this generates the ClassFactory class.
[ "Finally", "call", "this", "method", "to", "wrap", "things", "up", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/tlbimp/src/main/java/com4j/tlbimp/Generator.java#L121-L164
train
kohsuke/com4j
tlbimp/src/main/java/com4j/tlbimp/Generator.java
Generator.getDefaultInterface
ITypeDecl getDefaultInterface( ICoClassDecl t ) { final int count = t.countImplementedInterfaces(); // look for the default interface first. for( int i=0; i<count; i++ ) { IImplementedInterfaceDecl impl = t.getImplementedInterface(i); if(impl.isSource()) c...
java
ITypeDecl getDefaultInterface( ICoClassDecl t ) { final int count = t.countImplementedInterfaces(); // look for the default interface first. for( int i=0; i<count; i++ ) { IImplementedInterfaceDecl impl = t.getImplementedInterface(i); if(impl.isSource()) c...
[ "ITypeDecl", "getDefaultInterface", "(", "ICoClassDecl", "t", ")", "{", "final", "int", "count", "=", "t", ".", "countImplementedInterfaces", "(", ")", ";", "// look for the default interface first.", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", "...
Returns the primary interface for the given co-class. @return null if none is found.
[ "Returns", "the", "primary", "interface", "for", "the", "given", "co", "-", "class", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/tlbimp/src/main/java/com4j/tlbimp/Generator.java#L172-L214
train
kohsuke/com4j
runtime/src/main/java/com4j/ComMethod.java
ComMethod.messageParameters
@SuppressWarnings("unchecked") protected void messageParameters(Object[] args){ for( int i=0; i<args.length; i++ ) { if(args[i] instanceof Holder && params[i].getNoByRef()!=null) { // massage the value of Holder, not the Holder itself Holder h = (Holder)args[i]; ...
java
@SuppressWarnings("unchecked") protected void messageParameters(Object[] args){ for( int i=0; i<args.length; i++ ) { if(args[i] instanceof Holder && params[i].getNoByRef()!=null) { // massage the value of Holder, not the Holder itself Holder h = (Holder)args[i]; ...
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "protected", "void", "messageParameters", "(", "Object", "[", "]", "args", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "args", ".", "length", ";", "i", "++", ")", "{", "if", "(", "a...
Converts the parameters to be more native friendly. @param args the array of objects to be converted.
[ "Converts", "the", "parameters", "to", "be", "more", "native", "friendly", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/runtime/src/main/java/com4j/ComMethod.java#L174-L185
train
kohsuke/com4j
runtime/src/main/java/com4j/ComMethod.java
ComMethod.getDefaultConversion
static NativeType getDefaultConversion(Type t) { if( t instanceof Class ) { Class<?> c = (Class<?>)t; NativeType r = defaultConversions.get(c); if(r!=null) return r; if(Com4jObject.class.isAssignableFrom(c)) return NativeType.ComObject; ...
java
static NativeType getDefaultConversion(Type t) { if( t instanceof Class ) { Class<?> c = (Class<?>)t; NativeType r = defaultConversions.get(c); if(r!=null) return r; if(Com4jObject.class.isAssignableFrom(c)) return NativeType.ComObject; ...
[ "static", "NativeType", "getDefaultConversion", "(", "Type", "t", ")", "{", "if", "(", "t", "instanceof", "Class", ")", "{", "Class", "<", "?", ">", "c", "=", "(", "Class", "<", "?", ">", ")", "t", ";", "NativeType", "r", "=", "defaultConversions", "...
Computes the default conversion for the given type.
[ "Computes", "the", "default", "conversion", "for", "the", "given", "type", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/runtime/src/main/java/com4j/ComMethod.java#L208-L260
train
kohsuke/com4j
runtime/src/main/java/com4j/EnumDictionary.java
EnumDictionary.get
public static <T extends Enum<T>> EnumDictionary<T> get( Class<T> clazz ) { EnumDictionary<T> dic = registry.get(clazz); if(dic==null) { boolean sparse = ComEnum.class.isAssignableFrom(clazz); if(sparse) dic = new Sparse<T>(clazz); else ...
java
public static <T extends Enum<T>> EnumDictionary<T> get( Class<T> clazz ) { EnumDictionary<T> dic = registry.get(clazz); if(dic==null) { boolean sparse = ComEnum.class.isAssignableFrom(clazz); if(sparse) dic = new Sparse<T>(clazz); else ...
[ "public", "static", "<", "T", "extends", "Enum", "<", "T", ">", ">", "EnumDictionary", "<", "T", ">", "get", "(", "Class", "<", "T", ">", "clazz", ")", "{", "EnumDictionary", "<", "T", ">", "dic", "=", "registry", ".", "get", "(", "clazz", ")", "...
Looks up a dictionary from an enum class.
[ "Looks", "up", "a", "dictionary", "from", "an", "enum", "class", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/runtime/src/main/java/com4j/EnumDictionary.java#L25-L37
train
kohsuke/com4j
runtime/src/main/java/com4j/EnumDictionary.java
EnumDictionary.get
static <T extends Enum<T>> T get( Class<T> clazz, int v ) { return get(clazz).constant(v); }
java
static <T extends Enum<T>> T get( Class<T> clazz, int v ) { return get(clazz).constant(v); }
[ "static", "<", "T", "extends", "Enum", "<", "T", ">", ">", "T", "get", "(", "Class", "<", "T", ">", "clazz", ",", "int", "v", ")", "{", "return", "get", "(", "clazz", ")", ".", "constant", "(", "v", ")", ";", "}" ]
Convenience method to be invoked by JNI.
[ "Convenience", "method", "to", "be", "invoked", "by", "JNI", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/runtime/src/main/java/com4j/EnumDictionary.java#L42-L45
train
kohsuke/com4j
runtime/src/main/java/com4j/COM4J.java
COM4J.wrap
public static<T extends Com4jObject> T wrap( final Class<T> primaryInterface, final long ptr ) throws ComException { return new Task<T>() { @Override public T call() { return Wrapper.create(primaryInterface,ptr); } }.execute(); }
java
public static<T extends Com4jObject> T wrap( final Class<T> primaryInterface, final long ptr ) throws ComException { return new Task<T>() { @Override public T call() { return Wrapper.create(primaryInterface,ptr); } }.execute(); }
[ "public", "static", "<", "T", "extends", "Com4jObject", ">", "T", "wrap", "(", "final", "Class", "<", "T", ">", "primaryInterface", ",", "final", "long", "ptr", ")", "throws", "ComException", "{", "return", "new", "Task", "<", "T", ">", "(", ")", "{", ...
Wraps an externally obtained interface pointer into a COM wrapper object. <p> This method doesn't call addRef on the given interface pointer. Instead, this method takes over the ownership of the given pointer. @param primaryInterface The interface type to wrap the pointer into. @param ptr The rar interface pointer va...
[ "Wraps", "an", "externally", "obtained", "interface", "pointer", "into", "a", "COM", "wrapper", "object", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/runtime/src/main/java/com4j/COM4J.java#L135-L143
train
kohsuke/com4j
runtime/src/main/java/com4j/COM4J.java
COM4J.getActiveObject
public static <T extends Com4jObject> T getActiveObject(Class<T> primaryInterface, GUID clsid ) { return new GetActiveObjectTask<T>(clsid,primaryInterface).execute(); }
java
public static <T extends Com4jObject> T getActiveObject(Class<T> primaryInterface, GUID clsid ) { return new GetActiveObjectTask<T>(clsid,primaryInterface).execute(); }
[ "public", "static", "<", "T", "extends", "Com4jObject", ">", "T", "getActiveObject", "(", "Class", "<", "T", ">", "primaryInterface", ",", "GUID", "clsid", ")", "{", "return", "new", "GetActiveObjectTask", "<", "T", ">", "(", "clsid", ",", "primaryInterface"...
Gets an already running object from the running object table. @param <T> the type of the return value and the type parameter of the class object of primaryInterface @param primaryInterface The returned COM object is returned as this interface. Must be non-null. Passing in {@link Com4jObject} allows the caller to crea...
[ "Gets", "an", "already", "running", "object", "from", "the", "running", "object", "table", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/runtime/src/main/java/com4j/COM4J.java#L162-L164
train
kohsuke/com4j
runtime/src/main/java/com4j/COM4J.java
COM4J.getActiveObject
public static <T extends Com4jObject> T getActiveObject(Class<T> primaryInterface, String clsid ) { return getActiveObject(primaryInterface,new GUID(clsid)); }
java
public static <T extends Com4jObject> T getActiveObject(Class<T> primaryInterface, String clsid ) { return getActiveObject(primaryInterface,new GUID(clsid)); }
[ "public", "static", "<", "T", "extends", "Com4jObject", ">", "T", "getActiveObject", "(", "Class", "<", "T", ">", "primaryInterface", ",", "String", "clsid", ")", "{", "return", "getActiveObject", "(", "primaryInterface", ",", "new", "GUID", "(", "clsid", ")...
Gets an already object from the running object table. @param <T> the type of the return value and the type parameter of the class object of primaryInterface @param primaryInterface The returned COM object is returned as this interface. Must be non-null. Passing in {@link Com4jObject} allows the caller to create a new...
[ "Gets", "an", "already", "object", "from", "the", "running", "object", "table", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/runtime/src/main/java/com4j/COM4J.java#L185-L187
train
kohsuke/com4j
runtime/src/main/java/com4j/COM4J.java
COM4J.getObject
public static <T extends Com4jObject> T getObject(Class<T> primaryInterface, String fileName, String progId ) { return new GetObjectTask<T>(fileName,progId,primaryInterface).execute(); }
java
public static <T extends Com4jObject> T getObject(Class<T> primaryInterface, String fileName, String progId ) { return new GetObjectTask<T>(fileName,progId,primaryInterface).execute(); }
[ "public", "static", "<", "T", "extends", "Com4jObject", ">", "T", "getObject", "(", "Class", "<", "T", ">", "primaryInterface", ",", "String", "fileName", ",", "String", "progId", ")", "{", "return", "new", "GetObjectTask", "<", "T", ">", "(", "fileName", ...
Returns a reference to a COM object primarily by loading a file. <p> This method implements the semantics of the {@code GetObject} Visual Basic function. See <a href="http://msdn2.microsoft.com/en-us/library/e9waz863(VS.71).aspx">MSDN reference</a> for its semantics. <p> This function really has three different mode ...
[ "Returns", "a", "reference", "to", "a", "COM", "object", "primarily", "by", "loading", "a", "file", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/runtime/src/main/java/com4j/COM4J.java#L257-L259
train
kohsuke/com4j
runtime/src/main/java/com4j/COM4J.java
COM4J.getIID
public static GUID getIID( Class<?> _interface ) { IID iid = _interface.getAnnotation(IID.class); if(iid==null) throw new IllegalArgumentException(_interface.getName()+" doesn't have @IID annotation"); return new GUID(iid.value()); }
java
public static GUID getIID( Class<?> _interface ) { IID iid = _interface.getAnnotation(IID.class); if(iid==null) throw new IllegalArgumentException(_interface.getName()+" doesn't have @IID annotation"); return new GUID(iid.value()); }
[ "public", "static", "GUID", "getIID", "(", "Class", "<", "?", ">", "_interface", ")", "{", "IID", "iid", "=", "_interface", ".", "getAnnotation", "(", "IID", ".", "class", ")", ";", "if", "(", "iid", "==", "null", ")", "throw", "new", "IllegalArgumentE...
Gets the interface GUID associated with the given interface. <p> This method retrieves the associated {@link IID} annotation from the interface and return it. @param _interface reference to an object that has the {@link IID} annotation. @return always return no-null valid {@link GUID} object. @throws IllegalArgumentE...
[ "Gets", "the", "interface", "GUID", "associated", "with", "the", "given", "interface", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/runtime/src/main/java/com4j/COM4J.java#L306-L311
train
kohsuke/com4j
runtime/src/main/java/com4j/Variant.java
Variant.getType
public Type getType() { int varType = image.getInt(0) & 0xFFFF; return EnumDictionary.get(Type.class).constant(varType); }
java
public Type getType() { int varType = image.getInt(0) & 0xFFFF; return EnumDictionary.get(Type.class).constant(varType); }
[ "public", "Type", "getType", "(", ")", "{", "int", "varType", "=", "image", ".", "getInt", "(", "0", ")", "&", "0xFFFF", ";", "return", "EnumDictionary", ".", "get", "(", "Type", ".", "class", ")", ".", "constant", "(", "varType", ")", ";", "}" ]
Gets the type of the variant. @return The current type of the Variant
[ "Gets", "the", "type", "of", "the", "variant", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/runtime/src/main/java/com4j/Variant.java#L417-L420
train
kohsuke/com4j
runtime/src/main/java/com4j/Variant.java
Variant.getParseableString
public String getParseableString(){ // TODO expand this switch (this.getType()) { case VT_I1: case VT_I2: case VT_I4: case VT_INT: return Integer.toString(this.intValue()); case VT_I8: return Long.toString(this.longValue()); case VT_R4: ...
java
public String getParseableString(){ // TODO expand this switch (this.getType()) { case VT_I1: case VT_I2: case VT_I4: case VT_INT: return Integer.toString(this.intValue()); case VT_I8: return Long.toString(this.longValue()); case VT_R4: ...
[ "public", "String", "getParseableString", "(", ")", "{", "// TODO expand this", "switch", "(", "this", ".", "getType", "(", ")", ")", "{", "case", "VT_I1", ":", "case", "VT_I2", ":", "case", "VT_I4", ":", "case", "VT_INT", ":", "return", "Integer", ".", ...
Generates an String representation of this Variant that can be parsed. @return A parsable String representation of this Variant
[ "Generates", "an", "String", "representation", "of", "this", "Variant", "that", "can", "be", "parsed", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/runtime/src/main/java/com4j/Variant.java#L666-L691
train
kohsuke/com4j
runtime/src/main/java/com4j/Variant.java
Variant.object
public <T extends Com4jObject> T object( final Class<T> type ) { // native method invocation changeType needs to happen in the COM thread, that is responsible for this variant // @see ComCollection#fetch ComThread t = thread != null ? thread : ComThread.get(); return t.execute(new Task<T...
java
public <T extends Com4jObject> T object( final Class<T> type ) { // native method invocation changeType needs to happen in the COM thread, that is responsible for this variant // @see ComCollection#fetch ComThread t = thread != null ? thread : ComThread.get(); return t.execute(new Task<T...
[ "public", "<", "T", "extends", "Com4jObject", ">", "T", "object", "(", "final", "Class", "<", "T", ">", "type", ")", "{", "// native method invocation changeType needs to happen in the COM thread, that is responsible for this variant", "// @see ComCollection#fetch", "ComThread"...
Reads this VARIANT as a COM interface pointer. @param <T> The type of the return value @param type The class object of the type @return The {@link Com4jObject} of the IUnknown interface pointer that this Variant represents.
[ "Reads", "this", "VARIANT", "as", "a", "COM", "interface", "pointer", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/runtime/src/main/java/com4j/Variant.java#L739-L755
train
kohsuke/com4j
runtime/src/main/java/com4j/Variant.java
Variant.toDate
static Date toDate(double d) { GregorianCalendar ret = new GregorianCalendar(1899,11,30); int days = (int)d; d -= days; ret.add(Calendar.DATE,days); d *= 24; int hours = (int)d; ret.add(Calendar.HOUR,hours); d -= hours; d *= 60; // d += 0.5;...
java
static Date toDate(double d) { GregorianCalendar ret = new GregorianCalendar(1899,11,30); int days = (int)d; d -= days; ret.add(Calendar.DATE,days); d *= 24; int hours = (int)d; ret.add(Calendar.HOUR,hours); d -= hours; d *= 60; // d += 0.5;...
[ "static", "Date", "toDate", "(", "double", "d", ")", "{", "GregorianCalendar", "ret", "=", "new", "GregorianCalendar", "(", "1899", ",", "11", ",", "30", ")", ";", "int", "days", "=", "(", "int", ")", "d", ";", "d", "-=", "days", ";", "ret", ".", ...
Called from the native code to assist VT_DATE -> Date conversion.
[ "Called", "from", "the", "native", "code", "to", "assist", "VT_DATE", "-", ">", "Date", "conversion", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/runtime/src/main/java/com4j/Variant.java#L800-L820
train
kohsuke/com4j
runtime/src/main/java/com4j/ComException.java
ComException.cutEOL
private static String cutEOL( String s ) { if(s==null) return "(Unknown error)"; if(s.endsWith("\r\n")) return s.substring(0,s.length()-2); else return s; }
java
private static String cutEOL( String s ) { if(s==null) return "(Unknown error)"; if(s.endsWith("\r\n")) return s.substring(0,s.length()-2); else return s; }
[ "private", "static", "String", "cutEOL", "(", "String", "s", ")", "{", "if", "(", "s", "==", "null", ")", "return", "\"(Unknown error)\"", ";", "if", "(", "s", ".", "endsWith", "(", "\"\\r\\n\"", ")", ")", "return", "s", ".", "substring", "(", "0", "...
Cuts off the end of line characters. @param s the original String @return
[ "Cuts", "off", "the", "end", "of", "line", "characters", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/runtime/src/main/java/com4j/ComException.java#L108-L115
train
kohsuke/com4j
runtime/src/main/java/com4j/ComCollection.java
ComCollection.fetch
private void fetch() { next.clear(); // We need to remember for what thread the IEnumVARIANT was marshaled. Because if we want to interpret this // VARIANT as an interface pointer later on, we need to do this in the same thread! next.thread = e.getComThread(); int r = e.next(1,next)...
java
private void fetch() { next.clear(); // We need to remember for what thread the IEnumVARIANT was marshaled. Because if we want to interpret this // VARIANT as an interface pointer later on, we need to do this in the same thread! next.thread = e.getComThread(); int r = e.next(1,next)...
[ "private", "void", "fetch", "(", ")", "{", "next", ".", "clear", "(", ")", ";", "// We need to remember for what thread the IEnumVARIANT was marshaled. Because if we want to interpret this", "// VARIANT as an interface pointer later on, we need to do this in the same thread!", "next", ...
Fetches the next element.
[ "Fetches", "the", "next", "element", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/runtime/src/main/java/com4j/ComCollection.java#L75-L85
train
kohsuke/com4j
tlbimp/src/main/java/com4j/tlbimp/MethodBinder.java
MethodBinder.getReturnParam
private int getReturnParam() { // look for [retval] attribute for (int i = 0; i < params.length; i++) { if (params[i].isRetval()) { return i; } } // sometimes a COM method has only one [out] param. // treat that as the return value. // this is seen frequently in MSHTML (...
java
private int getReturnParam() { // look for [retval] attribute for (int i = 0; i < params.length; i++) { if (params[i].isRetval()) { return i; } } // sometimes a COM method has only one [out] param. // treat that as the return value. // this is seen frequently in MSHTML (...
[ "private", "int", "getReturnParam", "(", ")", "{", "// look for [retval] attribute", "for", "(", "int", "i", "=", "0", ";", "i", "<", "params", ".", "length", ";", "i", "++", ")", "{", "if", "(", "params", "[", "i", "]", ".", "isRetval", "(", ")", ...
Returns the index of the return value parameter, or -1 if none.
[ "Returns", "the", "index", "of", "the", "return", "value", "parameter", "or", "-", "1", "if", "none", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/tlbimp/src/main/java/com4j/tlbimp/MethodBinder.java#L83-L105
train
kohsuke/com4j
tlbimp/src/main/java/com4j/tlbimp/MethodBinder.java
MethodBinder.declare
private void declare(IndentingWriter o, IParam p) throws BindingException { TypeBinding vb = TypeBinding.bind(g, p.getType(), p.getName()); String javaType = vb.javaType; if (method.isVarArg() && p == params[params.length - 1]) { // use varargs if applicable if (javaType.endsWith("[]")) ...
java
private void declare(IndentingWriter o, IParam p) throws BindingException { TypeBinding vb = TypeBinding.bind(g, p.getType(), p.getName()); String javaType = vb.javaType; if (method.isVarArg() && p == params[params.length - 1]) { // use varargs if applicable if (javaType.endsWith("[]")) ...
[ "private", "void", "declare", "(", "IndentingWriter", "o", ",", "IParam", "p", ")", "throws", "BindingException", "{", "TypeBinding", "vb", "=", "TypeBinding", ".", "bind", "(", "g", ",", "p", ".", "getType", "(", ")", ",", "p", ".", "getName", "(", ")...
Declares a parameter.
[ "Declares", "a", "parameter", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/tlbimp/src/main/java/com4j/tlbimp/MethodBinder.java#L488-L521
train
kohsuke/com4j
tlbimp/src/main/java/com4j/tlbimp/MethodBinder.java
MethodBinder.declareReturnType
protected final void declareReturnType(IndentingWriter o, List<IType> intermediates, boolean usesDefaltValues) throws BindingException { generateAccessModifier(o); if (returnType == null && intermediates == null) { o.print("void "); } else { // we assume that the [retval] param to be passed by ...
java
protected final void declareReturnType(IndentingWriter o, List<IType> intermediates, boolean usesDefaltValues) throws BindingException { generateAccessModifier(o); if (returnType == null && intermediates == null) { o.print("void "); } else { // we assume that the [retval] param to be passed by ...
[ "protected", "final", "void", "declareReturnType", "(", "IndentingWriter", "o", ",", "List", "<", "IType", ">", "intermediates", ",", "boolean", "usesDefaltValues", ")", "throws", "BindingException", "{", "generateAccessModifier", "(", "o", ")", ";", "if", "(", ...
Declares the return type.
[ "Declares", "the", "return", "type", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/tlbimp/src/main/java/com4j/tlbimp/MethodBinder.java#L540-L589
train
kohsuke/com4j
tlbimp/src/main/java/com4j/tlbimp/MethodBinder.java
MethodBinder.getDispInterfaceReturnType
protected final IType getDispInterfaceReturnType() { IType r = method.getReturnType(); // if the return type is HRESULT, bind it to 'void'. // dispinterfaces defined by C++ often uses HRESULT // as the return value IPrimitiveType pt = r.queryInterface(IPrimitiveType.class); if (pt != null && pt...
java
protected final IType getDispInterfaceReturnType() { IType r = method.getReturnType(); // if the return type is HRESULT, bind it to 'void'. // dispinterfaces defined by C++ often uses HRESULT // as the return value IPrimitiveType pt = r.queryInterface(IPrimitiveType.class); if (pt != null && pt...
[ "protected", "final", "IType", "getDispInterfaceReturnType", "(", ")", "{", "IType", "r", "=", "method", ".", "getReturnType", "(", ")", ";", "// if the return type is HRESULT, bind it to 'void'.", "// dispinterfaces defined by C++ often uses HRESULT", "// as the return value", ...
Computes the return type for disp-only interface.
[ "Computes", "the", "return", "type", "for", "disp", "-", "only", "interface", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/tlbimp/src/main/java/com4j/tlbimp/MethodBinder.java#L626-L639
train
kohsuke/com4j
maven-com4j-plugin/src/main/java/com4j/tlbimp/driver/Com4jgenMojo.java
Com4jgenMojo.checkEnv
private void checkEnv() throws MojoExecutionException { // check OS String osName = System.getProperty("os.name"); if (!osName.startsWith("Windows")) { getLog().warn("Wrong OS: " + osName); throw new MojoExecutionException( "Com4j can only be run on a Windows operating system, and you're running: " ...
java
private void checkEnv() throws MojoExecutionException { // check OS String osName = System.getProperty("os.name"); if (!osName.startsWith("Windows")) { getLog().warn("Wrong OS: " + osName); throw new MojoExecutionException( "Com4j can only be run on a Windows operating system, and you're running: " ...
[ "private", "void", "checkEnv", "(", ")", "throws", "MojoExecutionException", "{", "// check OS", "String", "osName", "=", "System", ".", "getProperty", "(", "\"os.name\"", ")", ";", "if", "(", "!", "osName", ".", "startsWith", "(", "\"Windows\"", ")", ")", "...
Check the runtime environment. @throws MojoExecutionException
[ "Check", "the", "runtime", "environment", "." ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/maven-com4j-plugin/src/main/java/com4j/tlbimp/driver/Com4jgenMojo.java#L199-L216
train
kohsuke/com4j
maven-com4j-plugin/src/main/java/com4j/tlbimp/driver/Com4jgenMojo.java
Com4jgenMojo.validate
private void validate() throws MojoExecutionException { if ((file == null && libId == null) || (file != null && libId != null)) { getLog() .warn( "You specified <file> and <libId>. The <libId> always wins."); } // check that COM target exists if (file != null && !file.exists()) { getLog().wa...
java
private void validate() throws MojoExecutionException { if ((file == null && libId == null) || (file != null && libId != null)) { getLog() .warn( "You specified <file> and <libId>. The <libId> always wins."); } // check that COM target exists if (file != null && !file.exists()) { getLog().wa...
[ "private", "void", "validate", "(", ")", "throws", "MojoExecutionException", "{", "if", "(", "(", "file", "==", "null", "&&", "libId", "==", "null", ")", "||", "(", "file", "!=", "null", "&&", "libId", "!=", "null", ")", ")", "{", "getLog", "(", ")",...
Check the configuration from the pom.xml @throws MojoExecutionException
[ "Check", "the", "configuration", "from", "the", "pom", ".", "xml" ]
1e690b805fb0e4e9ef61560e20a56335aecb0b24
https://github.com/kohsuke/com4j/blob/1e690b805fb0e4e9ef61560e20a56335aecb0b24/maven-com4j-plugin/src/main/java/com4j/tlbimp/driver/Com4jgenMojo.java#L223-L236
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/VersionParser.java
VersionParser.parseValidSemVer
static Version parseValidSemVer(String version) { VersionParser parser = new VersionParser(version); return parser.parseValidSemVer(); }
java
static Version parseValidSemVer(String version) { VersionParser parser = new VersionParser(version); return parser.parseValidSemVer(); }
[ "static", "Version", "parseValidSemVer", "(", "String", "version", ")", "{", "VersionParser", "parser", "=", "new", "VersionParser", "(", "version", ")", ";", "return", "parser", ".", "parseValidSemVer", "(", ")", ";", "}" ]
Parses the whole version including pre-release version and build metadata. @param version the version string to parse @return a valid version object @throws IllegalArgumentException if the input string is {@code NULL} or empty @throws ParseException when there is a grammar error @throws UnexpectedCharacterException wh...
[ "Parses", "the", "whole", "version", "including", "pre", "-", "release", "version", "and", "build", "metadata", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/VersionParser.java#L193-L196
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/VersionParser.java
VersionParser.parseVersionCore
static NormalVersion parseVersionCore(String versionCore) { VersionParser parser = new VersionParser(versionCore); return parser.parseVersionCore(); }
java
static NormalVersion parseVersionCore(String versionCore) { VersionParser parser = new VersionParser(versionCore); return parser.parseVersionCore(); }
[ "static", "NormalVersion", "parseVersionCore", "(", "String", "versionCore", ")", "{", "VersionParser", "parser", "=", "new", "VersionParser", "(", "versionCore", ")", ";", "return", "parser", ".", "parseVersionCore", "(", ")", ";", "}" ]
Parses the version core. @param versionCore the version core string to parse @return a valid normal version object @throws IllegalArgumentException if the input string is {@code NULL} or empty @throws ParseException when there is a grammar error @throws UnexpectedCharacterException when encounters an unexpected charac...
[ "Parses", "the", "version", "core", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/VersionParser.java#L207-L210
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/VersionParser.java
VersionParser.parsePreRelease
static MetadataVersion parsePreRelease(String preRelease) { VersionParser parser = new VersionParser(preRelease); return parser.parsePreRelease(); }
java
static MetadataVersion parsePreRelease(String preRelease) { VersionParser parser = new VersionParser(preRelease); return parser.parsePreRelease(); }
[ "static", "MetadataVersion", "parsePreRelease", "(", "String", "preRelease", ")", "{", "VersionParser", "parser", "=", "new", "VersionParser", "(", "preRelease", ")", ";", "return", "parser", ".", "parsePreRelease", "(", ")", ";", "}" ]
Parses the pre-release version. @param preRelease the pre-release version string to parse @return a valid pre-release version object @throws IllegalArgumentException if the input string is {@code NULL} or empty @throws ParseException when there is a grammar error @throws UnexpectedCharacterException when encounters an...
[ "Parses", "the", "pre", "-", "release", "version", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/VersionParser.java#L221-L224
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/VersionParser.java
VersionParser.parseBuild
static MetadataVersion parseBuild(String build) { VersionParser parser = new VersionParser(build); return parser.parseBuild(); }
java
static MetadataVersion parseBuild(String build) { VersionParser parser = new VersionParser(build); return parser.parseBuild(); }
[ "static", "MetadataVersion", "parseBuild", "(", "String", "build", ")", "{", "VersionParser", "parser", "=", "new", "VersionParser", "(", "build", ")", ";", "return", "parser", ".", "parseBuild", "(", ")", ";", "}" ]
Parses the build metadata. @param build the build metadata string to parse @return a valid build metadata object @throws IllegalArgumentException if the input string is {@code NULL} or empty @throws ParseException when there is a grammar error @throws UnexpectedCharacterException when encounters an unexpected characte...
[ "Parses", "the", "build", "metadata", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/VersionParser.java#L235-L238
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/VersionParser.java
VersionParser.consumeNextCharacter
private Character consumeNextCharacter(CharType... expected) { try { return chars.consume(expected); } catch (UnexpectedElementException e) { throw new UnexpectedCharacterException(e); } }
java
private Character consumeNextCharacter(CharType... expected) { try { return chars.consume(expected); } catch (UnexpectedElementException e) { throw new UnexpectedCharacterException(e); } }
[ "private", "Character", "consumeNextCharacter", "(", "CharType", "...", "expected", ")", "{", "try", "{", "return", "chars", ".", "consume", "(", "expected", ")", ";", "}", "catch", "(", "UnexpectedElementException", "e", ")", "{", "throw", "new", "UnexpectedC...
Tries to consume the next character in the stream. @param expected the expected types of the next character @return the next character in the stream @throws UnexpectedCharacterException when encounters an unexpected character type
[ "Tries", "to", "consume", "the", "next", "character", "in", "the", "stream", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/VersionParser.java#L512-L518
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/VersionParser.java
VersionParser.ensureValidLookahead
private void ensureValidLookahead(CharType... expected) { if (!chars.positiveLookahead(expected)) { throw new UnexpectedCharacterException( chars.lookahead(1), chars.currentOffset(), expected ); } }
java
private void ensureValidLookahead(CharType... expected) { if (!chars.positiveLookahead(expected)) { throw new UnexpectedCharacterException( chars.lookahead(1), chars.currentOffset(), expected ); } }
[ "private", "void", "ensureValidLookahead", "(", "CharType", "...", "expected", ")", "{", "if", "(", "!", "chars", ".", "positiveLookahead", "(", "expected", ")", ")", "{", "throw", "new", "UnexpectedCharacterException", "(", "chars", ".", "lookahead", "(", "1"...
Checks if the next character in the stream is valid. @param expected the expected types of the next character @throws UnexpectedCharacterException if the next character is not valid
[ "Checks", "if", "the", "next", "character", "in", "the", "stream", "is", "valid", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/VersionParser.java#L526-L534
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/expr/ExpressionParser.java
ExpressionParser.parse
@Override public Expression parse(String input) { tokens = lexer.tokenize(input); Expression expr = parseSemVerExpression(); consumeNextToken(EOI); return expr; }
java
@Override public Expression parse(String input) { tokens = lexer.tokenize(input); Expression expr = parseSemVerExpression(); consumeNextToken(EOI); return expr; }
[ "@", "Override", "public", "Expression", "parse", "(", "String", "input", ")", "{", "tokens", "=", "lexer", ".", "tokenize", "(", "input", ")", ";", "Expression", "expr", "=", "parseSemVerExpression", "(", ")", ";", "consumeNextToken", "(", "EOI", ")", ";"...
Parses the SemVer Expressions. @param input a string representing the SemVer Expression @return the AST for the SemVer Expressions @throws LexerException when encounters an illegal character @throws UnexpectedTokenException when consumes a token of an unexpected type
[ "Parses", "the", "SemVer", "Expressions", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/expr/ExpressionParser.java#L84-L90
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/expr/ExpressionParser.java
ExpressionParser.isVersionFollowedBy
private boolean isVersionFollowedBy(ElementType<Token> type) { EnumSet<Token.Type> expected = EnumSet.of(NUMERIC, DOT); Iterator<Token> it = tokens.iterator(); Token lookahead = null; while (it.hasNext()) { lookahead = it.next(); if (!expected.contains(lookahead.t...
java
private boolean isVersionFollowedBy(ElementType<Token> type) { EnumSet<Token.Type> expected = EnumSet.of(NUMERIC, DOT); Iterator<Token> it = tokens.iterator(); Token lookahead = null; while (it.hasNext()) { lookahead = it.next(); if (!expected.contains(lookahead.t...
[ "private", "boolean", "isVersionFollowedBy", "(", "ElementType", "<", "Token", ">", "type", ")", "{", "EnumSet", "<", "Token", ".", "Type", ">", "expected", "=", "EnumSet", ".", "of", "(", "NUMERIC", ",", "DOT", ")", ";", "Iterator", "<", "Token", ">", ...
Determines if the version terminals are followed by the specified token type. This method is essentially a {@code lookahead(k)} method which allows to solve the grammar's ambiguities. @param type the token type to check @return {@code true} if the version terminals are followed by the specified token type or {@code f...
[ "Determines", "if", "the", "version", "terminals", "are", "followed", "by", "the", "specified", "token", "type", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/expr/ExpressionParser.java#L438-L449
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/expr/ExpressionParser.java
ExpressionParser.consumeNextToken
private Token consumeNextToken(Token.Type... expected) { try { return tokens.consume(expected); } catch (UnexpectedElementException e) { throw new UnexpectedTokenException(e); } }
java
private Token consumeNextToken(Token.Type... expected) { try { return tokens.consume(expected); } catch (UnexpectedElementException e) { throw new UnexpectedTokenException(e); } }
[ "private", "Token", "consumeNextToken", "(", "Token", ".", "Type", "...", "expected", ")", "{", "try", "{", "return", "tokens", ".", "consume", "(", "expected", ")", ";", "}", "catch", "(", "UnexpectedElementException", "e", ")", "{", "throw", "new", "Unex...
Tries to consume the next token in the stream. @param expected the expected types of the next token @return the next token in the stream @throws UnexpectedTokenException when encounters an unexpected token type
[ "Tries", "to", "consume", "the", "next", "token", "in", "the", "stream", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/expr/ExpressionParser.java#L503-L509
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/expr/Lexer.java
Lexer.tokenize
Stream<Token> tokenize(String input) { List<Token> tokens = new ArrayList<Token>(); int tokenPos = 0; while (!input.isEmpty()) { boolean matched = false; for (Token.Type tokenType : Token.Type.values()) { Matcher matcher = tokenType.pattern.matcher(input);...
java
Stream<Token> tokenize(String input) { List<Token> tokens = new ArrayList<Token>(); int tokenPos = 0; while (!input.isEmpty()) { boolean matched = false; for (Token.Type tokenType : Token.Type.values()) { Matcher matcher = tokenType.pattern.matcher(input);...
[ "Stream", "<", "Token", ">", "tokenize", "(", "String", "input", ")", "{", "List", "<", "Token", ">", "tokens", "=", "new", "ArrayList", "<", "Token", ">", "(", ")", ";", "int", "tokenPos", "=", "0", ";", "while", "(", "!", "input", ".", "isEmpty",...
Tokenizes the specified input string. @param input the input string to tokenize @return a stream of tokens @throws LexerException when encounters an illegal character
[ "Tokenizes", "the", "specified", "input", "string", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/expr/Lexer.java#L196-L223
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/Version.java
Version.incrementMajorVersion
public Version incrementMajorVersion(String preRelease) { return new Version( normal.incrementMajor(), VersionParser.parsePreRelease(preRelease) ); }
java
public Version incrementMajorVersion(String preRelease) { return new Version( normal.incrementMajor(), VersionParser.parsePreRelease(preRelease) ); }
[ "public", "Version", "incrementMajorVersion", "(", "String", "preRelease", ")", "{", "return", "new", "Version", "(", "normal", ".", "incrementMajor", "(", ")", ",", "VersionParser", ".", "parsePreRelease", "(", "preRelease", ")", ")", ";", "}" ]
Increments the major version and appends the pre-release version. @param preRelease the pre-release version to append @return a new instance of the {@code Version} class @throws IllegalArgumentException if the input string is {@code NULL} or empty @throws ParseException when invalid version string is provided @throws ...
[ "Increments", "the", "major", "version", "and", "appends", "the", "pre", "-", "release", "version", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/Version.java#L360-L365
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/Version.java
Version.incrementMinorVersion
public Version incrementMinorVersion(String preRelease) { return new Version( normal.incrementMinor(), VersionParser.parsePreRelease(preRelease) ); }
java
public Version incrementMinorVersion(String preRelease) { return new Version( normal.incrementMinor(), VersionParser.parsePreRelease(preRelease) ); }
[ "public", "Version", "incrementMinorVersion", "(", "String", "preRelease", ")", "{", "return", "new", "Version", "(", "normal", ".", "incrementMinor", "(", ")", ",", "VersionParser", ".", "parsePreRelease", "(", "preRelease", ")", ")", ";", "}" ]
Increments the minor version and appends the pre-release version. @param preRelease the pre-release version to append @return a new instance of the {@code Version} class @throws IllegalArgumentException if the input string is {@code NULL} or empty @throws ParseException when invalid version string is provided @throws ...
[ "Increments", "the", "minor", "version", "and", "appends", "the", "pre", "-", "release", "version", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/Version.java#L385-L390
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/Version.java
Version.incrementPatchVersion
public Version incrementPatchVersion(String preRelease) { return new Version( normal.incrementPatch(), VersionParser.parsePreRelease(preRelease) ); }
java
public Version incrementPatchVersion(String preRelease) { return new Version( normal.incrementPatch(), VersionParser.parsePreRelease(preRelease) ); }
[ "public", "Version", "incrementPatchVersion", "(", "String", "preRelease", ")", "{", "return", "new", "Version", "(", "normal", ".", "incrementPatch", "(", ")", ",", "VersionParser", ".", "parsePreRelease", "(", "preRelease", ")", ")", ";", "}" ]
Increments the patch version and appends the pre-release version. @param preRelease the pre-release version to append @return a new instance of the {@code Version} class @throws IllegalArgumentException if the input string is {@code NULL} or empty @throws ParseException when invalid version string is provided @throws ...
[ "Increments", "the", "patch", "version", "and", "appends", "the", "pre", "-", "release", "version", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/Version.java#L410-L415
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/Version.java
Version.setBuildMetadata
public Version setBuildMetadata(String build) { return new Version(normal, preRelease, VersionParser.parseBuild(build)); }
java
public Version setBuildMetadata(String build) { return new Version(normal, preRelease, VersionParser.parseBuild(build)); }
[ "public", "Version", "setBuildMetadata", "(", "String", "build", ")", "{", "return", "new", "Version", "(", "normal", ",", "preRelease", ",", "VersionParser", ".", "parseBuild", "(", "build", ")", ")", ";", "}" ]
Sets the build metadata. @param build the build metadata to set @return a new instance of the {@code Version} class @throws IllegalArgumentException if the input string is {@code NULL} or empty @throws ParseException when invalid version string is provided @throws UnexpectedCharacterException is a special case of {@co...
[ "Sets", "the", "build", "metadata", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/Version.java#L457-L459
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/Version.java
Version.compareTo
@Override public int compareTo(Version other) { int result = normal.compareTo(other.normal); if (result == 0) { result = preRelease.compareTo(other.preRelease); } return result; }
java
@Override public int compareTo(Version other) { int result = normal.compareTo(other.normal); if (result == 0) { result = preRelease.compareTo(other.preRelease); } return result; }
[ "@", "Override", "public", "int", "compareTo", "(", "Version", "other", ")", "{", "int", "result", "=", "normal", ".", "compareTo", "(", "other", ".", "normal", ")", ";", "if", "(", "result", "==", "0", ")", "{", "result", "=", "preRelease", ".", "co...
Compares this version to the other version. This method does not take into account the versions' build metadata. If you want to compare the versions' build metadata use the {@code Version.compareWithBuildsTo} method or the {@code Version.BUILD_AWARE_ORDER} comparator. @param other the other version to compare to @ret...
[ "Compares", "this", "version", "to", "the", "other", "version", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/Version.java#L624-L631
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/MetadataVersion.java
MetadataVersion.increment
MetadataVersion increment() { String[] ids = idents; String lastId = ids[ids.length - 1]; if (isInt(lastId)) { int intId = Integer.parseInt(lastId); ids[ids.length - 1] = String.valueOf(++intId); } else { ids = Arrays.copyOf(ids, ids.length + 1); ...
java
MetadataVersion increment() { String[] ids = idents; String lastId = ids[ids.length - 1]; if (isInt(lastId)) { int intId = Integer.parseInt(lastId); ids[ids.length - 1] = String.valueOf(++intId); } else { ids = Arrays.copyOf(ids, ids.length + 1); ...
[ "MetadataVersion", "increment", "(", ")", "{", "String", "[", "]", "ids", "=", "idents", ";", "String", "lastId", "=", "ids", "[", "ids", ".", "length", "-", "1", "]", ";", "if", "(", "isInt", "(", "lastId", ")", ")", "{", "int", "intId", "=", "I...
Increments the metadata version. @return a new instance of the {@code MetadataVersion} class
[ "Increments", "the", "metadata", "version", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/MetadataVersion.java#L120-L131
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/MetadataVersion.java
MetadataVersion.compareIdentifierArrays
private int compareIdentifierArrays(String[] otherIdents) { int result = 0; int length = getLeastCommonArrayLength(idents, otherIdents); for (int i = 0; i < length; i++) { result = compareIdentifiers(idents[i], otherIdents[i]); if (result != 0) { break; ...
java
private int compareIdentifierArrays(String[] otherIdents) { int result = 0; int length = getLeastCommonArrayLength(idents, otherIdents); for (int i = 0; i < length; i++) { result = compareIdentifiers(idents[i], otherIdents[i]); if (result != 0) { break; ...
[ "private", "int", "compareIdentifierArrays", "(", "String", "[", "]", "otherIdents", ")", "{", "int", "result", "=", "0", ";", "int", "length", "=", "getLeastCommonArrayLength", "(", "idents", ",", "otherIdents", ")", ";", "for", "(", "int", "i", "=", "0",...
Compares two arrays of identifiers. @param otherIdents the identifiers of the other version @return integer result of comparison compatible with the {@code Comparable.compareTo} method
[ "Compares", "two", "arrays", "of", "identifiers", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/MetadataVersion.java#L198-L208
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/MetadataVersion.java
MetadataVersion.getLeastCommonArrayLength
private int getLeastCommonArrayLength(String[] arr1, String[] arr2) { return arr1.length <= arr2.length ? arr1.length : arr2.length; }
java
private int getLeastCommonArrayLength(String[] arr1, String[] arr2) { return arr1.length <= arr2.length ? arr1.length : arr2.length; }
[ "private", "int", "getLeastCommonArrayLength", "(", "String", "[", "]", "arr1", ",", "String", "[", "]", "arr2", ")", "{", "return", "arr1", ".", "length", "<=", "arr2", ".", "length", "?", "arr1", ".", "length", ":", "arr2", ".", "length", ";", "}" ]
Returns the size of the smallest array. @param arr1 the first array @param arr2 the second array @return the size of the smallest array
[ "Returns", "the", "size", "of", "the", "smallest", "array", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/MetadataVersion.java#L217-L219
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/MetadataVersion.java
MetadataVersion.compareIdentifiers
private int compareIdentifiers(String ident1, String ident2) { if (isInt(ident1) && isInt(ident2)) { return Integer.parseInt(ident1) - Integer.parseInt(ident2); } else { return ident1.compareTo(ident2); } }
java
private int compareIdentifiers(String ident1, String ident2) { if (isInt(ident1) && isInt(ident2)) { return Integer.parseInt(ident1) - Integer.parseInt(ident2); } else { return ident1.compareTo(ident2); } }
[ "private", "int", "compareIdentifiers", "(", "String", "ident1", ",", "String", "ident2", ")", "{", "if", "(", "isInt", "(", "ident1", ")", "&&", "isInt", "(", "ident2", ")", ")", "{", "return", "Integer", ".", "parseInt", "(", "ident1", ")", "-", "Int...
Compares two identifiers. @param ident1 the first identifier @param ident2 the second identifier @return integer result of comparison compatible with the {@code Comparable.compareTo} method
[ "Compares", "two", "identifiers", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/MetadataVersion.java#L229-L235
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/MetadataVersion.java
MetadataVersion.isInt
private boolean isInt(String str) { try { Integer.parseInt(str); } catch (NumberFormatException e) { return false; } return true; }
java
private boolean isInt(String str) { try { Integer.parseInt(str); } catch (NumberFormatException e) { return false; } return true; }
[ "private", "boolean", "isInt", "(", "String", "str", ")", "{", "try", "{", "Integer", ".", "parseInt", "(", "str", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Checks if the specified string is an integer. @param str the string to check @return {@code true} if the specified string is an integer or {@code false} otherwise
[ "Checks", "if", "the", "specified", "string", "is", "an", "integer", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/MetadataVersion.java#L244-L251
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/util/Stream.java
Stream.positiveLookahead
public <T extends ElementType<E>> boolean positiveLookahead(T... expected) { for (ElementType<E> type : expected) { if (type.isMatchedBy(lookahead(1))) { return true; } } return false; }
java
public <T extends ElementType<E>> boolean positiveLookahead(T... expected) { for (ElementType<E> type : expected) { if (type.isMatchedBy(lookahead(1))) { return true; } } return false; }
[ "public", "<", "T", "extends", "ElementType", "<", "E", ">", ">", "boolean", "positiveLookahead", "(", "T", "...", "expected", ")", "{", "for", "(", "ElementType", "<", "E", ">", "type", ":", "expected", ")", "{", "if", "(", "type", ".", "isMatchedBy",...
Checks if the next element in this stream is of the expected types. @param <T> represents the element type of this stream, removes the "unchecked generic array creation for varargs parameter" warnings @param expected the expected types @return {@code true} if the next element is of the expected types or {@code false} ...
[ "Checks", "if", "the", "next", "element", "in", "this", "stream", "is", "of", "the", "expected", "types", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/util/Stream.java#L171-L178
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/util/Stream.java
Stream.positiveLookaheadUntil
public <T extends ElementType<E>> boolean positiveLookaheadUntil( int until, T... expected ) { for (int i = 1; i <= until; i++) { for (ElementType<E> type : expected) { if (type.isMatchedBy(lookahead(i))) { return true; } ...
java
public <T extends ElementType<E>> boolean positiveLookaheadUntil( int until, T... expected ) { for (int i = 1; i <= until; i++) { for (ElementType<E> type : expected) { if (type.isMatchedBy(lookahead(i))) { return true; } ...
[ "public", "<", "T", "extends", "ElementType", "<", "E", ">", ">", "boolean", "positiveLookaheadUntil", "(", "int", "until", ",", "T", "...", "expected", ")", "{", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "until", ";", "i", "++", ")", "{", ...
Checks if there is an element in this stream of the expected types until the specified position. @param <T> represents the element type of this stream, removes the "unchecked generic array creation for varargs parameter" warnings @param until the position until which to search @param expected the expected types @retur...
[ "Checks", "if", "there", "is", "an", "element", "in", "this", "stream", "of", "the", "expected", "types", "until", "the", "specified", "position", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/util/Stream.java#L223-L235
train
zafarkhaja/jsemver
src/main/java/com/github/zafarkhaja/semver/util/Stream.java
Stream.iterator
@Override public Iterator<E> iterator() { return new Iterator<E>() { /** * The index to indicate the current position * of this iterator. * * The starting point is set to the current * value of this stream's offset, so that it ...
java
@Override public Iterator<E> iterator() { return new Iterator<E>() { /** * The index to indicate the current position * of this iterator. * * The starting point is set to the current * value of this stream's offset, so that it ...
[ "@", "Override", "public", "Iterator", "<", "E", ">", "iterator", "(", ")", "{", "return", "new", "Iterator", "<", "E", ">", "(", ")", "{", "/**\n * The index to indicate the current position\n * of this iterator.\n *\n * The st...
Returns an iterator over elements that are left in this stream. @return an iterator of the remaining elements in this stream
[ "Returns", "an", "iterator", "over", "elements", "that", "are", "left", "in", "this", "stream", "." ]
1f4996ea3dab06193c378fd66fd4f8fdc8334cc6
https://github.com/zafarkhaja/jsemver/blob/1f4996ea3dab06193c378fd66fd4f8fdc8334cc6/src/main/java/com/github/zafarkhaja/semver/util/Stream.java#L242-L283
train
konmik/nucleus
nucleus/src/main/java/nucleus/presenter/RxPresenter.java
RxPresenter.start
public void start(int restartableId) { stop(restartableId); requested.add(restartableId); restartableSubscriptions.put(restartableId, restartables.get(restartableId).call()); }
java
public void start(int restartableId) { stop(restartableId); requested.add(restartableId); restartableSubscriptions.put(restartableId, restartables.get(restartableId).call()); }
[ "public", "void", "start", "(", "int", "restartableId", ")", "{", "stop", "(", "restartableId", ")", ";", "requested", ".", "add", "(", "restartableId", ")", ";", "restartableSubscriptions", ".", "put", "(", "restartableId", ",", "restartables", ".", "get", ...
Starts the given restartable. @param restartableId id of the restartable
[ "Starts", "the", "given", "restartable", "." ]
b161484a2bbf66a7896a8c1f61fa7187856ca5f7
https://github.com/konmik/nucleus/blob/b161484a2bbf66a7896a8c1f61fa7187856ca5f7/nucleus/src/main/java/nucleus/presenter/RxPresenter.java#L90-L94
train
konmik/nucleus
nucleus/src/main/java/nucleus/presenter/RxPresenter.java
RxPresenter.stop
public void stop(int restartableId) { requested.remove((Integer) restartableId); Subscription subscription = restartableSubscriptions.get(restartableId); if (subscription != null) subscription.unsubscribe(); }
java
public void stop(int restartableId) { requested.remove((Integer) restartableId); Subscription subscription = restartableSubscriptions.get(restartableId); if (subscription != null) subscription.unsubscribe(); }
[ "public", "void", "stop", "(", "int", "restartableId", ")", "{", "requested", ".", "remove", "(", "(", "Integer", ")", "restartableId", ")", ";", "Subscription", "subscription", "=", "restartableSubscriptions", ".", "get", "(", "restartableId", ")", ";", "if",...
Unsubscribes a restartable @param restartableId id of a restartable.
[ "Unsubscribes", "a", "restartable" ]
b161484a2bbf66a7896a8c1f61fa7187856ca5f7
https://github.com/konmik/nucleus/blob/b161484a2bbf66a7896a8c1f61fa7187856ca5f7/nucleus/src/main/java/nucleus/presenter/RxPresenter.java#L101-L106
train
konmik/nucleus
nucleus/src/main/java/nucleus/presenter/RxPresenter.java
RxPresenter.isUnsubscribed
public boolean isUnsubscribed(int restartableId) { Subscription subscription = restartableSubscriptions.get(restartableId); return subscription == null || subscription.isUnsubscribed(); }
java
public boolean isUnsubscribed(int restartableId) { Subscription subscription = restartableSubscriptions.get(restartableId); return subscription == null || subscription.isUnsubscribed(); }
[ "public", "boolean", "isUnsubscribed", "(", "int", "restartableId", ")", "{", "Subscription", "subscription", "=", "restartableSubscriptions", ".", "get", "(", "restartableId", ")", ";", "return", "subscription", "==", "null", "||", "subscription", ".", "isUnsubscri...
Checks if a restartable is unsubscribed. @param restartableId id of the restartable. @return true if the subscription is null or unsubscribed, false otherwise.
[ "Checks", "if", "a", "restartable", "is", "unsubscribed", "." ]
b161484a2bbf66a7896a8c1f61fa7187856ca5f7
https://github.com/konmik/nucleus/blob/b161484a2bbf66a7896a8c1f61fa7187856ca5f7/nucleus/src/main/java/nucleus/presenter/RxPresenter.java#L114-L117
train
konmik/nucleus
nucleus/src/main/java/nucleus/view/NucleusLayout.java
NucleusLayout.getActivity
public Activity getActivity() { Context context = getContext(); while (!(context instanceof Activity) && context instanceof ContextWrapper) context = ((ContextWrapper) context).getBaseContext(); if (!(context instanceof Activity)) throw new IllegalStateException("Expected...
java
public Activity getActivity() { Context context = getContext(); while (!(context instanceof Activity) && context instanceof ContextWrapper) context = ((ContextWrapper) context).getBaseContext(); if (!(context instanceof Activity)) throw new IllegalStateException("Expected...
[ "public", "Activity", "getActivity", "(", ")", "{", "Context", "context", "=", "getContext", "(", ")", ";", "while", "(", "!", "(", "context", "instanceof", "Activity", ")", "&&", "context", "instanceof", "ContextWrapper", ")", "context", "=", "(", "(", "C...
Returns the unwrapped activity of the view or throws an exception. @return an unwrapped activity
[ "Returns", "the", "unwrapped", "activity", "of", "the", "view", "or", "throws", "an", "exception", "." ]
b161484a2bbf66a7896a8c1f61fa7187856ca5f7
https://github.com/konmik/nucleus/blob/b161484a2bbf66a7896a8c1f61fa7187856ca5f7/nucleus/src/main/java/nucleus/view/NucleusLayout.java#L76-L83
train
konmik/nucleus
nucleus-example-with-fragments/src/main/java/nucleus/example/main/FragmentStack.java
FragmentStack.push
public void push(Fragment fragment) { Fragment top = peek(); if (top != null) { manager.beginTransaction() .setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right) .remove(top) .add(conta...
java
public void push(Fragment fragment) { Fragment top = peek(); if (top != null) { manager.beginTransaction() .setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right) .remove(top) .add(conta...
[ "public", "void", "push", "(", "Fragment", "fragment", ")", "{", "Fragment", "top", "=", "peek", "(", ")", ";", "if", "(", "top", "!=", "null", ")", "{", "manager", ".", "beginTransaction", "(", ")", ".", "setCustomAnimations", "(", "R", ".", "anim", ...
Pushes a fragment to the top of the stack.
[ "Pushes", "a", "fragment", "to", "the", "top", "of", "the", "stack", "." ]
b161484a2bbf66a7896a8c1f61fa7187856ca5f7
https://github.com/konmik/nucleus/blob/b161484a2bbf66a7896a8c1f61fa7187856ca5f7/nucleus-example-with-fragments/src/main/java/nucleus/example/main/FragmentStack.java#L46-L64
train
konmik/nucleus
nucleus-example-with-fragments/src/main/java/nucleus/example/main/FragmentStack.java
FragmentStack.replace
public void replace(Fragment fragment) { manager.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); manager.beginTransaction() .replace(containerId, fragment, indexToTag(0)) .commit(); manager.executePendingTransactions(); }
java
public void replace(Fragment fragment) { manager.popBackStackImmediate(null, FragmentManager.POP_BACK_STACK_INCLUSIVE); manager.beginTransaction() .replace(containerId, fragment, indexToTag(0)) .commit(); manager.executePendingTransactions(); }
[ "public", "void", "replace", "(", "Fragment", "fragment", ")", "{", "manager", ".", "popBackStackImmediate", "(", "null", ",", "FragmentManager", ".", "POP_BACK_STACK_INCLUSIVE", ")", ";", "manager", ".", "beginTransaction", "(", ")", ".", "replace", "(", "conta...
Replaces stack contents with just one fragment.
[ "Replaces", "stack", "contents", "with", "just", "one", "fragment", "." ]
b161484a2bbf66a7896a8c1f61fa7187856ca5f7
https://github.com/konmik/nucleus/blob/b161484a2bbf66a7896a8c1f61fa7187856ca5f7/nucleus-example-with-fragments/src/main/java/nucleus/example/main/FragmentStack.java#L98-L104
train
konmik/nucleus
nucleus-example-with-fragments/src/main/java/nucleus/example/main/FragmentStack.java
FragmentStack.findCallback
@SuppressWarnings("unchecked") public <T> T findCallback(Fragment fragment, Class<T> callbackType) { Fragment back = getBackFragment(fragment); if (back != null && callbackType.isAssignableFrom(back.getClass())) return (T)back; if (callbackType.isAssignableFrom(activity.getCla...
java
@SuppressWarnings("unchecked") public <T> T findCallback(Fragment fragment, Class<T> callbackType) { Fragment back = getBackFragment(fragment); if (back != null && callbackType.isAssignableFrom(back.getClass())) return (T)back; if (callbackType.isAssignableFrom(activity.getCla...
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "<", "T", ">", "T", "findCallback", "(", "Fragment", "fragment", ",", "Class", "<", "T", ">", "callbackType", ")", "{", "Fragment", "back", "=", "getBackFragment", "(", "fragment", ")", ";", "if...
Returns a back fragment if the fragment is of given class. If such fragment does not exist and activity implements the given class then the activity will be returned. @param fragment a fragment to search from. @param callbackType a class of type for callback to search. @param <T> a type of callback. @retu...
[ "Returns", "a", "back", "fragment", "if", "the", "fragment", "is", "of", "given", "class", ".", "If", "such", "fragment", "does", "not", "exist", "and", "activity", "implements", "the", "given", "class", "then", "the", "activity", "will", "be", "returned", ...
b161484a2bbf66a7896a8c1f61fa7187856ca5f7
https://github.com/konmik/nucleus/blob/b161484a2bbf66a7896a8c1f61fa7187856ca5f7/nucleus-example-with-fragments/src/main/java/nucleus/example/main/FragmentStack.java#L122-L134
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/msg/ReadCoilsResponse.java
ReadCoilsResponse.setCoilStatus
public void setCoilStatus(int index, boolean b) { if (index < 0) { throw new IllegalArgumentException(index + " < 0"); } if (index > coils.size()) { throw new IndexOutOfBoundsException(index + " > " + coils.size()); } coils.setBit(index, b); }
java
public void setCoilStatus(int index, boolean b) { if (index < 0) { throw new IllegalArgumentException(index + " < 0"); } if (index > coils.size()) { throw new IndexOutOfBoundsException(index + " > " + coils.size()); } coils.setBit(index, b); }
[ "public", "void", "setCoilStatus", "(", "int", "index", ",", "boolean", "b", ")", "{", "if", "(", "index", "<", "0", ")", "{", "throw", "new", "IllegalArgumentException", "(", "index", "+", "\" < 0\"", ")", ";", "}", "if", "(", "index", ">", "coils", ...
Sets the status of the given coil. @param index the index of the coil to be set. @param b true if to be set, false for reset.
[ "Sets", "the", "status", "of", "the", "given", "coil", "." ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/msg/ReadCoilsResponse.java#L131-L141
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/io/ModbusTCPTransaction.java
ModbusTCPTransaction.responseIsInValid
private boolean responseIsInValid() { if (response == null) { return true; } else if (!response.isHeadless() && validityCheck) { return request.getTransactionID() != response.getTransactionID(); } else { return false; } }
java
private boolean responseIsInValid() { if (response == null) { return true; } else if (!response.isHeadless() && validityCheck) { return request.getTransactionID() != response.getTransactionID(); } else { return false; } }
[ "private", "boolean", "responseIsInValid", "(", ")", "{", "if", "(", "response", "==", "null", ")", "{", "return", "true", ";", "}", "else", "if", "(", "!", "response", ".", "isHeadless", "(", ")", "&&", "validityCheck", ")", "{", "return", "request", ...
Returns true if the response is not valid This can be if the response is null or the transaction ID of the request doesn't match the reponse @return True if invalid
[ "Returns", "true", "if", "the", "response", "is", "not", "valid", "This", "can", "be", "if", "the", "response", "is", "null", "or", "the", "transaction", "ID", "of", "the", "request", "doesn", "t", "match", "the", "reponse" ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/ModbusTCPTransaction.java#L215-L225
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/msg/ModbusRequest.java
ModbusRequest.updateResponseWithHeader
ModbusResponse updateResponseWithHeader(ModbusResponse response, boolean ignoreFunctionCode) { // transfer header data response.setHeadless(isHeadless()); if (!isHeadless()) { response.setTransactionID(getTransactionID()); response.setProtocolID(getProtocolID()); ...
java
ModbusResponse updateResponseWithHeader(ModbusResponse response, boolean ignoreFunctionCode) { // transfer header data response.setHeadless(isHeadless()); if (!isHeadless()) { response.setTransactionID(getTransactionID()); response.setProtocolID(getProtocolID()); ...
[ "ModbusResponse", "updateResponseWithHeader", "(", "ModbusResponse", "response", ",", "boolean", "ignoreFunctionCode", ")", "{", "// transfer header data", "response", ".", "setHeadless", "(", "isHeadless", "(", ")", ")", ";", "if", "(", "!", "isHeadless", "(", ")",...
Updates the response with the header information to match the request @param response Response to update @param ignoreFunctionCode True if the function code should stay unmolested @return Updated response
[ "Updates", "the", "response", "with", "the", "header", "information", "to", "match", "the", "request" ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/msg/ModbusRequest.java#L172-L188
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/io/FastByteArrayInputStream.java
FastByteArrayInputStream.getBufferBytes
public synchronized byte[] getBufferBytes() { byte[] dest = new byte[count]; System.arraycopy(buf, 0, dest, 0, dest.length); return dest; }
java
public synchronized byte[] getBufferBytes() { byte[] dest = new byte[count]; System.arraycopy(buf, 0, dest, 0, dest.length); return dest; }
[ "public", "synchronized", "byte", "[", "]", "getBufferBytes", "(", ")", "{", "byte", "[", "]", "dest", "=", "new", "byte", "[", "count", "]", ";", "System", ".", "arraycopy", "(", "buf", ",", "0", ",", "dest", ",", "0", ",", "dest", ".", "length", ...
Returns the underlying data being read. @return the underlying data.
[ "Returns", "the", "underlying", "data", "being", "read", "." ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/FastByteArrayInputStream.java#L142-L146
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/util/ThreadPool.java
ThreadPool.initPool
public void initPool(String name) { running = true; for (int i = size; --i >= 0; ) { PoolThread thread = new PoolThread(); threadPool.add(thread); thread.setName(String.format("%s Handler", name)); thread.start(); } }
java
public void initPool(String name) { running = true; for (int i = size; --i >= 0; ) { PoolThread thread = new PoolThread(); threadPool.add(thread); thread.setName(String.format("%s Handler", name)); thread.start(); } }
[ "public", "void", "initPool", "(", "String", "name", ")", "{", "running", "=", "true", ";", "for", "(", "int", "i", "=", "size", ";", "--", "i", ">=", "0", ";", ")", "{", "PoolThread", "thread", "=", "new", "PoolThread", "(", ")", ";", "threadPool"...
Initializes the pool, populating it with n started threads. @param name Name to give each thread
[ "Initializes", "the", "pool", "populating", "it", "with", "n", "started", "threads", "." ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/util/ThreadPool.java#L73-L81
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/util/ThreadPool.java
ThreadPool.close
public void close() { if (running) { taskPool.clear(); running = false; for (PoolThread thread : threadPool) { thread.interrupt(); } } }
java
public void close() { if (running) { taskPool.clear(); running = false; for (PoolThread thread : threadPool) { thread.interrupt(); } } }
[ "public", "void", "close", "(", ")", "{", "if", "(", "running", ")", "{", "taskPool", ".", "clear", "(", ")", ";", "running", "=", "false", ";", "for", "(", "PoolThread", "thread", ":", "threadPool", ")", "{", "thread", ".", "interrupt", "(", ")", ...
Shutdown the pool of threads
[ "Shutdown", "the", "pool", "of", "threads" ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/util/ThreadPool.java#L86-L94
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/facade/ModbusTCPMaster.java
ModbusTCPMaster.setReconnecting
public synchronized void setReconnecting(boolean b) { reconnecting = b; if (transaction != null) { ((ModbusTCPTransaction)transaction).setReconnecting(b); } }
java
public synchronized void setReconnecting(boolean b) { reconnecting = b; if (transaction != null) { ((ModbusTCPTransaction)transaction).setReconnecting(b); } }
[ "public", "synchronized", "void", "setReconnecting", "(", "boolean", "b", ")", "{", "reconnecting", "=", "b", ";", "if", "(", "transaction", "!=", "null", ")", "{", "(", "(", "ModbusTCPTransaction", ")", "transaction", ")", ".", "setReconnecting", "(", "b", ...
Sets the flag that specifies whether to maintain a constant connection or reconnect for every transaction. @param b true if a new connection should be established for each transaction, false otherwise.
[ "Sets", "the", "flag", "that", "specifies", "whether", "to", "maintain", "a", "constant", "connection", "or", "reconnect", "for", "every", "transaction", "." ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/facade/ModbusTCPMaster.java#L171-L176
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/msg/IllegalFunctionRequest.java
IllegalFunctionRequest.readData
public void readData(DataInput din) throws IOException { // skip all following bytes int length = getDataLength(); for (int i = 0; i < length; i++) { din.readByte(); } }
java
public void readData(DataInput din) throws IOException { // skip all following bytes int length = getDataLength(); for (int i = 0; i < length; i++) { din.readByte(); } }
[ "public", "void", "readData", "(", "DataInput", "din", ")", "throws", "IOException", "{", "// skip all following bytes", "int", "length", "=", "getDataLength", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "length", ";", "i", "++", ")",...
Read all of the data that can be read. This is an unsupported function, so it may not be possible to know exactly how much data needs to be read. @throws java.io.IOException If the data cannot be read from the socket/port
[ "Read", "all", "of", "the", "data", "that", "can", "be", "read", ".", "This", "is", "an", "unsupported", "function", "so", "it", "may", "not", "be", "possible", "to", "know", "exactly", "how", "much", "data", "needs", "to", "be", "read", "." ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/msg/IllegalFunctionRequest.java#L92-L98
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/util/SerialParameters.java
SerialParameters.setEncoding
public void setEncoding(String enc) { if (!ModbusUtil.isBlank(enc) && (enc.equalsIgnoreCase(Modbus.SERIAL_ENCODING_ASCII) || enc.equalsIgnoreCase(Modbus.SERIAL_ENCODING_RTU))) { encoding = enc; } else { encoding = Modbus.DEFAULT_SERIAL_ENCODING; } ...
java
public void setEncoding(String enc) { if (!ModbusUtil.isBlank(enc) && (enc.equalsIgnoreCase(Modbus.SERIAL_ENCODING_ASCII) || enc.equalsIgnoreCase(Modbus.SERIAL_ENCODING_RTU))) { encoding = enc; } else { encoding = Modbus.DEFAULT_SERIAL_ENCODING; } ...
[ "public", "void", "setEncoding", "(", "String", "enc", ")", "{", "if", "(", "!", "ModbusUtil", ".", "isBlank", "(", "enc", ")", "&&", "(", "enc", ".", "equalsIgnoreCase", "(", "Modbus", ".", "SERIAL_ENCODING_ASCII", ")", "||", "enc", ".", "equalsIgnoreCase...
Sets the encoding to be used. @param enc the encoding as string. @see Modbus#SERIAL_ENCODING_ASCII @see Modbus#SERIAL_ENCODING_RTU
[ "Sets", "the", "encoding", "to", "be", "used", "." ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/util/SerialParameters.java#L430-L438
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/io/ModbusTransaction.java
ModbusTransaction.checkValidity
void checkValidity() throws ModbusException { if (request != null && response != null) { if (request.getUnitID() != response.getUnitID()) { throw new ModbusIOException("Unit ID mismatch - Request [%s] Response [%s]", request.getHexMessage(), response.getHexMessage()); } ...
java
void checkValidity() throws ModbusException { if (request != null && response != null) { if (request.getUnitID() != response.getUnitID()) { throw new ModbusIOException("Unit ID mismatch - Request [%s] Response [%s]", request.getHexMessage(), response.getHexMessage()); } ...
[ "void", "checkValidity", "(", ")", "throws", "ModbusException", "{", "if", "(", "request", "!=", "null", "&&", "response", "!=", "null", ")", "{", "if", "(", "request", ".", "getUnitID", "(", ")", "!=", "response", ".", "getUnitID", "(", ")", ")", "{",...
Checks the validity of the transaction, by checking if the values of the response correspond to the values of the request. @throws ModbusException if the transaction is not valid.
[ "Checks", "the", "validity", "of", "the", "transaction", "by", "checking", "if", "the", "values", "of", "the", "response", "correspond", "to", "the", "values", "of", "the", "request", "." ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/ModbusTransaction.java#L165-L174
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/io/FastByteArrayOutputStream.java
FastByteArrayOutputStream.toByteArray
public void toByteArray(byte[] toBuf, int offset) { int toLen = (toBuf.length > count) ? count : toBuf.length; System.arraycopy(buf, offset, toBuf, offset, toLen - offset); }
java
public void toByteArray(byte[] toBuf, int offset) { int toLen = (toBuf.length > count) ? count : toBuf.length; System.arraycopy(buf, offset, toBuf, offset, toLen - offset); }
[ "public", "void", "toByteArray", "(", "byte", "[", "]", "toBuf", ",", "int", "offset", ")", "{", "int", "toLen", "=", "(", "toBuf", ".", "length", ">", "count", ")", "?", "count", ":", "toBuf", ".", "length", ";", "System", ".", "arraycopy", "(", "...
Copy the buffered data to the given array. @param toBuf the buffer to hold a copy of the data. @param offset the offset at which to start copying.
[ "Copy", "the", "buffered", "data", "to", "the", "given", "array", "." ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/FastByteArrayOutputStream.java#L203-L206
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/io/FastByteArrayOutputStream.java
FastByteArrayOutputStream.makeSpace
public void makeSpace(int sizeNeeded) { int needed = count + sizeNeeded - buf.length; if (needed > 0) { bump(needed); } }
java
public void makeSpace(int sizeNeeded) { int needed = count + sizeNeeded - buf.length; if (needed > 0) { bump(needed); } }
[ "public", "void", "makeSpace", "(", "int", "sizeNeeded", ")", "{", "int", "needed", "=", "count", "+", "sizeNeeded", "-", "buf", ".", "length", ";", "if", "(", "needed", ">", "0", ")", "{", "bump", "(", "needed", ")", ";", "}", "}" ]
Ensure that at least the given number of bytes are available in the internal buffer. @param sizeNeeded the number of bytes desired.
[ "Ensure", "that", "at", "least", "the", "given", "number", "of", "bytes", "are", "available", "in", "the", "internal", "buffer", "." ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/FastByteArrayOutputStream.java#L244-L249
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/io/ModbusRTUTransport.java
ModbusRTUTransport.readRequestData
private void readRequestData(int byteCount, BytesOutputStream out) throws IOException { byteCount += 2; byte inpBuf[] = new byte[byteCount]; readBytes(inpBuf, byteCount); out.write(inpBuf, 0, byteCount); }
java
private void readRequestData(int byteCount, BytesOutputStream out) throws IOException { byteCount += 2; byte inpBuf[] = new byte[byteCount]; readBytes(inpBuf, byteCount); out.write(inpBuf, 0, byteCount); }
[ "private", "void", "readRequestData", "(", "int", "byteCount", ",", "BytesOutputStream", "out", ")", "throws", "IOException", "{", "byteCount", "+=", "2", ";", "byte", "inpBuf", "[", "]", "=", "new", "byte", "[", "byteCount", "]", ";", "readBytes", "(", "i...
Read the data for a request of a given fixed size @param byteCount Byte count excluding the 2 byte CRC @param out Output buffer to populate @throws IOException If data cannot be read from the port
[ "Read", "the", "data", "for", "a", "request", "of", "a", "given", "fixed", "size" ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/ModbusRTUTransport.java#L56-L61
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/io/ModbusRTUTransport.java
ModbusRTUTransport.getRequest
private void getRequest(int function, BytesOutputStream out) throws IOException { int byteCount; byte inpBuf[] = new byte[256]; try { if ((function & 0x80) == 0) { switch (function) { case Modbus.READ_EXCEPTION_STATUS: case Modb...
java
private void getRequest(int function, BytesOutputStream out) throws IOException { int byteCount; byte inpBuf[] = new byte[256]; try { if ((function & 0x80) == 0) { switch (function) { case Modbus.READ_EXCEPTION_STATUS: case Modb...
[ "private", "void", "getRequest", "(", "int", "function", ",", "BytesOutputStream", "out", ")", "throws", "IOException", "{", "int", "byteCount", ";", "byte", "inpBuf", "[", "]", "=", "new", "byte", "[", "256", "]", ";", "try", "{", "if", "(", "(", "fun...
getRequest - Read a request, after the unit and function code @param function - Modbus function code @param out - Byte stream buffer to hold actual message
[ "getRequest", "-", "Read", "a", "request", "after", "the", "unit", "and", "function", "code" ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/ModbusRTUTransport.java#L69-L133
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/io/ModbusRTUTransport.java
ModbusRTUTransport.writeMessageOut
protected void writeMessageOut(ModbusMessage msg) throws ModbusIOException { try { int len; synchronized (byteOutputStream) { // first clear any input from the receive buffer to prepare // for the reply since RTU doesn't have message delimiters ...
java
protected void writeMessageOut(ModbusMessage msg) throws ModbusIOException { try { int len; synchronized (byteOutputStream) { // first clear any input from the receive buffer to prepare // for the reply since RTU doesn't have message delimiters ...
[ "protected", "void", "writeMessageOut", "(", "ModbusMessage", "msg", ")", "throws", "ModbusIOException", "{", "try", "{", "int", "len", ";", "synchronized", "(", "byteOutputStream", ")", "{", "// first clear any input from the receive buffer to prepare", "// for the reply s...
Writes the Modbus message to the comms port @param msg a <code>ModbusMessage</code> value @throws ModbusIOException If an error occurred bundling the message
[ "Writes", "the", "Modbus", "message", "to", "the", "comms", "port" ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/ModbusRTUTransport.java#L245-L277
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/io/ModbusRTUTransport.java
ModbusRTUTransport.readResponseIn
protected ModbusResponse readResponseIn() throws ModbusIOException { boolean done; ModbusResponse response; int dlength; try { do { // 1. read to function code, create request and read function // specific bytes synchronized (b...
java
protected ModbusResponse readResponseIn() throws ModbusIOException { boolean done; ModbusResponse response; int dlength; try { do { // 1. read to function code, create request and read function // specific bytes synchronized (b...
[ "protected", "ModbusResponse", "readResponseIn", "(", ")", "throws", "ModbusIOException", "{", "boolean", "done", ";", "ModbusResponse", "response", ";", "int", "dlength", ";", "try", "{", "do", "{", "// 1. read to function code, create request and read function", "// spe...
readResponse - Read the bytes for the response from the slave. @return a <tt>ModbusRespose</tt> @throws com.ghgande.j2mod.modbus.ModbusIOException If the response cannot be read from the socket/port
[ "readResponse", "-", "Read", "the", "bytes", "for", "the", "response", "from", "the", "slave", "." ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/ModbusRTUTransport.java#L406-L466
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/slave/ModbusSlaveFactory.java
ModbusSlaveFactory.createUDPSlave
public static synchronized ModbusSlave createUDPSlave(InetAddress address, int port) throws ModbusException { String key = ModbusSlaveType.UDP.getKey(port); if (slaves.containsKey(key)) { return slaves.get(key); } else { ModbusSlave slave = new ModbusSlave(address...
java
public static synchronized ModbusSlave createUDPSlave(InetAddress address, int port) throws ModbusException { String key = ModbusSlaveType.UDP.getKey(port); if (slaves.containsKey(key)) { return slaves.get(key); } else { ModbusSlave slave = new ModbusSlave(address...
[ "public", "static", "synchronized", "ModbusSlave", "createUDPSlave", "(", "InetAddress", "address", ",", "int", "port", ")", "throws", "ModbusException", "{", "String", "key", "=", "ModbusSlaveType", ".", "UDP", ".", "getKey", "(", "port", ")", ";", "if", "(",...
Creates a UDP modbus slave or returns the one already allocated to this port @param address IP address to listen on @param port Port to listen on @return new or existing UDP modbus slave associated with the port @throws ModbusException If a problem occurs e.g. port already in use
[ "Creates", "a", "UDP", "modbus", "slave", "or", "returns", "the", "one", "already", "allocated", "to", "this", "port" ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/slave/ModbusSlaveFactory.java#L114-L124
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/slave/ModbusSlaveFactory.java
ModbusSlaveFactory.createSerialSlave
public static synchronized ModbusSlave createSerialSlave(SerialParameters serialParams) throws ModbusException { ModbusSlave slave = null; if (serialParams == null) { throw new ModbusException("Serial parameters are null"); } else if (ModbusUtil.isBlank(serialParams.getPortNa...
java
public static synchronized ModbusSlave createSerialSlave(SerialParameters serialParams) throws ModbusException { ModbusSlave slave = null; if (serialParams == null) { throw new ModbusException("Serial parameters are null"); } else if (ModbusUtil.isBlank(serialParams.getPortNa...
[ "public", "static", "synchronized", "ModbusSlave", "createSerialSlave", "(", "SerialParameters", "serialParams", ")", "throws", "ModbusException", "{", "ModbusSlave", "slave", "=", "null", ";", "if", "(", "serialParams", "==", "null", ")", "{", "throw", "new", "Mo...
Creates a serial modbus slave or returns the one already allocated to this port @param serialParams Serial parameters for serial type slaves @return new or existing Serial modbus slave associated with the port @throws ModbusException If a problem occurs e.g. port already in use
[ "Creates", "a", "serial", "modbus", "slave", "or", "returns", "the", "one", "already", "allocated", "to", "this", "port" ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/slave/ModbusSlaveFactory.java#L134-L161
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/slave/ModbusSlaveFactory.java
ModbusSlaveFactory.close
public static void close(ModbusSlave slave) { if (slave != null) { slave.closeListener(); slaves.remove(slave.getType().getKey(slave.getPort())); } }
java
public static void close(ModbusSlave slave) { if (slave != null) { slave.closeListener(); slaves.remove(slave.getType().getKey(slave.getPort())); } }
[ "public", "static", "void", "close", "(", "ModbusSlave", "slave", ")", "{", "if", "(", "slave", "!=", "null", ")", "{", "slave", ".", "closeListener", "(", ")", ";", "slaves", ".", "remove", "(", "slave", ".", "getType", "(", ")", ".", "getKey", "(",...
Closes this slave and removes it from the running list @param slave Slave to remove
[ "Closes", "this", "slave", "and", "removes", "it", "from", "the", "running", "list" ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/slave/ModbusSlaveFactory.java#L168-L173
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/slave/ModbusSlaveFactory.java
ModbusSlaveFactory.getSlave
public static ModbusSlave getSlave(String port) { return ModbusUtil.isBlank(port) ? null : slaves.get(port); }
java
public static ModbusSlave getSlave(String port) { return ModbusUtil.isBlank(port) ? null : slaves.get(port); }
[ "public", "static", "ModbusSlave", "getSlave", "(", "String", "port", ")", "{", "return", "ModbusUtil", ".", "isBlank", "(", "port", ")", "?", "null", ":", "slaves", ".", "get", "(", "port", ")", ";", "}" ]
Returns the running slave listening on the given serial port @param port Port to check for running slave @return Null or ModbusSlave
[ "Returns", "the", "running", "slave", "listening", "on", "the", "given", "serial", "port" ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/slave/ModbusSlaveFactory.java#L200-L202
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/slave/ModbusSlaveFactory.java
ModbusSlaveFactory.getSlave
public static synchronized ModbusSlave getSlave(AbstractModbusListener listener) { for (ModbusSlave slave : slaves.values()) { if (slave.getListener().equals(listener)) { return slave; } } return null; }
java
public static synchronized ModbusSlave getSlave(AbstractModbusListener listener) { for (ModbusSlave slave : slaves.values()) { if (slave.getListener().equals(listener)) { return slave; } } return null; }
[ "public", "static", "synchronized", "ModbusSlave", "getSlave", "(", "AbstractModbusListener", "listener", ")", "{", "for", "(", "ModbusSlave", "slave", ":", "slaves", ".", "values", "(", ")", ")", "{", "if", "(", "slave", ".", "getListener", "(", ")", ".", ...
Returns the running slave that utilises the give listener @param listener Listener used for this slave @return Null or ModbusSlave
[ "Returns", "the", "running", "slave", "that", "utilises", "the", "give", "listener" ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/slave/ModbusSlaveFactory.java#L210-L217
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/io/BytesOutputStream.java
BytesOutputStream.getBuffer
public synchronized byte[] getBuffer() { byte[] dest = new byte[buf.length]; System.arraycopy(buf, 0, dest, 0, dest.length); return dest; }
java
public synchronized byte[] getBuffer() { byte[] dest = new byte[buf.length]; System.arraycopy(buf, 0, dest, 0, dest.length); return dest; }
[ "public", "synchronized", "byte", "[", "]", "getBuffer", "(", ")", "{", "byte", "[", "]", "dest", "=", "new", "byte", "[", "buf", ".", "length", "]", ";", "System", ".", "arraycopy", "(", "buf", ",", "0", ",", "dest", ",", "0", ",", "dest", ".", ...
Returns the reference to the output buffer. @return the reference to the <tt>byte[]</tt> output buffer.
[ "Returns", "the", "reference", "to", "the", "output", "buffer", "." ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/io/BytesOutputStream.java#L62-L66
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/msg/ReadInputDiscretesResponse.java
ReadInputDiscretesResponse.setBitCount
public void setBitCount(int count) { bitCount = count; discretes = new BitVector(count); //set correct length, without counting unitid and fc setDataLength(discretes.byteSize() + 1); }
java
public void setBitCount(int count) { bitCount = count; discretes = new BitVector(count); //set correct length, without counting unitid and fc setDataLength(discretes.byteSize() + 1); }
[ "public", "void", "setBitCount", "(", "int", "count", ")", "{", "bitCount", "=", "count", ";", "discretes", "=", "new", "BitVector", "(", "count", ")", ";", "//set correct length, without counting unitid and fc", "setDataLength", "(", "discretes", ".", "byteSize", ...
Sets the number of bits in this response. @param count the number of response bits as int.
[ "Sets", "the", "number", "of", "bits", "in", "this", "response", "." ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/msg/ReadInputDiscretesResponse.java#L81-L86
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/msg/ReadMEIResponse.java
ReadMEIResponse.getFields
public synchronized String[] getFields() { String[] dest = new String[fields.length]; System.arraycopy(fields, 0, dest, 0, dest.length); return dest; }
java
public synchronized String[] getFields() { String[] dest = new String[fields.length]; System.arraycopy(fields, 0, dest, 0, dest.length); return dest; }
[ "public", "synchronized", "String", "[", "]", "getFields", "(", ")", "{", "String", "[", "]", "dest", "=", "new", "String", "[", "fields", ".", "length", "]", ";", "System", ".", "arraycopy", "(", "fields", ",", "0", ",", "dest", ",", "0", ",", "de...
Returns the array of strings that were read @return Array of the fields read
[ "Returns", "the", "array", "of", "strings", "that", "were", "read" ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/msg/ReadMEIResponse.java#L77-L81
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/msg/ReadInputRegistersResponse.java
ReadInputRegistersResponse.getRegisters
public synchronized InputRegister[] getRegisters() { InputRegister[] dest = new InputRegister[registers.length]; System.arraycopy(registers, 0, dest, 0, dest.length); return dest; }
java
public synchronized InputRegister[] getRegisters() { InputRegister[] dest = new InputRegister[registers.length]; System.arraycopy(registers, 0, dest, 0, dest.length); return dest; }
[ "public", "synchronized", "InputRegister", "[", "]", "getRegisters", "(", ")", "{", "InputRegister", "[", "]", "dest", "=", "new", "InputRegister", "[", "registers", ".", "length", "]", ";", "System", ".", "arraycopy", "(", "registers", ",", "0", ",", "des...
Returns a reference to the array of input registers read. @return a <tt>InputRegister[]</tt> instance.
[ "Returns", "a", "reference", "to", "the", "array", "of", "input", "registers", "read", "." ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/msg/ReadInputRegistersResponse.java#L135-L139
train
steveohara/j2mod
src/main/java/com/ghgande/j2mod/modbus/msg/ReadWriteMultipleResponse.java
ReadWriteMultipleResponse.setRegisters
public void setRegisters(InputRegister[] registers) { byteCount = registers.length * 2; setDataLength(byteCount + 1); this.registers = Arrays.copyOf(registers, registers.length); }
java
public void setRegisters(InputRegister[] registers) { byteCount = registers.length * 2; setDataLength(byteCount + 1); this.registers = Arrays.copyOf(registers, registers.length); }
[ "public", "void", "setRegisters", "(", "InputRegister", "[", "]", "registers", ")", "{", "byteCount", "=", "registers", ".", "length", "*", "2", ";", "setDataLength", "(", "byteCount", "+", "1", ")", ";", "this", ".", "registers", "=", "Arrays", ".", "co...
Sets the entire block of registers for this response @param registers Array of registers
[ "Sets", "the", "entire", "block", "of", "registers", "for", "this", "response" ]
67162c55d7c02564e50211a9df06b8314953b5f2
https://github.com/steveohara/j2mod/blob/67162c55d7c02564e50211a9df06b8314953b5f2/src/main/java/com/ghgande/j2mod/modbus/msg/ReadWriteMultipleResponse.java#L155-L160
train