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
otto-de/edison-microservice
edison-jobs/src/main/java/de/otto/edison/jobs/service/JobService.java
JobService.clearRunLocks
private void clearRunLocks() { jobMetaService.runningJobs().forEach((RunningJob runningJob) -> { final Optional<JobInfo> jobInfoOptional = jobRepository.findOne(runningJob.jobId); if (jobInfoOptional.isPresent() && jobInfoOptional.get().isStopped()) { jobMetaService.relea...
java
private void clearRunLocks() { jobMetaService.runningJobs().forEach((RunningJob runningJob) -> { final Optional<JobInfo> jobInfoOptional = jobRepository.findOne(runningJob.jobId); if (jobInfoOptional.isPresent() && jobInfoOptional.get().isStopped()) { jobMetaService.relea...
[ "private", "void", "clearRunLocks", "(", ")", "{", "jobMetaService", ".", "runningJobs", "(", ")", ".", "forEach", "(", "(", "RunningJob", "runningJob", ")", "->", "{", "final", "Optional", "<", "JobInfo", ">", "jobInfoOptional", "=", "jobRepository", ".", "...
Checks all run locks and releases the lock, if the job is stopped. TODO: This method should never do something, otherwise the is a bug in the lock handling. TODO: Check Log files + Remove
[ "Checks", "all", "run", "locks", "and", "releases", "the", "lock", "if", "the", "job", "is", "stopped", "." ]
89ecf0a0dee40977f004370b0b474a36c699e8a2
https://github.com/otto-de/edison-microservice/blob/89ecf0a0dee40977f004370b0b474a36c699e8a2/edison-jobs/src/main/java/de/otto/edison/jobs/service/JobService.java#L162-L173
train
otto-de/edison-microservice
edison-core/src/main/java/de/otto/edison/status/configuration/VersionInfoProperties.java
VersionInfoProperties.versionInfoProperties
public static VersionInfoProperties versionInfoProperties(final String version, final String commit, final String urlTemplate) { final VersionInfoProperties p = new VersionInfoProperties(); p.version = version; p.commit = commit; p.urlTemplate = urlTemplate; return p; }
java
public static VersionInfoProperties versionInfoProperties(final String version, final String commit, final String urlTemplate) { final VersionInfoProperties p = new VersionInfoProperties(); p.version = version; p.commit = commit; p.urlTemplate = urlTemplate; return p; }
[ "public", "static", "VersionInfoProperties", "versionInfoProperties", "(", "final", "String", "version", ",", "final", "String", "commit", ",", "final", "String", "urlTemplate", ")", "{", "final", "VersionInfoProperties", "p", "=", "new", "VersionInfoProperties", "(",...
Used for testing purposes. @param version vcs version @param commit vcs commit number @param urlTemplate template used to generate links to the vcs server @return VersionInfoProperties
[ "Used", "for", "testing", "purposes", "." ]
89ecf0a0dee40977f004370b0b474a36c699e8a2
https://github.com/otto-de/edison-microservice/blob/89ecf0a0dee40977f004370b0b474a36c699e8a2/edison-core/src/main/java/de/otto/edison/status/configuration/VersionInfoProperties.java#L42-L48
train
otto-de/edison-microservice
edison-core/src/main/java/de/otto/edison/status/domain/StatusDetail.java
StatusDetail.withDetail
public StatusDetail withDetail(final String key, final String value) { final LinkedHashMap<String, String> newDetails = new LinkedHashMap<>(details); newDetails.put(key, value); return statusDetail(name,status,message, newDetails); }
java
public StatusDetail withDetail(final String key, final String value) { final LinkedHashMap<String, String> newDetails = new LinkedHashMap<>(details); newDetails.put(key, value); return statusDetail(name,status,message, newDetails); }
[ "public", "StatusDetail", "withDetail", "(", "final", "String", "key", ",", "final", "String", "value", ")", "{", "final", "LinkedHashMap", "<", "String", ",", "String", ">", "newDetails", "=", "new", "LinkedHashMap", "<>", "(", "details", ")", ";", "newDeta...
Create a copy of this StatusDetail, add a detail and return the new StatusDetail. @param key the key of the additional detail @param value the value of the additional detail @return StatusDetail
[ "Create", "a", "copy", "of", "this", "StatusDetail", "add", "a", "detail", "and", "return", "the", "new", "StatusDetail", "." ]
89ecf0a0dee40977f004370b0b474a36c699e8a2
https://github.com/otto-de/edison-microservice/blob/89ecf0a0dee40977f004370b0b474a36c699e8a2/edison-core/src/main/java/de/otto/edison/status/domain/StatusDetail.java#L132-L136
train
otto-de/edison-microservice
edison-core/src/main/java/de/otto/edison/status/domain/StatusDetail.java
StatusDetail.withoutDetail
public StatusDetail withoutDetail(final String key) { final LinkedHashMap<String, String> newDetails = new LinkedHashMap<>(details); newDetails.remove(key); return statusDetail(name,status,message, newDetails); }
java
public StatusDetail withoutDetail(final String key) { final LinkedHashMap<String, String> newDetails = new LinkedHashMap<>(details); newDetails.remove(key); return statusDetail(name,status,message, newDetails); }
[ "public", "StatusDetail", "withoutDetail", "(", "final", "String", "key", ")", "{", "final", "LinkedHashMap", "<", "String", ",", "String", ">", "newDetails", "=", "new", "LinkedHashMap", "<>", "(", "details", ")", ";", "newDetails", ".", "remove", "(", "key...
Create a copy of this StatusDetail, remove a detail and return the new StatusDetail. @param key the key of the additional detail @return StatusDetail
[ "Create", "a", "copy", "of", "this", "StatusDetail", "remove", "a", "detail", "and", "return", "the", "new", "StatusDetail", "." ]
89ecf0a0dee40977f004370b0b474a36c699e8a2
https://github.com/otto-de/edison-microservice/blob/89ecf0a0dee40977f004370b0b474a36c699e8a2/edison-core/src/main/java/de/otto/edison/status/domain/StatusDetail.java#L144-L148
train
otto-de/edison-microservice
edison-core/src/main/java/de/otto/edison/status/domain/DatasourceDependencyBuilder.java
DatasourceDependencyBuilder.mongoDependency
public static DatasourceDependencyBuilder mongoDependency(final List<Datasource> datasources) { return new DatasourceDependencyBuilder() .withDatasources(datasources) .withType(DatasourceDependency.TYPE_DB) .withSubtype(DatasourceDependency.SUBTYPE_MONGODB); }
java
public static DatasourceDependencyBuilder mongoDependency(final List<Datasource> datasources) { return new DatasourceDependencyBuilder() .withDatasources(datasources) .withType(DatasourceDependency.TYPE_DB) .withSubtype(DatasourceDependency.SUBTYPE_MONGODB); }
[ "public", "static", "DatasourceDependencyBuilder", "mongoDependency", "(", "final", "List", "<", "Datasource", ">", "datasources", ")", "{", "return", "new", "DatasourceDependencyBuilder", "(", ")", ".", "withDatasources", "(", "datasources", ")", ".", "withType", "...
Creates a ServiceDependencyBuilder with type="db" and subtype="MongoDB". @param datasources the datasources of the accessed database. @return builder used to configure MongoDB datasource dependencies
[ "Creates", "a", "ServiceDependencyBuilder", "with", "type", "=", "db", "and", "subtype", "=", "MongoDB", "." ]
89ecf0a0dee40977f004370b0b474a36c699e8a2
https://github.com/otto-de/edison-microservice/blob/89ecf0a0dee40977f004370b0b474a36c699e8a2/edison-core/src/main/java/de/otto/edison/status/domain/DatasourceDependencyBuilder.java#L49-L54
train
otto-de/edison-microservice
edison-core/src/main/java/de/otto/edison/status/domain/DatasourceDependencyBuilder.java
DatasourceDependencyBuilder.redisDependency
public static DatasourceDependencyBuilder redisDependency(final List<Datasource> datasources) { return new DatasourceDependencyBuilder() .withDatasources(datasources) .withType(DatasourceDependency.TYPE_DB) .withSubtype(DatasourceDependency.SUBTYPE_REDIS); }
java
public static DatasourceDependencyBuilder redisDependency(final List<Datasource> datasources) { return new DatasourceDependencyBuilder() .withDatasources(datasources) .withType(DatasourceDependency.TYPE_DB) .withSubtype(DatasourceDependency.SUBTYPE_REDIS); }
[ "public", "static", "DatasourceDependencyBuilder", "redisDependency", "(", "final", "List", "<", "Datasource", ">", "datasources", ")", "{", "return", "new", "DatasourceDependencyBuilder", "(", ")", ".", "withDatasources", "(", "datasources", ")", ".", "withType", "...
Creates a ServiceDependencyBuilder with type="db" and subtype="Redis". @param datasources the datasources of the accessed database. @return builder used to configure Redis datasource dependencies
[ "Creates", "a", "ServiceDependencyBuilder", "with", "type", "=", "db", "and", "subtype", "=", "Redis", "." ]
89ecf0a0dee40977f004370b0b474a36c699e8a2
https://github.com/otto-de/edison-microservice/blob/89ecf0a0dee40977f004370b0b474a36c699e8a2/edison-core/src/main/java/de/otto/edison/status/domain/DatasourceDependencyBuilder.java#L72-L77
train
otto-de/edison-microservice
edison-core/src/main/java/de/otto/edison/status/domain/DatasourceDependencyBuilder.java
DatasourceDependencyBuilder.cassandraDependency
public static DatasourceDependencyBuilder cassandraDependency(final List<Datasource> datasources) { return new DatasourceDependencyBuilder() .withDatasources(datasources) .withType(DatasourceDependency.TYPE_DB) .withSubtype(DatasourceDependency.SUBTYPE_CASSANDRA);...
java
public static DatasourceDependencyBuilder cassandraDependency(final List<Datasource> datasources) { return new DatasourceDependencyBuilder() .withDatasources(datasources) .withType(DatasourceDependency.TYPE_DB) .withSubtype(DatasourceDependency.SUBTYPE_CASSANDRA);...
[ "public", "static", "DatasourceDependencyBuilder", "cassandraDependency", "(", "final", "List", "<", "Datasource", ">", "datasources", ")", "{", "return", "new", "DatasourceDependencyBuilder", "(", ")", ".", "withDatasources", "(", "datasources", ")", ".", "withType",...
Creates a ServiceDependencyBuilder with type="db" and subtype="Cassandra". @param datasources the datasources of the accessed database. @return builder used to configure Cassandra datasource dependencies
[ "Creates", "a", "ServiceDependencyBuilder", "with", "type", "=", "db", "and", "subtype", "=", "Cassandra", "." ]
89ecf0a0dee40977f004370b0b474a36c699e8a2
https://github.com/otto-de/edison-microservice/blob/89ecf0a0dee40977f004370b0b474a36c699e8a2/edison-core/src/main/java/de/otto/edison/status/domain/DatasourceDependencyBuilder.java#L95-L100
train
otto-de/edison-microservice
edison-core/src/main/java/de/otto/edison/status/domain/DatasourceDependencyBuilder.java
DatasourceDependencyBuilder.elasticSearchDependency
public static DatasourceDependencyBuilder elasticSearchDependency(final List<Datasource> datasources) { return new DatasourceDependencyBuilder() .withDatasources(datasources) .withType(DatasourceDependency.TYPE_DB) .withSubtype(DatasourceDependency.SUBTYPE_ELASTIC...
java
public static DatasourceDependencyBuilder elasticSearchDependency(final List<Datasource> datasources) { return new DatasourceDependencyBuilder() .withDatasources(datasources) .withType(DatasourceDependency.TYPE_DB) .withSubtype(DatasourceDependency.SUBTYPE_ELASTIC...
[ "public", "static", "DatasourceDependencyBuilder", "elasticSearchDependency", "(", "final", "List", "<", "Datasource", ">", "datasources", ")", "{", "return", "new", "DatasourceDependencyBuilder", "(", ")", ".", "withDatasources", "(", "datasources", ")", ".", "withTy...
Creates a ServiceDependencyBuilder with type="db" and subtype="ElasticSearch". @param datasources the datasources of the accessed ES services. @return builder used to configure ES datasource dependencies
[ "Creates", "a", "ServiceDependencyBuilder", "with", "type", "=", "db", "and", "subtype", "=", "ElasticSearch", "." ]
89ecf0a0dee40977f004370b0b474a36c699e8a2
https://github.com/otto-de/edison-microservice/blob/89ecf0a0dee40977f004370b0b474a36c699e8a2/edison-core/src/main/java/de/otto/edison/status/domain/DatasourceDependencyBuilder.java#L118-L123
train
otto-de/edison-microservice
edison-core/src/main/java/de/otto/edison/status/domain/DatasourceDependencyBuilder.java
DatasourceDependencyBuilder.kafkaDependency
public static DatasourceDependencyBuilder kafkaDependency(final List<Datasource> datasources) { return new DatasourceDependencyBuilder() .withDatasources(datasources) .withType(DatasourceDependency.TYPE_QUEUE) .withSubtype(DatasourceDependency.SUBTYPE_KAFKA); ...
java
public static DatasourceDependencyBuilder kafkaDependency(final List<Datasource> datasources) { return new DatasourceDependencyBuilder() .withDatasources(datasources) .withType(DatasourceDependency.TYPE_QUEUE) .withSubtype(DatasourceDependency.SUBTYPE_KAFKA); ...
[ "public", "static", "DatasourceDependencyBuilder", "kafkaDependency", "(", "final", "List", "<", "Datasource", ">", "datasources", ")", "{", "return", "new", "DatasourceDependencyBuilder", "(", ")", ".", "withDatasources", "(", "datasources", ")", ".", "withType", "...
Creates a ServiceDependencyBuilder with type="queue" and subtype="Kafka". @param datasources the datasources of the accessed queue. @return builder used to configure Kafka datasource dependencies
[ "Creates", "a", "ServiceDependencyBuilder", "with", "type", "=", "queue", "and", "subtype", "=", "Kafka", "." ]
89ecf0a0dee40977f004370b0b474a36c699e8a2
https://github.com/otto-de/edison-microservice/blob/89ecf0a0dee40977f004370b0b474a36c699e8a2/edison-core/src/main/java/de/otto/edison/status/domain/DatasourceDependencyBuilder.java#L141-L146
train
otto-de/edison-microservice
edison-core/src/main/java/de/otto/edison/authentication/configuration/LdapProperties.java
LdapProperties.ldapProperties
public static LdapProperties ldapProperties(final String host, final int port, final List<String> baseDn, final String roleBaseDn, ...
java
public static LdapProperties ldapProperties(final String host, final int port, final List<String> baseDn, final String roleBaseDn, ...
[ "public", "static", "LdapProperties", "ldapProperties", "(", "final", "String", "host", ",", "final", "int", "port", ",", "final", "List", "<", "String", ">", "baseDn", ",", "final", "String", "roleBaseDn", ",", "final", "String", "rdnIdentifier", ",", "final"...
Creates Ldap properties. Primarily used in tests. @param host LDAP server @param port LDAP port @param baseDn Base distinguished name @param roleBaseDn Base distinguished name used to select user roles @param rdnIdentifier Relative distinguished name @param prefix Prefixes of paths that should require LDAP authenticat...
[ "Creates", "Ldap", "properties", ".", "Primarily", "used", "in", "tests", "." ]
89ecf0a0dee40977f004370b0b474a36c699e8a2
https://github.com/otto-de/edison-microservice/blob/89ecf0a0dee40977f004370b0b474a36c699e8a2/edison-core/src/main/java/de/otto/edison/authentication/configuration/LdapProperties.java#L114-L133
train
otto-de/edison-microservice
edison-core/src/main/java/de/otto/edison/status/domain/ServiceDependencyBuilder.java
ServiceDependencyBuilder.restServiceDependency
public static ServiceDependencyBuilder restServiceDependency(final String url) { return new ServiceDependencyBuilder() .withUrl(url) .withType(ServiceDependency.TYPE_SERVICE) .withSubtype(ServiceDependency.SUBTYPE_REST) .withMethods(singletonList("...
java
public static ServiceDependencyBuilder restServiceDependency(final String url) { return new ServiceDependencyBuilder() .withUrl(url) .withType(ServiceDependency.TYPE_SERVICE) .withSubtype(ServiceDependency.SUBTYPE_REST) .withMethods(singletonList("...
[ "public", "static", "ServiceDependencyBuilder", "restServiceDependency", "(", "final", "String", "url", ")", "{", "return", "new", "ServiceDependencyBuilder", "(", ")", ".", "withUrl", "(", "url", ")", ".", "withType", "(", "ServiceDependency", ".", "TYPE_SERVICE", ...
Creates a ServiceDependencyBuilder with type="service" and subtype="REST". @param url the url or uri-template of the accessed REST service. @return ServiceDependencyBuilder
[ "Creates", "a", "ServiceDependencyBuilder", "with", "type", "=", "service", "and", "subtype", "=", "REST", "." ]
89ecf0a0dee40977f004370b0b474a36c699e8a2
https://github.com/otto-de/edison-microservice/blob/89ecf0a0dee40977f004370b0b474a36c699e8a2/edison-core/src/main/java/de/otto/edison/status/domain/ServiceDependencyBuilder.java#L56-L63
train
otto-de/edison-microservice
edison-core/src/main/java/de/otto/edison/status/domain/ServiceDependencyBuilder.java
ServiceDependencyBuilder.serviceDependency
public static ServiceDependencyBuilder serviceDependency(final String url) { return new ServiceDependencyBuilder() .withUrl(url) .withType(ServiceDependency.TYPE_SERVICE) .withSubtype(ServiceDependency.SUBTYPE_OTHER); }
java
public static ServiceDependencyBuilder serviceDependency(final String url) { return new ServiceDependencyBuilder() .withUrl(url) .withType(ServiceDependency.TYPE_SERVICE) .withSubtype(ServiceDependency.SUBTYPE_OTHER); }
[ "public", "static", "ServiceDependencyBuilder", "serviceDependency", "(", "final", "String", "url", ")", "{", "return", "new", "ServiceDependencyBuilder", "(", ")", ".", "withUrl", "(", "url", ")", ".", "withType", "(", "ServiceDependency", ".", "TYPE_SERVICE", ")...
Creates a generic ServiceDependencyBuilder with type="service" and subtype="OTHER". @param url the url or uri-template of the accessed service. @return ServiceDependencyBuilder
[ "Creates", "a", "generic", "ServiceDependencyBuilder", "with", "type", "=", "service", "and", "subtype", "=", "OTHER", "." ]
89ecf0a0dee40977f004370b0b474a36c699e8a2
https://github.com/otto-de/edison-microservice/blob/89ecf0a0dee40977f004370b0b474a36c699e8a2/edison-core/src/main/java/de/otto/edison/status/domain/ServiceDependencyBuilder.java#L71-L76
train
otto-de/edison-microservice
edison-core/src/main/java/de/otto/edison/status/domain/Datasource.java
Datasource.datasource
public static Datasource datasource(final String node, final int port, final String resource) { return new Datasource(node, port, resource); }
java
public static Datasource datasource(final String node, final int port, final String resource) { return new Datasource(node, port, resource); }
[ "public", "static", "Datasource", "datasource", "(", "final", "String", "node", ",", "final", "int", "port", ",", "final", "String", "resource", ")", "{", "return", "new", "Datasource", "(", "node", ",", "port", ",", "resource", ")", ";", "}" ]
Creates a Datasource from node, port and resource descriptors. @param node the node of the datasource @param port the port used to access the datasource @param resource the resource accessed at the datasource @return Datasource
[ "Creates", "a", "Datasource", "from", "node", "port", "and", "resource", "descriptors", "." ]
89ecf0a0dee40977f004370b0b474a36c699e8a2
https://github.com/otto-de/edison-microservice/blob/89ecf0a0dee40977f004370b0b474a36c699e8a2/edison-core/src/main/java/de/otto/edison/status/domain/Datasource.java#L108-L112
train
otto-de/edison-microservice
edison-jobs/src/main/java/de/otto/edison/jobs/definition/DefaultJobDefinition.java
DefaultJobDefinition.manuallyTriggerableJobDefinition
public static JobDefinition manuallyTriggerableJobDefinition(final String jobType, final String jobName, final String description, ...
java
public static JobDefinition manuallyTriggerableJobDefinition(final String jobType, final String jobName, final String description, ...
[ "public", "static", "JobDefinition", "manuallyTriggerableJobDefinition", "(", "final", "String", "jobType", ",", "final", "String", "jobName", ",", "final", "String", "description", ",", "final", "int", "restarts", ",", "final", "Optional", "<", "Duration", ">", "...
Create a JobDefinition for a job that will not be triggered automatically by a job trigger. @param jobType The type of the Job @param jobName A human readable name of the Job @param description A short description of the job's purpose @param restarts The number of restarts if the job failed because of error...
[ "Create", "a", "JobDefinition", "for", "a", "job", "that", "will", "not", "be", "triggered", "automatically", "by", "a", "job", "trigger", "." ]
89ecf0a0dee40977f004370b0b474a36c699e8a2
https://github.com/otto-de/edison-microservice/blob/89ecf0a0dee40977f004370b0b474a36c699e8a2/edison-jobs/src/main/java/de/otto/edison/jobs/definition/DefaultJobDefinition.java#L38-L44
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/flac/FlacAudioFrame.java
FlacAudioFrame.getData
@Override public byte[] getData() { byte[] data = new byte[frameData.length+2]; int first2 = (FRAME_SYNC<<2); if (blockSizeVariable) first2++; IOUtils.putInt2BE(data, 0, first2); System.arraycopy(frameData, 0, data, 2, frameData.length); return data; }
java
@Override public byte[] getData() { byte[] data = new byte[frameData.length+2]; int first2 = (FRAME_SYNC<<2); if (blockSizeVariable) first2++; IOUtils.putInt2BE(data, 0, first2); System.arraycopy(frameData, 0, data, 2, frameData.length); return data; }
[ "@", "Override", "public", "byte", "[", "]", "getData", "(", ")", "{", "byte", "[", "]", "data", "=", "new", "byte", "[", "frameData", ".", "length", "+", "2", "]", ";", "int", "first2", "=", "(", "FRAME_SYNC", "<<", "2", ")", ";", "if", "(", "...
Returns the contents, including the sync header
[ "Returns", "the", "contents", "including", "the", "sync", "header" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/flac/FlacAudioFrame.java#L222-L233
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/skeleton/SkeletonFishead.java
SkeletonFishead.setUtc
public void setUtc(String utc) { if (utc == null) { this.utc = null; } else { if (utc.length() != 20) { throw new IllegalArgumentException("Must be of the form YYYYMMDDTHHMMSS.sssZ"); } } }
java
public void setUtc(String utc) { if (utc == null) { this.utc = null; } else { if (utc.length() != 20) { throw new IllegalArgumentException("Must be of the form YYYYMMDDTHHMMSS.sssZ"); } } }
[ "public", "void", "setUtc", "(", "String", "utc", ")", "{", "if", "(", "utc", "==", "null", ")", "{", "this", ".", "utc", "=", "null", ";", "}", "else", "{", "if", "(", "utc", ".", "length", "(", ")", "!=", "20", ")", "{", "throw", "new", "Il...
Sets the ISO-8601 UTC time of the file, which must be YYYYMMDDTHHMMSS.sssZ or null
[ "Sets", "the", "ISO", "-", "8601", "UTC", "time", "of", "the", "file", "which", "must", "be", "YYYYMMDDTHHMMSS", ".", "sssZ", "or", "null" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/skeleton/SkeletonFishead.java#L169-L177
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/skeleton/SkeletonStream.java
SkeletonStream.processPacket
public void processPacket(OggPacket packet) { SkeletonPacket skel = SkeletonPacketFactory.create(packet); // First packet must be the head if (packet.isBeginningOfStream()) { fishead = (SkeletonFishead)skel; } else if (skel instanceof SkeletonFisbone) { SkeletonF...
java
public void processPacket(OggPacket packet) { SkeletonPacket skel = SkeletonPacketFactory.create(packet); // First packet must be the head if (packet.isBeginningOfStream()) { fishead = (SkeletonFishead)skel; } else if (skel instanceof SkeletonFisbone) { SkeletonF...
[ "public", "void", "processPacket", "(", "OggPacket", "packet", ")", "{", "SkeletonPacket", "skel", "=", "SkeletonPacketFactory", ".", "create", "(", "packet", ")", ";", "// First packet must be the head", "if", "(", "packet", ".", "isBeginningOfStream", "(", ")", ...
Processes and tracks the next packet for the stream
[ "Processes", "and", "tracks", "the", "next", "packet", "for", "the", "stream" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/skeleton/SkeletonStream.java#L66-L85
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/skeleton/SkeletonStream.java
SkeletonStream.addBoneForStream
public SkeletonFisbone addBoneForStream(int sid) { SkeletonFisbone bone = new SkeletonFisbone(); bone.setSerialNumber(sid); fisbones.add(bone); if (sid == -1 || bonesByStream.containsKey(sid)) { throw new IllegalArgumentException("Invalid / duplicate sid " + sid); } ...
java
public SkeletonFisbone addBoneForStream(int sid) { SkeletonFisbone bone = new SkeletonFisbone(); bone.setSerialNumber(sid); fisbones.add(bone); if (sid == -1 || bonesByStream.containsKey(sid)) { throw new IllegalArgumentException("Invalid / duplicate sid " + sid); } ...
[ "public", "SkeletonFisbone", "addBoneForStream", "(", "int", "sid", ")", "{", "SkeletonFisbone", "bone", "=", "new", "SkeletonFisbone", "(", ")", ";", "bone", ".", "setSerialNumber", "(", "sid", ")", ";", "fisbones", ".", "add", "(", "bone", ")", ";", "if"...
Adds a new fisbone for the given stream
[ "Adds", "a", "new", "fisbone", "for", "the", "given", "stream" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/skeleton/SkeletonStream.java#L124-L135
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/ogg/OggPage.java
OggPage.addPacket
protected int addPacket(OggPacket packet, int offset) { if(packet.isBeginningOfStream()) { isBOS = true; } if(packet.isEndOfStream()) { isEOS = true; } // Add on in 255 byte chunks int size = packet.getData().length; for(int i = numLVs; i<...
java
protected int addPacket(OggPacket packet, int offset) { if(packet.isBeginningOfStream()) { isBOS = true; } if(packet.isEndOfStream()) { isEOS = true; } // Add on in 255 byte chunks int size = packet.getData().length; for(int i = numLVs; i<...
[ "protected", "int", "addPacket", "(", "OggPacket", "packet", ",", "int", "offset", ")", "{", "if", "(", "packet", ".", "isBeginningOfStream", "(", ")", ")", "{", "isBOS", "=", "true", ";", "}", "if", "(", "packet", ".", "isEndOfStream", "(", ")", ")", ...
Adds as much of the packet's data as we can do.
[ "Adds", "as", "much", "of", "the", "packet", "s", "data", "as", "we", "can", "do", "." ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/OggPage.java#L91-L119
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/ogg/OggPage.java
OggPage.isChecksumValid
public boolean isChecksumValid() { if(checksum == 0) return true; int crc = CRCUtils.getCRC(getHeader()); if(data != null && data.length > 0) { crc = CRCUtils.getCRC(data, crc); } return (checksum == crc); }
java
public boolean isChecksumValid() { if(checksum == 0) return true; int crc = CRCUtils.getCRC(getHeader()); if(data != null && data.length > 0) { crc = CRCUtils.getCRC(data, crc); } return (checksum == crc); }
[ "public", "boolean", "isChecksumValid", "(", ")", "{", "if", "(", "checksum", "==", "0", ")", "return", "true", ";", "int", "crc", "=", "CRCUtils", ".", "getCRC", "(", "getHeader", "(", ")", ")", ";", "if", "(", "data", "!=", "null", "&&", "data", ...
Is the checksum for the page valid?
[ "Is", "the", "checksum", "for", "the", "page", "valid?" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/OggPage.java#L124-L134
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/ogg/OggPage.java
OggPage.hasSpaceFor
protected boolean hasSpaceFor(int bytes) { // Do we have enough lvs spare? // (Each LV holds up to 255 bytes, and we're // not allowed more than 255 of them) int reqLVs = (int)Math.ceil(bytes / 255.0); if(numLVs + reqLVs > 255) { return false; } retu...
java
protected boolean hasSpaceFor(int bytes) { // Do we have enough lvs spare? // (Each LV holds up to 255 bytes, and we're // not allowed more than 255 of them) int reqLVs = (int)Math.ceil(bytes / 255.0); if(numLVs + reqLVs > 255) { return false; } retu...
[ "protected", "boolean", "hasSpaceFor", "(", "int", "bytes", ")", "{", "// Do we have enough lvs spare?", "// (Each LV holds up to 255 bytes, and we're", "// not allowed more than 255 of them)", "int", "reqLVs", "=", "(", "int", ")", "Math", ".", "ceil", "(", "bytes", "/"...
Does this Page have space for the given number of bytes?
[ "Does", "this", "Page", "have", "space", "for", "the", "given", "number", "of", "bytes?" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/OggPage.java#L143-L153
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/ogg/OggPage.java
OggPage.getDataSize
public int getDataSize() { // Data size is given by lvs int size = 0; for(int i=0; i<numLVs; i++) { size += IOUtils.toInt(lvs[i]); } return size; }
java
public int getDataSize() { // Data size is given by lvs int size = 0; for(int i=0; i<numLVs; i++) { size += IOUtils.toInt(lvs[i]); } return size; }
[ "public", "int", "getDataSize", "(", ")", "{", "// Data size is given by lvs", "int", "size", "=", "0", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "numLVs", ";", "i", "++", ")", "{", "size", "+=", "IOUtils", ".", "toInt", "(", "lvs", "["...
How big is the page, excluding headers?
[ "How", "big", "is", "the", "page", "excluding", "headers?" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/OggPage.java#L177-L184
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/ogg/OggPage.java
OggPage.getHeader
protected byte[] getHeader() { byte[] header = new byte[MINIMUM_PAGE_SIZE + numLVs]; header[0] = (byte)'O'; header[1] = (byte)'g'; header[2] = (byte)'g'; header[3] = (byte)'S'; header[4] = 0; // Version byte flags = 0; if(isContinue) { flags ...
java
protected byte[] getHeader() { byte[] header = new byte[MINIMUM_PAGE_SIZE + numLVs]; header[0] = (byte)'O'; header[1] = (byte)'g'; header[2] = (byte)'g'; header[3] = (byte)'S'; header[4] = 0; // Version byte flags = 0; if(isContinue) { flags ...
[ "protected", "byte", "[", "]", "getHeader", "(", ")", "{", "byte", "[", "]", "header", "=", "new", "byte", "[", "MINIMUM_PAGE_SIZE", "+", "numLVs", "]", ";", "header", "[", "0", "]", "=", "(", "byte", ")", "'", "'", ";", "header", "[", "1", "]", ...
Gets the header, but with a blank CRC field
[ "Gets", "the", "header", "but", "with", "a", "blank", "CRC", "field" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/OggPage.java#L276-L307
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/ogg/audio/OggAudioStreamHeaders.java
OggAudioStreamHeaders.createNext
protected OggStreamPacket createNext(OggPacket packet) { if (type == OggStreamIdentifier.OGG_VORBIS) { return VorbisPacketFactory.create(packet); } else if (type == OggStreamIdentifier.SPEEX_AUDIO) { return SpeexPacketFactory.create(packet); } else if (type == OggStreamId...
java
protected OggStreamPacket createNext(OggPacket packet) { if (type == OggStreamIdentifier.OGG_VORBIS) { return VorbisPacketFactory.create(packet); } else if (type == OggStreamIdentifier.SPEEX_AUDIO) { return SpeexPacketFactory.create(packet); } else if (type == OggStreamId...
[ "protected", "OggStreamPacket", "createNext", "(", "OggPacket", "packet", ")", "{", "if", "(", "type", "==", "OggStreamIdentifier", ".", "OGG_VORBIS", ")", "{", "return", "VorbisPacketFactory", ".", "create", "(", "packet", ")", ";", "}", "else", "if", "(", ...
Creates an appropriate high level packet
[ "Creates", "an", "appropriate", "high", "level", "packet" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/audio/OggAudioStreamHeaders.java#L88-L101
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/ogg/audio/OggAudioStreamHeaders.java
OggAudioStreamHeaders.populate
public boolean populate(OggPacket packet) { // TODO Finish the flac support properly if (type == OggStreamIdentifier.OGG_FLAC) { if (tags == null) { tags = new FlacTags(packet); return true; } else { // TODO Finish FLAC support ...
java
public boolean populate(OggPacket packet) { // TODO Finish the flac support properly if (type == OggStreamIdentifier.OGG_FLAC) { if (tags == null) { tags = new FlacTags(packet); return true; } else { // TODO Finish FLAC support ...
[ "public", "boolean", "populate", "(", "OggPacket", "packet", ")", "{", "// TODO Finish the flac support properly", "if", "(", "type", "==", "OggStreamIdentifier", ".", "OGG_FLAC", ")", "{", "if", "(", "tags", "==", "null", ")", "{", "tags", "=", "new", "FlacTa...
Populates with the next header @return Do any more headers remain to be populated?
[ "Populates", "with", "the", "next", "header" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/audio/OggAudioStreamHeaders.java#L108-L139
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/ogg/IOUtils.java
IOUtils.readUE7
public static long readUE7(InputStream stream) throws IOException { int i; long v = 0; while ((i = stream.read()) >= 0) { v = v << 7; if ((i & 128) == 128) { // Continues v += (i&127); } else { // Last value ...
java
public static long readUE7(InputStream stream) throws IOException { int i; long v = 0; while ((i = stream.read()) >= 0) { v = v << 7; if ((i & 128) == 128) { // Continues v += (i&127); } else { // Last value ...
[ "public", "static", "long", "readUE7", "(", "InputStream", "stream", ")", "throws", "IOException", "{", "int", "i", ";", "long", "v", "=", "0", ";", "while", "(", "(", "i", "=", "stream", ".", "read", "(", ")", ")", ">=", "0", ")", "{", "v", "=",...
Gets the integer value that is stored in UTF-8 like fashion, in Big Endian but with the high bit on each number indicating if it continues or not
[ "Gets", "the", "integer", "value", "that", "is", "stored", "in", "UTF", "-", "8", "like", "fashion", "in", "Big", "Endian", "but", "with", "the", "high", "bit", "on", "each", "number", "indicating", "if", "it", "continues", "or", "not" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/IOUtils.java#L308-L323
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/ogg/IOUtils.java
IOUtils.removeNullPadding
public static String removeNullPadding(String str) { int idx = str.indexOf(0); if (idx == -1) { return str; } return str.substring(0, idx); }
java
public static String removeNullPadding(String str) { int idx = str.indexOf(0); if (idx == -1) { return str; } return str.substring(0, idx); }
[ "public", "static", "String", "removeNullPadding", "(", "String", "str", ")", "{", "int", "idx", "=", "str", ".", "indexOf", "(", "0", ")", ";", "if", "(", "idx", "==", "-", "1", ")", "{", "return", "str", ";", "}", "return", "str", ".", "substring...
Strips off any null padding, if any, from the string
[ "Strips", "off", "any", "null", "padding", "if", "any", "from", "the", "string" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/IOUtils.java#L337-L343
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/ogg/IOUtils.java
IOUtils.writeUTF8
public static void writeUTF8(OutputStream out, String str) throws IOException { byte[] s = str.getBytes(UTF8); out.write(s); }
java
public static void writeUTF8(OutputStream out, String str) throws IOException { byte[] s = str.getBytes(UTF8); out.write(s); }
[ "public", "static", "void", "writeUTF8", "(", "OutputStream", "out", ",", "String", "str", ")", "throws", "IOException", "{", "byte", "[", "]", "s", "=", "str", ".", "getBytes", "(", "UTF8", ")", ";", "out", ".", "write", "(", "s", ")", ";", "}" ]
Writes the string out as UTF-8
[ "Writes", "the", "string", "out", "as", "UTF", "-", "8" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/IOUtils.java#L362-L365
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/ogg/IOUtils.java
IOUtils.byteRangeMatches
public static boolean byteRangeMatches(byte[] wanted, byte[] within, int withinOffset) { for (int i=0; i<wanted.length; i++) { if (wanted[i] != within[i+withinOffset]) return false; } return true; }
java
public static boolean byteRangeMatches(byte[] wanted, byte[] within, int withinOffset) { for (int i=0; i<wanted.length; i++) { if (wanted[i] != within[i+withinOffset]) return false; } return true; }
[ "public", "static", "boolean", "byteRangeMatches", "(", "byte", "[", "]", "wanted", ",", "byte", "[", "]", "within", ",", "int", "withinOffset", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "wanted", ".", "length", ";", "i", "++", ")"...
Checks to see if the wanted byte pattern is found in the within bytes from the given offset @param wanted Byte sequence to look for @param within Bytes to find in @param withinOffset Offset to check from
[ "Checks", "to", "see", "if", "the", "wanted", "byte", "pattern", "is", "found", "in", "the", "within", "bytes", "from", "the", "given", "offset" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/IOUtils.java#L383-L388
train
Gagravarr/VorbisJava
tika/src/main/java/org/gagravarr/tika/OggDetector.java
OggDetector.toMediaType
protected static MediaType toMediaType(OggStreamType type) { if (type == OggStreamIdentifier.UNKNOWN) { // We don't have a specific type available to return return OGG_GENERAL; } else { // Say it's the specific type we found return MediaType.parse(type.mimetype)...
java
protected static MediaType toMediaType(OggStreamType type) { if (type == OggStreamIdentifier.UNKNOWN) { // We don't have a specific type available to return return OGG_GENERAL; } else { // Say it's the specific type we found return MediaType.parse(type.mimetype)...
[ "protected", "static", "MediaType", "toMediaType", "(", "OggStreamType", "type", ")", "{", "if", "(", "type", "==", "OggStreamIdentifier", ".", "UNKNOWN", ")", "{", "// We don't have a specific type available to return", "return", "OGG_GENERAL", ";", "}", "else", "{",...
Converts from our type to Tika's type
[ "Converts", "from", "our", "type", "to", "Tika", "s", "type" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/tika/src/main/java/org/gagravarr/tika/OggDetector.java#L244-L252
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/theora/TheoraFile.java
TheoraFile.addSoundtrack
public int addSoundtrack(OggAudioHeaders audio) { if (w == null) { throw new IllegalStateException("Not in write mode"); } // If it doesn't have a sid yet, get it one OggPacketWriter aw = null; if (audio.getSid() == -1) { aw = ogg.getPacketWriter(); ...
java
public int addSoundtrack(OggAudioHeaders audio) { if (w == null) { throw new IllegalStateException("Not in write mode"); } // If it doesn't have a sid yet, get it one OggPacketWriter aw = null; if (audio.getSid() == -1) { aw = ogg.getPacketWriter(); ...
[ "public", "int", "addSoundtrack", "(", "OggAudioHeaders", "audio", ")", "{", "if", "(", "w", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Not in write mode\"", ")", ";", "}", "// If it doesn't have a sid yet, get it one", "OggPacketWriter",...
Adds a new soundtrack to the video @return the serial id (sid) of the new soundtrack
[ "Adds", "a", "new", "soundtrack", "to", "the", "video" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/theora/TheoraFile.java#L256-L284
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/theora/TheoraFile.java
TheoraFile.getNextAudioVisualPacket
public OggStreamAudioVisualData getNextAudioVisualPacket(Set<Integer> sids) throws IOException { OggStreamAudioVisualData data = null; while (data == null && !pendingPackets.isEmpty()) { AudioVisualDataAndSid avd = pendingPackets.removeFirst(); if (sids == null || sids.contains(...
java
public OggStreamAudioVisualData getNextAudioVisualPacket(Set<Integer> sids) throws IOException { OggStreamAudioVisualData data = null; while (data == null && !pendingPackets.isEmpty()) { AudioVisualDataAndSid avd = pendingPackets.removeFirst(); if (sids == null || sids.contains(...
[ "public", "OggStreamAudioVisualData", "getNextAudioVisualPacket", "(", "Set", "<", "Integer", ">", "sids", ")", "throws", "IOException", "{", "OggStreamAudioVisualData", "data", "=", "null", ";", "while", "(", "data", "==", "null", "&&", "!", "pendingPackets", "."...
Returns the next audio or video packet from any of the specified streams, or null if no more remain
[ "Returns", "the", "next", "audio", "or", "video", "packet", "from", "any", "of", "the", "specified", "streams", "or", "null", "if", "no", "more", "remain" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/theora/TheoraFile.java#L297-L330
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/theora/TheoraFile.java
TheoraFile.close
public void close() throws IOException { if (r != null) { r = null; ogg.close(); ogg = null; } if (w != null) { // First, write the initial packet of each stream // Skeleton (if present) goes first, then video, then audio(s) ...
java
public void close() throws IOException { if (r != null) { r = null; ogg.close(); ogg = null; } if (w != null) { // First, write the initial packet of each stream // Skeleton (if present) goes first, then video, then audio(s) ...
[ "public", "void", "close", "(", ")", "throws", "IOException", "{", "if", "(", "r", "!=", "null", ")", "{", "r", "=", "null", ";", "ogg", ".", "close", "(", ")", ";", "ogg", "=", "null", ";", "}", "if", "(", "w", "!=", "null", ")", "{", "// Fi...
In Reading mode, will close the underlying ogg file and free its resources. In Writing mode, will write out the Info, Comment Tags objects, and then the video and audio data.
[ "In", "Reading", "mode", "will", "close", "the", "underlying", "ogg", "file", "and", "free", "its", "resources", ".", "In", "Writing", "mode", "will", "write", "out", "the", "Info", "Comment", "Tags", "objects", "and", "then", "the", "video", "and", "audio...
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/theora/TheoraFile.java#L365-L450
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/vorbis/VorbisSetup.java
VorbisSetup.getNumberOfCodebooks
public int getNumberOfCodebooks() { byte[] data = getData(); int number = -1; if(data != null && data.length >= 10) { number = IOUtils.toInt(data[8]); } return (number+1); }
java
public int getNumberOfCodebooks() { byte[] data = getData(); int number = -1; if(data != null && data.length >= 10) { number = IOUtils.toInt(data[8]); } return (number+1); }
[ "public", "int", "getNumberOfCodebooks", "(", ")", "{", "byte", "[", "]", "data", "=", "getData", "(", ")", ";", "int", "number", "=", "-", "1", ";", "if", "(", "data", "!=", "null", "&&", "data", ".", "length", ">=", "10", ")", "{", "number", "=...
Example first bit of decoding
[ "Example", "first", "bit", "of", "decoding" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/vorbis/VorbisSetup.java#L49-L56
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/flac/FlacTags.java
FlacTags.populateMetadataHeader
@Override public void populateMetadataHeader(byte[] b, int dataLength) { b[0] = FlacMetadataBlock.VORBIS_COMMENT; IOUtils.putInt3BE(b, 1, dataLength); }
java
@Override public void populateMetadataHeader(byte[] b, int dataLength) { b[0] = FlacMetadataBlock.VORBIS_COMMENT; IOUtils.putInt3BE(b, 1, dataLength); }
[ "@", "Override", "public", "void", "populateMetadataHeader", "(", "byte", "[", "]", "b", ",", "int", "dataLength", ")", "{", "b", "[", "0", "]", "=", "FlacMetadataBlock", ".", "VORBIS_COMMENT", ";", "IOUtils", ".", "putInt3BE", "(", "b", ",", "1", ",", ...
Type plus three byte length
[ "Type", "plus", "three", "byte", "length" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/flac/FlacTags.java#L61-L65
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/ogg/audio/OggAudioStatistics.java
OggAudioStatistics.calculate
public void calculate() throws IOException { OggStreamAudioData data; // Calculate the headers sizing OggAudioInfoHeader info = headers.getInfo(); handleHeader(info); handleHeader(headers.getTags()); handleHeader(headers.getSetup()); // Have each audio packet ha...
java
public void calculate() throws IOException { OggStreamAudioData data; // Calculate the headers sizing OggAudioInfoHeader info = headers.getInfo(); handleHeader(info); handleHeader(headers.getTags()); handleHeader(headers.getSetup()); // Have each audio packet ha...
[ "public", "void", "calculate", "(", ")", "throws", "IOException", "{", "OggStreamAudioData", "data", ";", "// Calculate the headers sizing", "OggAudioInfoHeader", "info", "=", "headers", ".", "getInfo", "(", ")", ";", "handleHeader", "(", "info", ")", ";", "handle...
Calculate the statistics
[ "Calculate", "the", "statistics" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/audio/OggAudioStatistics.java#L52-L76
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/ogg/OggPacketWriter.java
OggPacketWriter.setGranulePosition
public void setGranulePosition(long position) { currentGranulePosition = position; for(OggPage p : buffer) { p.setGranulePosition(position); } }
java
public void setGranulePosition(long position) { currentGranulePosition = position; for(OggPage p : buffer) { p.setGranulePosition(position); } }
[ "public", "void", "setGranulePosition", "(", "long", "position", ")", "{", "currentGranulePosition", "=", "position", ";", "for", "(", "OggPage", "p", ":", "buffer", ")", "{", "p", ".", "setGranulePosition", "(", "position", ")", ";", "}", "}" ]
Sets the current granule position. The granule position will be applied to all un-flushed packets, and all future packets. As such, you should normally either call a flush just before or just after this call.
[ "Sets", "the", "current", "granule", "position", ".", "The", "granule", "position", "will", "be", "applied", "to", "all", "un", "-", "flushed", "packets", "and", "all", "future", "packets", ".", "As", "such", "you", "should", "normally", "either", "call", ...
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/OggPacketWriter.java#L45-L50
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/ogg/OggPacketWriter.java
OggPacketWriter.bufferPacket
public void bufferPacket(OggPacket packet, long granulePosition) { if(closed) { throw new IllegalStateException("Can't buffer packets on a closed stream!"); } if(! doneFirstPacket) { packet.setIsBOS(); doneFirstPacket = true; } int size = pack...
java
public void bufferPacket(OggPacket packet, long granulePosition) { if(closed) { throw new IllegalStateException("Can't buffer packets on a closed stream!"); } if(! doneFirstPacket) { packet.setIsBOS(); doneFirstPacket = true; } int size = pack...
[ "public", "void", "bufferPacket", "(", "OggPacket", "packet", ",", "long", "granulePosition", ")", "{", "if", "(", "closed", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Can't buffer packets on a closed stream!\"", ")", ";", "}", "if", "(", "!", "d...
Buffers the given packet up ready for writing to the stream, but doesn't write it to disk yet. The granule position is updated on the page. If writing the packet requires a new page, then the updated granule position only applies to the new page
[ "Buffers", "the", "given", "packet", "up", "ready", "for", "writing", "to", "the", "stream", "but", "doesn", "t", "write", "it", "to", "disk", "yet", ".", "The", "granule", "position", "is", "updated", "on", "the", "page", ".", "If", "writing", "the", ...
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/OggPacketWriter.java#L89-L115
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/ogg/OggPacketWriter.java
OggPacketWriter.getCurrentPageSize
public int getCurrentPageSize() { if (buffer.isEmpty()) return OggPage.getMinimumPageSize(); OggPage p = buffer.get( buffer.size()-1 ); return p.getPageSize(); }
java
public int getCurrentPageSize() { if (buffer.isEmpty()) return OggPage.getMinimumPageSize(); OggPage p = buffer.get( buffer.size()-1 ); return p.getPageSize(); }
[ "public", "int", "getCurrentPageSize", "(", ")", "{", "if", "(", "buffer", ".", "isEmpty", "(", ")", ")", "return", "OggPage", ".", "getMinimumPageSize", "(", ")", ";", "OggPage", "p", "=", "buffer", ".", "get", "(", "buffer", ".", "size", "(", ")", ...
Returns the size of the page currently being written to, including its headers. For a new stream, or a stream that has just been flushed, will return zero. @return Current page size, or 27 (the minimum) if no current page
[ "Returns", "the", "size", "of", "the", "page", "currently", "being", "written", "to", "including", "its", "headers", ".", "For", "a", "new", "stream", "or", "a", "stream", "that", "has", "just", "been", "flushed", "will", "return", "zero", "." ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/OggPacketWriter.java#L153-L158
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/ogg/OggPacketWriter.java
OggPacketWriter.flush
public void flush() throws IOException { if(closed) { throw new IllegalStateException("Can't flush packets on a closed stream!"); } // Write in one go OggPage[] pages = buffer.toArray(new OggPage[buffer.size()]); file.writePages(pages); // Get ready for nex...
java
public void flush() throws IOException { if(closed) { throw new IllegalStateException("Can't flush packets on a closed stream!"); } // Write in one go OggPage[] pages = buffer.toArray(new OggPage[buffer.size()]); file.writePages(pages); // Get ready for nex...
[ "public", "void", "flush", "(", ")", "throws", "IOException", "{", "if", "(", "closed", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Can't flush packets on a closed stream!\"", ")", ";", "}", "// Write in one go", "OggPage", "[", "]", "pages", "=", ...
Writes all pending packets to the stream, splitting across pages as needed.
[ "Writes", "all", "pending", "packets", "to", "the", "stream", "splitting", "across", "pages", "as", "needed", "." ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/OggPacketWriter.java#L164-L175
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/ogg/OggPacketWriter.java
OggPacketWriter.close
public void close() throws IOException { if(buffer.size() > 0) { buffer.get( buffer.size()-1 ).setIsEOS(); } else { OggPacket p = new OggPacket(new byte[0]); p.setIsEOS(); bufferPacket(p); } flush(); closed = true; }
java
public void close() throws IOException { if(buffer.size() > 0) { buffer.get( buffer.size()-1 ).setIsEOS(); } else { OggPacket p = new OggPacket(new byte[0]); p.setIsEOS(); bufferPacket(p); } flush(); closed = true; }
[ "public", "void", "close", "(", ")", "throws", "IOException", "{", "if", "(", "buffer", ".", "size", "(", ")", ">", "0", ")", "{", "buffer", ".", "get", "(", "buffer", ".", "size", "(", ")", "-", "1", ")", ".", "setIsEOS", "(", ")", ";", "}", ...
Writes all pending packets to the stream, with the last one containing the End Of Stream Flag, and then closes down.
[ "Writes", "all", "pending", "packets", "to", "the", "stream", "with", "the", "last", "one", "containing", "the", "End", "Of", "Stream", "Flag", "and", "then", "closes", "down", "." ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/OggPacketWriter.java#L182-L193
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/ogg/OggFile.java
OggFile.getPacketWriter
public OggPacketWriter getPacketWriter(int sid) { if(!writing) { throw new IllegalStateException("Can only write to a file opened with an OutputStream"); } seenSIDs.add(sid); return new OggPacketWriter(this, sid); }
java
public OggPacketWriter getPacketWriter(int sid) { if(!writing) { throw new IllegalStateException("Can only write to a file opened with an OutputStream"); } seenSIDs.add(sid); return new OggPacketWriter(this, sid); }
[ "public", "OggPacketWriter", "getPacketWriter", "(", "int", "sid", ")", "{", "if", "(", "!", "writing", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Can only write to a file opened with an OutputStream\"", ")", ";", "}", "seenSIDs", ".", "add", "(", ...
Creates a new Logical Bit Stream in the file, and returns a Writer for putting data into it.
[ "Creates", "a", "new", "Logical", "Bit", "Stream", "in", "the", "file", "and", "returns", "a", "Writer", "for", "putting", "data", "into", "it", "." ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/OggFile.java#L128-L134
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/ogg/OggFile.java
OggFile.getUnusedSerialNumber
protected int getUnusedSerialNumber() { while(true) { int sid = (int)(Math.random() * Short.MAX_VALUE); if(! seenSIDs.contains(sid)) { return sid; } } }
java
protected int getUnusedSerialNumber() { while(true) { int sid = (int)(Math.random() * Short.MAX_VALUE); if(! seenSIDs.contains(sid)) { return sid; } } }
[ "protected", "int", "getUnusedSerialNumber", "(", ")", "{", "while", "(", "true", ")", "{", "int", "sid", "=", "(", "int", ")", "(", "Math", ".", "random", "(", ")", "*", "Short", ".", "MAX_VALUE", ")", ";", "if", "(", "!", "seenSIDs", ".", "contai...
Returns a random, but previously un-used serial number for use by a new stream
[ "Returns", "a", "random", "but", "previously", "un", "-", "used", "serial", "number", "for", "use", "by", "a", "new", "stream" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/ogg/OggFile.java#L153-L160
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/flac/FlacFile.java
FlacFile.open
public static FlacFile open(File f) throws IOException, FileNotFoundException { // Open, in a way that we can skip backwards a few bytes InputStream inp = new BufferedInputStream(new FileInputStream(f), 8); FlacFile file = open(inp); return file; }
java
public static FlacFile open(File f) throws IOException, FileNotFoundException { // Open, in a way that we can skip backwards a few bytes InputStream inp = new BufferedInputStream(new FileInputStream(f), 8); FlacFile file = open(inp); return file; }
[ "public", "static", "FlacFile", "open", "(", "File", "f", ")", "throws", "IOException", ",", "FileNotFoundException", "{", "// Open, in a way that we can skip backwards a few bytes", "InputStream", "inp", "=", "new", "BufferedInputStream", "(", "new", "FileInputStream", "...
Opens the given file for reading
[ "Opens", "the", "given", "file", "for", "reading" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/flac/FlacFile.java#L40-L45
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/vorbis/VorbisStyleComments.java
VorbisStyleComments.getComments
public List<String> getComments(String tag) { List<String> c = comments.get( normaliseTag(tag) ); if(c == null) { return new ArrayList<String>(); } else { return c; } }
java
public List<String> getComments(String tag) { List<String> c = comments.get( normaliseTag(tag) ); if(c == null) { return new ArrayList<String>(); } else { return c; } }
[ "public", "List", "<", "String", ">", "getComments", "(", "String", "tag", ")", "{", "List", "<", "String", ">", "c", "=", "comments", ".", "get", "(", "normaliseTag", "(", "tag", ")", ")", ";", "if", "(", "c", "==", "null", ")", "{", "return", "...
Returns all comments for a given tag, in file order. Will return an empty list for tags which aren't present.
[ "Returns", "all", "comments", "for", "a", "given", "tag", "in", "file", "order", ".", "Will", "return", "an", "empty", "list", "for", "tags", "which", "aren", "t", "present", "." ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/vorbis/VorbisStyleComments.java#L184-L191
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/vorbis/VorbisStyleComments.java
VorbisStyleComments.addComment
public void addComment(String tag, String comment) { String nt = normaliseTag(tag); if(! comments.containsKey(nt)) { comments.put(nt, new ArrayList<String>()); } comments.get(nt).add(comment); }
java
public void addComment(String tag, String comment) { String nt = normaliseTag(tag); if(! comments.containsKey(nt)) { comments.put(nt, new ArrayList<String>()); } comments.get(nt).add(comment); }
[ "public", "void", "addComment", "(", "String", "tag", ",", "String", "comment", ")", "{", "String", "nt", "=", "normaliseTag", "(", "tag", ")", ";", "if", "(", "!", "comments", ".", "containsKey", "(", "nt", ")", ")", "{", "comments", ".", "put", "("...
Adds a comment for a given tag
[ "Adds", "a", "comment", "for", "a", "given", "tag" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/vorbis/VorbisStyleComments.java#L209-L215
train
Gagravarr/VorbisJava
core/src/main/java/org/gagravarr/vorbis/VorbisStyleComments.java
VorbisStyleComments.setComments
public void setComments(String tag, List<String> comments) { String nt = normaliseTag(tag); if(this.comments.containsKey(nt)) { this.comments.remove(nt); } this.comments.put(nt, comments); }
java
public void setComments(String tag, List<String> comments) { String nt = normaliseTag(tag); if(this.comments.containsKey(nt)) { this.comments.remove(nt); } this.comments.put(nt, comments); }
[ "public", "void", "setComments", "(", "String", "tag", ",", "List", "<", "String", ">", "comments", ")", "{", "String", "nt", "=", "normaliseTag", "(", "tag", ")", ";", "if", "(", "this", ".", "comments", ".", "containsKey", "(", "nt", ")", ")", "{",...
Removes any existing comments for a given tag, and replaces them with the supplied list
[ "Removes", "any", "existing", "comments", "for", "a", "given", "tag", "and", "replaces", "them", "with", "the", "supplied", "list" ]
22b4d645b00386d59d17a336a2bc9d54db08df16
https://github.com/Gagravarr/VorbisJava/blob/22b4d645b00386d59d17a336a2bc9d54db08df16/core/src/main/java/org/gagravarr/vorbis/VorbisStyleComments.java#L220-L226
train
zandero/rest.vertx
src/main/java/com/zandero/rest/data/PathConverter.java
PathConverter.extract
static List<MethodParameter> extract(String path) { List<MethodParameter> output = new ArrayList<>(); List<String> items = split(path); if (items.size() > 0) { int pathIndex = 0; int index = 0; for (String item : items) { MethodParameter param = getParamFromPath(item, index, pathIndex); // set n...
java
static List<MethodParameter> extract(String path) { List<MethodParameter> output = new ArrayList<>(); List<String> items = split(path); if (items.size() > 0) { int pathIndex = 0; int index = 0; for (String item : items) { MethodParameter param = getParamFromPath(item, index, pathIndex); // set n...
[ "static", "List", "<", "MethodParameter", ">", "extract", "(", "String", "path", ")", "{", "List", "<", "MethodParameter", ">", "output", "=", "new", "ArrayList", "<>", "(", ")", ";", "List", "<", "String", ">", "items", "=", "split", "(", "path", ")",...
Extract method argument parameters from path definition @param path to extract from @return list of method parameters or empty list if none found
[ "Extract", "method", "argument", "parameters", "from", "path", "definition" ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/data/PathConverter.java#L25-L49
train
zandero/rest.vertx
src/main/java/com/zandero/rest/data/PathConverter.java
PathConverter.convertSub
private static String convertSub(String path) { if (isRestEasyPath(path)) { // remove {} path = path.substring(1, path.length() - 1); int index = path.lastIndexOf(":"); // check for regular expression if (index > 0 && index + 1 < path.length()) { return path.substring(index + 1); // make regular ex...
java
private static String convertSub(String path) { if (isRestEasyPath(path)) { // remove {} path = path.substring(1, path.length() - 1); int index = path.lastIndexOf(":"); // check for regular expression if (index > 0 && index + 1 < path.length()) { return path.substring(index + 1); // make regular ex...
[ "private", "static", "String", "convertSub", "(", "String", "path", ")", "{", "if", "(", "isRestEasyPath", "(", "path", ")", ")", "{", "// remove {}", "path", "=", "path", ".", "substring", "(", "1", ",", "path", ".", "length", "(", ")", "-", "1", ")...
Converts from RestEasy to Vert.X format if necessary @param path to be converted @return vert.x path format
[ "Converts", "from", "RestEasy", "to", "Vert", ".", "X", "format", "if", "necessary" ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/data/PathConverter.java#L183-L204
train
zandero/rest.vertx
src/main/java/com/zandero/rest/data/ArgumentProvider.java
ArgumentProvider.removeMatrixFromPath
private static String removeMatrixFromPath(String path, RouteDefinition definition) { // simple removal ... we don't care what matrix attributes were given if (definition.hasMatrixParams()) { int index = path.indexOf(";"); if (index > 0) { return path.substring(0, index); } } return path; }
java
private static String removeMatrixFromPath(String path, RouteDefinition definition) { // simple removal ... we don't care what matrix attributes were given if (definition.hasMatrixParams()) { int index = path.indexOf(";"); if (index > 0) { return path.substring(0, index); } } return path; }
[ "private", "static", "String", "removeMatrixFromPath", "(", "String", "path", ",", "RouteDefinition", "definition", ")", "{", "// simple removal ... we don't care what matrix attributes were given", "if", "(", "definition", ".", "hasMatrixParams", "(", ")", ")", "{", "int...
Removes matrix params from path @param path to clean up @param definition to check if matrix params are present @return cleaned up path
[ "Removes", "matrix", "params", "from", "path" ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/data/ArgumentProvider.java#L268-L279
train
zandero/rest.vertx
src/main/java/com/zandero/rest/data/ClassFactory.java
ClassFactory.constructType
public static <T> Object constructType(Class<T> type, String fromValue) throws ClassFactoryException { Assert.notNull(type, "Missing type!"); // a primitive or "simple" type if (isSimpleType(type)) { return stringToPrimitiveType(fromValue, type); } // have a constructor that accepts a single argument (S...
java
public static <T> Object constructType(Class<T> type, String fromValue) throws ClassFactoryException { Assert.notNull(type, "Missing type!"); // a primitive or "simple" type if (isSimpleType(type)) { return stringToPrimitiveType(fromValue, type); } // have a constructor that accepts a single argument (S...
[ "public", "static", "<", "T", ">", "Object", "constructType", "(", "Class", "<", "T", ">", "type", ",", "String", "fromValue", ")", "throws", "ClassFactoryException", "{", "Assert", ".", "notNull", "(", "type", ",", "\"Missing type!\"", ")", ";", "// a primi...
Aims to construct given type utilizing a constructor that takes String or other primitive type values @param type to be constructed @param fromValue constructor param @param <T> type of value @return class object @throws ClassFactoryException in case type could not be constructed
[ "Aims", "to", "construct", "given", "type", "utilizing", "a", "constructor", "that", "takes", "String", "or", "other", "primitive", "type", "values" ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/data/ClassFactory.java#L455-L488
train
zandero/rest.vertx
src/main/java/com/zandero/rest/data/ClassFactory.java
ClassFactory.getMethods
private static <T> List<Method> getMethods(Class<T> type, String... names) { Assert.notNull(type, "Missing class to search for methods!"); Assert.notNullOrEmpty(names, "Missing method names to search for!"); Map<String, Method> candidates = new HashMap<>(); for (Method method : type.getMethods()) { if (Mo...
java
private static <T> List<Method> getMethods(Class<T> type, String... names) { Assert.notNull(type, "Missing class to search for methods!"); Assert.notNullOrEmpty(names, "Missing method names to search for!"); Map<String, Method> candidates = new HashMap<>(); for (Method method : type.getMethods()) { if (Mo...
[ "private", "static", "<", "T", ">", "List", "<", "Method", ">", "getMethods", "(", "Class", "<", "T", ">", "type", ",", "String", "...", "names", ")", "{", "Assert", ".", "notNull", "(", "type", ",", "\"Missing class to search for methods!\"", ")", ";", ...
Get methods in order desired to invoke them one by one until match or fail @param type desired @param names of methods in order @param <T> class to search for methods @return method list to use
[ "Get", "methods", "in", "order", "desired", "to", "invoke", "them", "one", "by", "one", "until", "match", "or", "fail" ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/data/ClassFactory.java#L574-L601
train
zandero/rest.vertx
src/main/java/com/zandero/rest/RestBuilder.java
RestBuilder.errorHandler
@SafeVarargs public final RestBuilder errorHandler(Class<? extends ExceptionHandler>... handlers) { Assert.notNullOrEmpty(handlers, "Missing exception handler(s)!"); exceptionHandlers.addAll(Arrays.asList(handlers)); return this; }
java
@SafeVarargs public final RestBuilder errorHandler(Class<? extends ExceptionHandler>... handlers) { Assert.notNullOrEmpty(handlers, "Missing exception handler(s)!"); exceptionHandlers.addAll(Arrays.asList(handlers)); return this; }
[ "@", "SafeVarargs", "public", "final", "RestBuilder", "errorHandler", "(", "Class", "<", "?", "extends", "ExceptionHandler", ">", "...", "handlers", ")", "{", "Assert", ".", "notNullOrEmpty", "(", "handlers", ",", "\"Missing exception handler(s)!\"", ")", ";", "ex...
Registeres one or more exception handler classes @param handlers to be registered @return builder
[ "Registeres", "one", "or", "more", "exception", "handler", "classes" ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/RestBuilder.java#L177-L184
train
zandero/rest.vertx
src/main/java/com/zandero/rest/RestBuilder.java
RestBuilder.provide
public <T> RestBuilder provide(ContextProvider<T> provider) { Assert.notNull(provider, "Missing context provider!"); contextProviders.add(provider); return this; }
java
public <T> RestBuilder provide(ContextProvider<T> provider) { Assert.notNull(provider, "Missing context provider!"); contextProviders.add(provider); return this; }
[ "public", "<", "T", ">", "RestBuilder", "provide", "(", "ContextProvider", "<", "T", ">", "provider", ")", "{", "Assert", ".", "notNull", "(", "provider", ",", "\"Missing context provider!\"", ")", ";", "contextProviders", ".", "add", "(", "provider", ")", "...
Creates a provider handler into routing @param provider to be executed on every request @param <T> provided object to insert into @Context @return builder
[ "Creates", "a", "provider", "handler", "into", "routing" ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/RestBuilder.java#L297-L303
train
zandero/rest.vertx
src/main/java/com/zandero/rest/data/MediaTypeHelper.java
MediaTypeHelper.parse
private static MediaType parse(String mediaType) { Assert.notNullOrEmptyTrimmed(mediaType, "Missing media type!"); String type = null; String subType = null; Map<String, String> params = new HashMap<>(); String[] parts = mediaType.split(";"); for (int i = 0; i < parts.length; i++) { String part = Str...
java
private static MediaType parse(String mediaType) { Assert.notNullOrEmptyTrimmed(mediaType, "Missing media type!"); String type = null; String subType = null; Map<String, String> params = new HashMap<>(); String[] parts = mediaType.split(";"); for (int i = 0; i < parts.length; i++) { String part = Str...
[ "private", "static", "MediaType", "parse", "(", "String", "mediaType", ")", "{", "Assert", ".", "notNullOrEmptyTrimmed", "(", "mediaType", ",", "\"Missing media type!\"", ")", ";", "String", "type", "=", "null", ";", "String", "subType", "=", "null", ";", "Map...
Simple parsing utility to get MediaType @param mediaType to be parsed @return media type of throw IllegalArgumentException if parsing fails
[ "Simple", "parsing", "utility", "to", "get", "MediaType" ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/data/MediaTypeHelper.java#L73-L113
train
zandero/rest.vertx
src/main/java/com/zandero/rest/reader/ReaderFactory.java
ReaderFactory.get
public ValueReader get(MethodParameter parameter, Class<? extends ValueReader> byMethodDefinition, InjectionProvider provider, RoutingContext context, MediaType... mediaTypes) { // by type Class<?> readerType = null; ...
java
public ValueReader get(MethodParameter parameter, Class<? extends ValueReader> byMethodDefinition, InjectionProvider provider, RoutingContext context, MediaType... mediaTypes) { // by type Class<?> readerType = null; ...
[ "public", "ValueReader", "get", "(", "MethodParameter", "parameter", ",", "Class", "<", "?", "extends", "ValueReader", ">", "byMethodDefinition", ",", "InjectionProvider", "provider", ",", "RoutingContext", "context", ",", "MediaType", "...", "mediaTypes", ")", "{",...
Step over all possibilities to provide desired reader @param parameter check parameter if reader is set or we have a type reader present @param byMethodDefinition check default definition @param provider injection provider if any @param context routing context @param mediaTypes ch...
[ "Step", "over", "all", "possibilities", "to", "provide", "desired", "reader" ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/reader/ReaderFactory.java#L49-L83
train
zandero/rest.vertx
src/main/java/com/zandero/rest/reader/ReaderFactory.java
ReaderFactory.register
public void register(Class<? extends ValueReader> reader) { Assert.notNull(reader, "Missing reader class!"); boolean registered = false; Consumes found = reader.getAnnotation(Consumes.class); if (found != null) { MediaType[] consumes = MediaTypeHelper.getMediaTypes(found.value()); if (consumes != null &...
java
public void register(Class<? extends ValueReader> reader) { Assert.notNull(reader, "Missing reader class!"); boolean registered = false; Consumes found = reader.getAnnotation(Consumes.class); if (found != null) { MediaType[] consumes = MediaTypeHelper.getMediaTypes(found.value()); if (consumes != null &...
[ "public", "void", "register", "(", "Class", "<", "?", "extends", "ValueReader", ">", "reader", ")", "{", "Assert", ".", "notNull", "(", "reader", ",", "\"Missing reader class!\"", ")", ";", "boolean", "registered", "=", "false", ";", "Consumes", "found", "="...
Takes media type from @Consumes annotation if specified, otherwise fallback to generics
[ "Takes", "media", "type", "from" ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/reader/ReaderFactory.java#L88-L106
train
zandero/rest.vertx
src/main/java/com/zandero/rest/AnnotationProcessor.java
AnnotationProcessor.get
public static Map<RouteDefinition, Method> get(Class clazz) { Map<RouteDefinition, Method> out = new HashMap<>(); Map<RouteDefinition, Method> candidates = collect(clazz); // Final check if definitions are OK for (RouteDefinition definition : candidates.keySet()) { if (definition.getMethod() == null) { //...
java
public static Map<RouteDefinition, Method> get(Class clazz) { Map<RouteDefinition, Method> out = new HashMap<>(); Map<RouteDefinition, Method> candidates = collect(clazz); // Final check if definitions are OK for (RouteDefinition definition : candidates.keySet()) { if (definition.getMethod() == null) { //...
[ "public", "static", "Map", "<", "RouteDefinition", ",", "Method", ">", "get", "(", "Class", "clazz", ")", "{", "Map", "<", "RouteDefinition", ",", "Method", ">", "out", "=", "new", "HashMap", "<>", "(", ")", ";", "Map", "<", "RouteDefinition", ",", "Me...
Extracts all JAX-RS annotated methods from class and all its subclasses and interfaces @param clazz to extract from @return map of routeDefinition and class method to execute
[ "Extracts", "all", "JAX", "-", "RS", "annotated", "methods", "from", "class", "and", "all", "its", "subclasses", "and", "interfaces" ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/AnnotationProcessor.java#L39-L81
train
zandero/rest.vertx
src/main/java/com/zandero/rest/AnnotationProcessor.java
AnnotationProcessor.find
private static RouteDefinition find(Map<RouteDefinition, Method> add, Method method) { if (add == null || add.size() == 0) { return null; } for (RouteDefinition additional : add.keySet()) { Method match = add.get(additional); if (isMatching(method, match)) { return additional; } } return n...
java
private static RouteDefinition find(Map<RouteDefinition, Method> add, Method method) { if (add == null || add.size() == 0) { return null; } for (RouteDefinition additional : add.keySet()) { Method match = add.get(additional); if (isMatching(method, match)) { return additional; } } return n...
[ "private", "static", "RouteDefinition", "find", "(", "Map", "<", "RouteDefinition", ",", "Method", ">", "add", ",", "Method", "method", ")", "{", "if", "(", "add", "==", "null", "||", "add", ".", "size", "(", ")", "==", "0", ")", "{", "return", "null...
Find mathing definition for same method ... @param add to search @param method base @return found definition or null if no match found
[ "Find", "mathing", "definition", "for", "same", "method", "..." ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/AnnotationProcessor.java#L133-L148
train
zandero/rest.vertx
src/main/java/com/zandero/rest/AnnotationProcessor.java
AnnotationProcessor.getDefinitions
private static Map<RouteDefinition, Method> getDefinitions(Class clazz) { Assert.notNull(clazz, "Missing class with JAX-RS annotations!"); // base RouteDefinition root = new RouteDefinition(clazz); // go over methods ... Map<RouteDefinition, Method> output = new LinkedHashMap<>(); for (Method method : cl...
java
private static Map<RouteDefinition, Method> getDefinitions(Class clazz) { Assert.notNull(clazz, "Missing class with JAX-RS annotations!"); // base RouteDefinition root = new RouteDefinition(clazz); // go over methods ... Map<RouteDefinition, Method> output = new LinkedHashMap<>(); for (Method method : cl...
[ "private", "static", "Map", "<", "RouteDefinition", ",", "Method", ">", "getDefinitions", "(", "Class", "clazz", ")", "{", "Assert", ".", "notNull", "(", "clazz", ",", "\"Missing class with JAX-RS annotations!\"", ")", ";", "// base", "RouteDefinition", "root", "=...
Checks class for JAX-RS annotations and returns a list of route definitions to build routes upon @param clazz to be checked @return list of definitions or empty list if none present
[ "Checks", "class", "for", "JAX", "-", "RS", "annotations", "and", "returns", "a", "list", "of", "route", "definitions", "to", "build", "routes", "upon" ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/AnnotationProcessor.java#L186-L211
train
zandero/rest.vertx
src/main/java/com/zandero/rest/context/ContextProviderFactory.java
ContextProviderFactory.provideContext
public static Object provideContext(Class<?> type, String defaultValue, RoutingContext context) throws ContextException { // vert.x context if (type.isAssignableFrom(HttpServerResponse.class)) { return context.response(); } if (type....
java
public static Object provideContext(Class<?> type, String defaultValue, RoutingContext context) throws ContextException { // vert.x context if (type.isAssignableFrom(HttpServerResponse.class)) { return context.response(); } if (type....
[ "public", "static", "Object", "provideContext", "(", "Class", "<", "?", ">", "type", ",", "String", "defaultValue", ",", "RoutingContext", "context", ")", "throws", "ContextException", "{", "// vert.x context", "if", "(", "type", ".", "isAssignableFrom", "(", "H...
Provides vertx context of desired type if possible @param type context type @param defaultValue default value if given @param context to provider / extract values from @return found context or null if not found @throws ContextException in case context could not be provided
[ "Provides", "vertx", "context", "of", "desired", "type", "if", "possible" ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/context/ContextProviderFactory.java#L98-L155
train
zandero/rest.vertx
src/main/java/com/zandero/rest/RestRouter.java
RestRouter.checkWriterCompatibility
private static void checkWriterCompatibility(RouteDefinition definition) { try { // no way to know the accept content at this point getWriter(injectionProvider, definition.getReturnType(), definition, null, GenericResponseWriter.class); } catch (ClassFactoryException e) { // ignoring instance creation ... b...
java
private static void checkWriterCompatibility(RouteDefinition definition) { try { // no way to know the accept content at this point getWriter(injectionProvider, definition.getReturnType(), definition, null, GenericResponseWriter.class); } catch (ClassFactoryException e) { // ignoring instance creation ... b...
[ "private", "static", "void", "checkWriterCompatibility", "(", "RouteDefinition", "definition", ")", "{", "try", "{", "// no way to know the accept content at this point", "getWriter", "(", "injectionProvider", ",", "definition", ".", "getReturnType", "(", ")", ",", "defin...
Check writer compatibility if possible
[ "Check", "writer", "compatibility", "if", "possible" ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/RestRouter.java#L191-L198
train
zandero/rest.vertx
src/main/java/com/zandero/rest/RestRouter.java
RestRouter.notFound
public static void notFound(Router router, Class<? extends NotFoundResponseWriter> notFound) { notFound(router, null, notFound); }
java
public static void notFound(Router router, Class<? extends NotFoundResponseWriter> notFound) { notFound(router, null, notFound); }
[ "public", "static", "void", "notFound", "(", "Router", "router", ",", "Class", "<", "?", "extends", "NotFoundResponseWriter", ">", "notFound", ")", "{", "notFound", "(", "router", ",", "null", ",", "notFound", ")", ";", "}" ]
Handles not found route for all requests @param router to add route to @param notFound handler
[ "Handles", "not", "found", "route", "for", "all", "requests" ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/RestRouter.java#L268-L270
train
zandero/rest.vertx
src/main/java/com/zandero/rest/RestRouter.java
RestRouter.notFound
public static void notFound(Router router, String regExPath, Class<? extends NotFoundResponseWriter> notFound) { Assert.notNull(router, "Missing router!"); Assert.notNull(notFound, "Missing not found handler!"); addLastHandler(router, regExPath, getNotFoundHandler(notFound)); }
java
public static void notFound(Router router, String regExPath, Class<? extends NotFoundResponseWriter> notFound) { Assert.notNull(router, "Missing router!"); Assert.notNull(notFound, "Missing not found handler!"); addLastHandler(router, regExPath, getNotFoundHandler(notFound)); }
[ "public", "static", "void", "notFound", "(", "Router", "router", ",", "String", "regExPath", ",", "Class", "<", "?", "extends", "NotFoundResponseWriter", ">", "notFound", ")", "{", "Assert", ".", "notNull", "(", "router", ",", "\"Missing router!\"", ")", ";", ...
Handles not found route in case request regExPath mathes given regExPath prefix @param router to add route to @param regExPath prefix @param notFound hander
[ "Handles", "not", "found", "route", "in", "case", "request", "regExPath", "mathes", "given", "regExPath", "prefix" ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/RestRouter.java#L304-L310
train
zandero/rest.vertx
src/main/java/com/zandero/rest/RestRouter.java
RestRouter.addProvider
public static void addProvider(Class<? extends ContextProvider> provider) { Class clazz = (Class) ClassFactory.getGenericType(provider); addProvider(clazz, provider); }
java
public static void addProvider(Class<? extends ContextProvider> provider) { Class clazz = (Class) ClassFactory.getGenericType(provider); addProvider(clazz, provider); }
[ "public", "static", "void", "addProvider", "(", "Class", "<", "?", "extends", "ContextProvider", ">", "provider", ")", "{", "Class", "clazz", "=", "(", "Class", ")", "ClassFactory", ".", "getGenericType", "(", "provider", ")", ";", "addProvider", "(", "clazz...
Registers a context provider for given type of class @param provider clazz type to be registered
[ "Registers", "a", "context", "provider", "for", "given", "type", "of", "class" ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/RestRouter.java#L727-L731
train
zandero/rest.vertx
src/main/java/com/zandero/rest/writer/WriterFactory.java
WriterFactory.getResponseWriter
public HttpResponseWriter getResponseWriter(Class returnType, RouteDefinition definition, InjectionProvider provider, RoutingContext routeContext, ...
java
public HttpResponseWriter getResponseWriter(Class returnType, RouteDefinition definition, InjectionProvider provider, RoutingContext routeContext, ...
[ "public", "HttpResponseWriter", "getResponseWriter", "(", "Class", "returnType", ",", "RouteDefinition", "definition", ",", "InjectionProvider", "provider", ",", "RoutingContext", "routeContext", ",", "MediaType", "accept", ")", "{", "try", "{", "HttpResponseWriter", "w...
Finds assigned response writer or tries to assign a writer according to produces annotation and result type @param returnType type of response @param definition method definition @param provider injection provider if any @param routeContext routing context @param accept accept media type header @return w...
[ "Finds", "assigned", "response", "writer", "or", "tries", "to", "assign", "a", "writer", "according", "to", "produces", "annotation", "and", "result", "type" ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/writer/WriterFactory.java#L52-L80
train
zandero/rest.vertx
src/main/java/com/zandero/rest/exception/ConstraintException.java
ConstraintException.createMessage
private static String createMessage(RouteDefinition definition, Set<? extends ConstraintViolation<?>> constraintViolations) { List<String> messages = new ArrayList<>(); for (ConstraintViolation<?> violation : constraintViolations) { StringBuilder message = new StringBuilder(); for (Path.Node next : violatio...
java
private static String createMessage(RouteDefinition definition, Set<? extends ConstraintViolation<?>> constraintViolations) { List<String> messages = new ArrayList<>(); for (ConstraintViolation<?> violation : constraintViolations) { StringBuilder message = new StringBuilder(); for (Path.Node next : violatio...
[ "private", "static", "String", "createMessage", "(", "RouteDefinition", "definition", ",", "Set", "<", "?", "extends", "ConstraintViolation", "<", "?", ">", ">", "constraintViolations", ")", "{", "List", "<", "String", ">", "messages", "=", "new", "ArrayList", ...
Tries to produce some sensible message to make some informed decision @param definition route definition to get parameter information @param constraintViolations list of violations @return message describing violation
[ "Tries", "to", "produce", "some", "sensible", "message", "to", "make", "some", "informed", "decision" ]
ba458720cf59e076953eab9dac7227eeaf9e58ce
https://github.com/zandero/rest.vertx/blob/ba458720cf59e076953eab9dac7227eeaf9e58ce/src/main/java/com/zandero/rest/exception/ConstraintException.java#L39-L82
train
hugegraph/hugegraph-common
src/main/java/com/baidu/hugegraph/util/CollectionUtil.java
CollectionUtil.subSet
public static <T> Set<T> subSet(Set<T> original, int from, int to) { List<T> list = new ArrayList<>(original); if (to == -1) { to = original.size(); } return new LinkedHashSet<>(list.subList(from, to)); }
java
public static <T> Set<T> subSet(Set<T> original, int from, int to) { List<T> list = new ArrayList<>(original); if (to == -1) { to = original.size(); } return new LinkedHashSet<>(list.subList(from, to)); }
[ "public", "static", "<", "T", ">", "Set", "<", "T", ">", "subSet", "(", "Set", "<", "T", ">", "original", ",", "int", "from", ",", "int", "to", ")", "{", "List", "<", "T", ">", "list", "=", "new", "ArrayList", "<>", "(", "original", ")", ";", ...
Get sub-set of a set. @param original original set @param from index of start position @param to index of end position(exclude), but -1 means the last element @param <T> element type of set @return sub-set of original set [from, to)
[ "Get", "sub", "-", "set", "of", "a", "set", "." ]
1eb2414134b639a13f68ca352c1b3eb2d956e7b2
https://github.com/hugegraph/hugegraph-common/blob/1eb2414134b639a13f68ca352c1b3eb2d956e7b2/src/main/java/com/baidu/hugegraph/util/CollectionUtil.java#L96-L102
train
hugegraph/hugegraph-common
src/main/java/com/baidu/hugegraph/util/CollectionUtil.java
CollectionUtil.intersect
public static <T> Collection<T> intersect(Collection<T> first, Collection<T> second) { E.checkNotNull(first, "first"); E.checkNotNull(second, "second"); HashSet<T> results = null; if (first instanceof HashSet) { @SuppressWarnings...
java
public static <T> Collection<T> intersect(Collection<T> first, Collection<T> second) { E.checkNotNull(first, "first"); E.checkNotNull(second, "second"); HashSet<T> results = null; if (first instanceof HashSet) { @SuppressWarnings...
[ "public", "static", "<", "T", ">", "Collection", "<", "T", ">", "intersect", "(", "Collection", "<", "T", ">", "first", ",", "Collection", "<", "T", ">", "second", ")", "{", "E", ".", "checkNotNull", "(", "first", ",", "\"first\"", ")", ";", "E", "...
Find the intersection of two collections, the original collections will not be modified @param first the first collection @param second the second collection @param <T> element type of collection @return intersection of the two collections
[ "Find", "the", "intersection", "of", "two", "collections", "the", "original", "collections", "will", "not", "be", "modified" ]
1eb2414134b639a13f68ca352c1b3eb2d956e7b2
https://github.com/hugegraph/hugegraph-common/blob/1eb2414134b639a13f68ca352c1b3eb2d956e7b2/src/main/java/com/baidu/hugegraph/util/CollectionUtil.java#L120-L135
train
hugegraph/hugegraph-common
src/main/java/com/baidu/hugegraph/util/CollectionUtil.java
CollectionUtil.intersectWithModify
public static <T> Collection<T> intersectWithModify(Collection<T> first, Collection<T> second) { E.checkNotNull(first, "first"); E.checkNotNull(second, "second"); first.retainAll(second); return first; }
java
public static <T> Collection<T> intersectWithModify(Collection<T> first, Collection<T> second) { E.checkNotNull(first, "first"); E.checkNotNull(second, "second"); first.retainAll(second); return first; }
[ "public", "static", "<", "T", ">", "Collection", "<", "T", ">", "intersectWithModify", "(", "Collection", "<", "T", ">", "first", ",", "Collection", "<", "T", ">", "second", ")", "{", "E", ".", "checkNotNull", "(", "first", ",", "\"first\"", ")", ";", ...
Find the intersection of two collections, note that the first collection will be modified and store the results @param first the first collection, it will be modified @param second the second collection @param <T> element type of collection @return intersection of the two collections
[ "Find", "the", "intersection", "of", "two", "collections", "note", "that", "the", "first", "collection", "will", "be", "modified", "and", "store", "the", "results" ]
1eb2414134b639a13f68ca352c1b3eb2d956e7b2
https://github.com/hugegraph/hugegraph-common/blob/1eb2414134b639a13f68ca352c1b3eb2d956e7b2/src/main/java/com/baidu/hugegraph/util/CollectionUtil.java#L145-L151
train
hugegraph/hugegraph-common
src/main/java/com/baidu/hugegraph/concurrent/KeyLock.java
KeyLock.lock
public final Lock lock(Object key) { Lock lock = this.locks.get(key); lock.lock(); return lock; }
java
public final Lock lock(Object key) { Lock lock = this.locks.get(key); lock.lock(); return lock; }
[ "public", "final", "Lock", "lock", "(", "Object", "key", ")", "{", "Lock", "lock", "=", "this", ".", "locks", ".", "get", "(", "key", ")", ";", "lock", ".", "lock", "(", ")", ";", "return", "lock", ";", "}" ]
Lock an object @param key The object to lock @return The lock(locked) of passed key
[ "Lock", "an", "object" ]
1eb2414134b639a13f68ca352c1b3eb2d956e7b2
https://github.com/hugegraph/hugegraph-common/blob/1eb2414134b639a13f68ca352c1b3eb2d956e7b2/src/main/java/com/baidu/hugegraph/concurrent/KeyLock.java#L60-L64
train
hugegraph/hugegraph-common
src/main/java/com/baidu/hugegraph/concurrent/KeyLock.java
KeyLock.lockAll
public final List<Lock> lockAll(Object... keys) { List<Lock> locks = new ArrayList<>(keys.length); for (Object key : keys) { Lock lock = this.locks.get(key); locks.add(lock); } Collections.sort(locks, (a, b) -> { int diff = a.hashCode() - b.hashCode();...
java
public final List<Lock> lockAll(Object... keys) { List<Lock> locks = new ArrayList<>(keys.length); for (Object key : keys) { Lock lock = this.locks.get(key); locks.add(lock); } Collections.sort(locks, (a, b) -> { int diff = a.hashCode() - b.hashCode();...
[ "public", "final", "List", "<", "Lock", ">", "lockAll", "(", "Object", "...", "keys", ")", "{", "List", "<", "Lock", ">", "locks", "=", "new", "ArrayList", "<>", "(", "keys", ".", "length", ")", ";", "for", "(", "Object", "key", ":", "keys", ")", ...
Lock a list of object with sorted order @param keys The objects to lock @return The locks(locked) of keys
[ "Lock", "a", "list", "of", "object", "with", "sorted", "order" ]
1eb2414134b639a13f68ca352c1b3eb2d956e7b2
https://github.com/hugegraph/hugegraph-common/blob/1eb2414134b639a13f68ca352c1b3eb2d956e7b2/src/main/java/com/baidu/hugegraph/concurrent/KeyLock.java#L79-L97
train
hugegraph/hugegraph-common
src/main/java/com/baidu/hugegraph/concurrent/KeyLock.java
KeyLock.unlockAll
public final void unlockAll(List<Lock> locks) { for (int i = locks.size(); i > 0; i--) { assert this.indexOf(locks.get(i - 1)) != -1; locks.get(i - 1).unlock(); } }
java
public final void unlockAll(List<Lock> locks) { for (int i = locks.size(); i > 0; i--) { assert this.indexOf(locks.get(i - 1)) != -1; locks.get(i - 1).unlock(); } }
[ "public", "final", "void", "unlockAll", "(", "List", "<", "Lock", ">", "locks", ")", "{", "for", "(", "int", "i", "=", "locks", ".", "size", "(", ")", ";", "i", ">", "0", ";", "i", "--", ")", "{", "assert", "this", ".", "indexOf", "(", "locks",...
Unlock a list of object @param locks The locks to unlock
[ "Unlock", "a", "list", "of", "object" ]
1eb2414134b639a13f68ca352c1b3eb2d956e7b2
https://github.com/hugegraph/hugegraph-common/blob/1eb2414134b639a13f68ca352c1b3eb2d956e7b2/src/main/java/com/baidu/hugegraph/concurrent/KeyLock.java#L131-L136
train
hugegraph/hugegraph-common
src/main/java/com/baidu/hugegraph/util/VersionUtil.java
VersionUtil.match
public static boolean match(Version version, String begin, String end) { E.checkArgumentNotNull(version, "The version to match is null"); return version.compareTo(new Version(begin)) >= 0 && version.compareTo(new Version(end)) < 0; }
java
public static boolean match(Version version, String begin, String end) { E.checkArgumentNotNull(version, "The version to match is null"); return version.compareTo(new Version(begin)) >= 0 && version.compareTo(new Version(end)) < 0; }
[ "public", "static", "boolean", "match", "(", "Version", "version", ",", "String", "begin", ",", "String", "end", ")", "{", "E", ".", "checkArgumentNotNull", "(", "version", ",", "\"The version to match is null\"", ")", ";", "return", "version", ".", "compareTo",...
Compare if a version is inside a range [begin, end) @param version The version to be compared @param begin The lower bound of the range @param end The upper bound of the range @return true if belong to the range, otherwise false
[ "Compare", "if", "a", "version", "is", "inside", "a", "range", "[", "begin", "end", ")" ]
1eb2414134b639a13f68ca352c1b3eb2d956e7b2
https://github.com/hugegraph/hugegraph-common/blob/1eb2414134b639a13f68ca352c1b3eb2d956e7b2/src/main/java/com/baidu/hugegraph/util/VersionUtil.java#L38-L42
train
hugegraph/hugegraph-common
src/main/java/com/baidu/hugegraph/util/VersionUtil.java
VersionUtil.check
public static void check(Version version, String begin, String end, String component) { E.checkState(VersionUtil.match(version, begin, end), "The version %s of '%s' is not in [%s, %s)", version, component, begin, end); }
java
public static void check(Version version, String begin, String end, String component) { E.checkState(VersionUtil.match(version, begin, end), "The version %s of '%s' is not in [%s, %s)", version, component, begin, end); }
[ "public", "static", "void", "check", "(", "Version", "version", ",", "String", "begin", ",", "String", "end", ",", "String", "component", ")", "{", "E", ".", "checkState", "(", "VersionUtil", ".", "match", "(", "version", ",", "begin", ",", "end", ")", ...
Check whether a component version is matched expected range, throw an exception if it's not matched. @param version The version to be checked @param begin The lower bound of the range @param end The upper bound of the range @param component The owner component of version
[ "Check", "whether", "a", "component", "version", "is", "matched", "expected", "range", "throw", "an", "exception", "if", "it", "s", "not", "matched", "." ]
1eb2414134b639a13f68ca352c1b3eb2d956e7b2
https://github.com/hugegraph/hugegraph-common/blob/1eb2414134b639a13f68ca352c1b3eb2d956e7b2/src/main/java/com/baidu/hugegraph/util/VersionUtil.java#L63-L68
train
hugegraph/hugegraph-common
src/main/java/com/baidu/hugegraph/util/VersionUtil.java
VersionUtil.getImplementationVersion
public static String getImplementationVersion(Class<?> clazz) { /* * We don't use Package.getImplementationVersion() due to * a duplicate package would override the origin package info. * https://stackoverflow.com/questions/1272648/reading-my-own-jars-manifest */ Stri...
java
public static String getImplementationVersion(Class<?> clazz) { /* * We don't use Package.getImplementationVersion() due to * a duplicate package would override the origin package info. * https://stackoverflow.com/questions/1272648/reading-my-own-jars-manifest */ Stri...
[ "public", "static", "String", "getImplementationVersion", "(", "Class", "<", "?", ">", "clazz", ")", "{", "/*\n * We don't use Package.getImplementationVersion() due to\n * a duplicate package would override the origin package info.\n * https://stackoverflow.com/quest...
Get implementation version from manifest in jar @param clazz The class to be load from jar package @return The implementation version
[ "Get", "implementation", "version", "from", "manifest", "in", "jar" ]
1eb2414134b639a13f68ca352c1b3eb2d956e7b2
https://github.com/hugegraph/hugegraph-common/blob/1eb2414134b639a13f68ca352c1b3eb2d956e7b2/src/main/java/com/baidu/hugegraph/util/VersionUtil.java#L75-L100
train
hugegraph/hugegraph-common
src/main/java/com/baidu/hugegraph/util/VersionUtil.java
VersionUtil.getPomVersion
public static String getPomVersion() { String cmd = "mvn help:evaluate -Dexpression=project.version " + "-q -DforceStdout"; Process process = null; InputStreamReader isr = null; try { process = Runtime.getRuntime().exec(cmd); process.waitFor()...
java
public static String getPomVersion() { String cmd = "mvn help:evaluate -Dexpression=project.version " + "-q -DforceStdout"; Process process = null; InputStreamReader isr = null; try { process = Runtime.getRuntime().exec(cmd); process.waitFor()...
[ "public", "static", "String", "getPomVersion", "(", ")", "{", "String", "cmd", "=", "\"mvn help:evaluate -Dexpression=project.version \"", "+", "\"-q -DforceStdout\"", ";", "Process", "process", "=", "null", ";", "InputStreamReader", "isr", "=", "null", ";", "try", ...
Get version from pom.xml @return The pom version
[ "Get", "version", "from", "pom", ".", "xml" ]
1eb2414134b639a13f68ca352c1b3eb2d956e7b2
https://github.com/hugegraph/hugegraph-common/blob/1eb2414134b639a13f68ca352c1b3eb2d956e7b2/src/main/java/com/baidu/hugegraph/util/VersionUtil.java#L106-L132
train
GideonLeGrange/mikrotik-java
src/main/java/me/legrange/mikrotik/impl/Util.java
Util.write
static void write(Command cmd, OutputStream out) throws UnsupportedEncodingException, IOException { encode(cmd.getCommand(), out); for (Parameter param : cmd.getParameters()) { encode(String.format("=%s=%s", param.getName(), param.hasValue() ? param.getValue() : ""), out); } ...
java
static void write(Command cmd, OutputStream out) throws UnsupportedEncodingException, IOException { encode(cmd.getCommand(), out); for (Parameter param : cmd.getParameters()) { encode(String.format("=%s=%s", param.getName(), param.hasValue() ? param.getValue() : ""), out); } ...
[ "static", "void", "write", "(", "Command", "cmd", ",", "OutputStream", "out", ")", "throws", "UnsupportedEncodingException", ",", "IOException", "{", "encode", "(", "cmd", ".", "getCommand", "(", ")", ",", "out", ")", ";", "for", "(", "Parameter", "param", ...
write a command to the output stream
[ "write", "a", "command", "to", "the", "output", "stream" ]
7e9c0000a582b7bea042965bd91a6ae7c79a44a0
https://github.com/GideonLeGrange/mikrotik-java/blob/7e9c0000a582b7bea042965bd91a6ae7c79a44a0/src/main/java/me/legrange/mikrotik/impl/Util.java#L24-L48
train
GideonLeGrange/mikrotik-java
src/main/java/me/legrange/mikrotik/impl/Util.java
Util.decode
static String decode(InputStream in) throws ApiDataException, ApiConnectionException { StringBuilder res = new StringBuilder(); decode(in, res); return res.toString(); }
java
static String decode(InputStream in) throws ApiDataException, ApiConnectionException { StringBuilder res = new StringBuilder(); decode(in, res); return res.toString(); }
[ "static", "String", "decode", "(", "InputStream", "in", ")", "throws", "ApiDataException", ",", "ApiConnectionException", "{", "StringBuilder", "res", "=", "new", "StringBuilder", "(", ")", ";", "decode", "(", "in", ",", "res", ")", ";", "return", "res", "."...
decode bytes from an input stream of Mikrotik protocol sentences into text
[ "decode", "bytes", "from", "an", "input", "stream", "of", "Mikrotik", "protocol", "sentences", "into", "text" ]
7e9c0000a582b7bea042965bd91a6ae7c79a44a0
https://github.com/GideonLeGrange/mikrotik-java/blob/7e9c0000a582b7bea042965bd91a6ae7c79a44a0/src/main/java/me/legrange/mikrotik/impl/Util.java#L54-L58
train
GideonLeGrange/mikrotik-java
src/main/java/me/legrange/mikrotik/impl/Util.java
Util.decode
private static void decode(InputStream in, StringBuilder result) throws ApiDataException, ApiConnectionException { try { int len = readLen(in); if (len > 0) { byte buf[] = new byte[len]; for (int i = 0; i < len; ++i) { int c = in.read()...
java
private static void decode(InputStream in, StringBuilder result) throws ApiDataException, ApiConnectionException { try { int len = readLen(in); if (len > 0) { byte buf[] = new byte[len]; for (int i = 0; i < len; ++i) { int c = in.read()...
[ "private", "static", "void", "decode", "(", "InputStream", "in", ",", "StringBuilder", "result", ")", "throws", "ApiDataException", ",", "ApiConnectionException", "{", "try", "{", "int", "len", "=", "readLen", "(", "in", ")", ";", "if", "(", "len", ">", "0...
decode bytes from an input stream into Mikrotik protocol sentences
[ "decode", "bytes", "from", "an", "input", "stream", "into", "Mikrotik", "protocol", "sentences" ]
7e9c0000a582b7bea042965bd91a6ae7c79a44a0
https://github.com/GideonLeGrange/mikrotik-java/blob/7e9c0000a582b7bea042965bd91a6ae7c79a44a0/src/main/java/me/legrange/mikrotik/impl/Util.java#L63-L85
train
GideonLeGrange/mikrotik-java
src/main/java/me/legrange/mikrotik/impl/Util.java
Util.hashMD5
static String hashMD5(String s) throws ApiDataException { MessageDigest algorithm = null; try { algorithm = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException nsae) { throw new ApiDataException("Cannot find MD5 digest algorithm"); } byte[]...
java
static String hashMD5(String s) throws ApiDataException { MessageDigest algorithm = null; try { algorithm = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException nsae) { throw new ApiDataException("Cannot find MD5 digest algorithm"); } byte[]...
[ "static", "String", "hashMD5", "(", "String", "s", ")", "throws", "ApiDataException", "{", "MessageDigest", "algorithm", "=", "null", ";", "try", "{", "algorithm", "=", "MessageDigest", ".", "getInstance", "(", "\"MD5\"", ")", ";", "}", "catch", "(", "NoSuch...
makes MD5 hash of string for use with RouterOS API @param s - variable to make hash from @return - the md5 hash
[ "makes", "MD5", "hash", "of", "string", "for", "use", "with", "RouterOS", "API" ]
7e9c0000a582b7bea042965bd91a6ae7c79a44a0
https://github.com/GideonLeGrange/mikrotik-java/blob/7e9c0000a582b7bea042965bd91a6ae7c79a44a0/src/main/java/me/legrange/mikrotik/impl/Util.java#L93-L116
train
GideonLeGrange/mikrotik-java
src/main/java/me/legrange/mikrotik/impl/Util.java
Util.hexStrToStr
static String hexStrToStr(String s) { StringBuilder ret = new StringBuilder(); for (int i = 0; i < s.length(); i += 2) { ret.append((char) Integer.parseInt(s.substring(i, i + 2), 16)); } return ret.toString(); }
java
static String hexStrToStr(String s) { StringBuilder ret = new StringBuilder(); for (int i = 0; i < s.length(); i += 2) { ret.append((char) Integer.parseInt(s.substring(i, i + 2), 16)); } return ret.toString(); }
[ "static", "String", "hexStrToStr", "(", "String", "s", ")", "{", "StringBuilder", "ret", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "s", ".", "length", "(", ")", ";", "i", "+=", "2", ")", "{", "...
converts hex value string to normal strint for use with RouterOS API @param s - hex string to convert to @return - converted string.
[ "converts", "hex", "value", "string", "to", "normal", "strint", "for", "use", "with", "RouterOS", "API" ]
7e9c0000a582b7bea042965bd91a6ae7c79a44a0
https://github.com/GideonLeGrange/mikrotik-java/blob/7e9c0000a582b7bea042965bd91a6ae7c79a44a0/src/main/java/me/legrange/mikrotik/impl/Util.java#L124-L130
train
GideonLeGrange/mikrotik-java
src/main/java/me/legrange/mikrotik/impl/Util.java
Util.encode
private static void encode(String word, OutputStream out) throws UnsupportedEncodingException, IOException { byte bytes[] = word.getBytes("UTF-8"); int len = bytes.length; if (len < 0x80) { out.write(len); } else if (len < 0x4000) { len = len | 0x8000; ...
java
private static void encode(String word, OutputStream out) throws UnsupportedEncodingException, IOException { byte bytes[] = word.getBytes("UTF-8"); int len = bytes.length; if (len < 0x80) { out.write(len); } else if (len < 0x4000) { len = len | 0x8000; ...
[ "private", "static", "void", "encode", "(", "String", "word", ",", "OutputStream", "out", ")", "throws", "UnsupportedEncodingException", ",", "IOException", "{", "byte", "bytes", "[", "]", "=", "word", ".", "getBytes", "(", "\"UTF-8\"", ")", ";", "int", "len...
encode text using Mikrotik's encoding scheme and write it to an output stream.
[ "encode", "text", "using", "Mikrotik", "s", "encoding", "scheme", "and", "write", "it", "to", "an", "output", "stream", "." ]
7e9c0000a582b7bea042965bd91a6ae7c79a44a0
https://github.com/GideonLeGrange/mikrotik-java/blob/7e9c0000a582b7bea042965bd91a6ae7c79a44a0/src/main/java/me/legrange/mikrotik/impl/Util.java#L136-L164
train
GideonLeGrange/mikrotik-java
src/main/java/me/legrange/mikrotik/impl/Util.java
Util.readLen
private static int readLen(InputStream in) throws IOException { int c = in.read(); if (c > 0) { if ((c & 0x80) == 0) { } else if ((c & 0xC0) == 0x80) { c = c & ~0xC0; c = (c << 8) | in.read(); } else if ((c & 0xE0) == 0xC0) { ...
java
private static int readLen(InputStream in) throws IOException { int c = in.read(); if (c > 0) { if ((c & 0x80) == 0) { } else if ((c & 0xC0) == 0x80) { c = c & ~0xC0; c = (c << 8) | in.read(); } else if ((c & 0xE0) == 0xC0) { ...
[ "private", "static", "int", "readLen", "(", "InputStream", "in", ")", "throws", "IOException", "{", "int", "c", "=", "in", ".", "read", "(", ")", ";", "if", "(", "c", ">", "0", ")", "{", "if", "(", "(", "c", "&", "0x80", ")", "==", "0", ")", ...
read length bytes from stream and return length of coming word
[ "read", "length", "bytes", "from", "stream", "and", "return", "length", "of", "coming", "word" ]
7e9c0000a582b7bea042965bd91a6ae7c79a44a0
https://github.com/GideonLeGrange/mikrotik-java/blob/7e9c0000a582b7bea042965bd91a6ae7c79a44a0/src/main/java/me/legrange/mikrotik/impl/Util.java#L169-L194
train
GideonLeGrange/mikrotik-java
src/main/java/me/legrange/mikrotik/impl/Command.java
Command.addParameter
void addParameter(String name, String value) { params.add(new Parameter(name, value)); }
java
void addParameter(String name, String value) { params.add(new Parameter(name, value)); }
[ "void", "addParameter", "(", "String", "name", ",", "String", "value", ")", "{", "params", ".", "add", "(", "new", "Parameter", "(", "name", ",", "value", ")", ")", ";", "}" ]
Add a parameter to a command.
[ "Add", "a", "parameter", "to", "a", "command", "." ]
7e9c0000a582b7bea042965bd91a6ae7c79a44a0
https://github.com/GideonLeGrange/mikrotik-java/blob/7e9c0000a582b7bea042965bd91a6ae7c79a44a0/src/main/java/me/legrange/mikrotik/impl/Command.java#L34-L36
train
GideonLeGrange/mikrotik-java
src/main/java/me/legrange/mikrotik/ApiConnection.java
ApiConnection.connect
public static ApiConnection connect(SocketFactory fact, String host, int port, int timeout) throws MikrotikApiException { return ApiConnectionImpl.connect(fact, host, port, timeout); }
java
public static ApiConnection connect(SocketFactory fact, String host, int port, int timeout) throws MikrotikApiException { return ApiConnectionImpl.connect(fact, host, port, timeout); }
[ "public", "static", "ApiConnection", "connect", "(", "SocketFactory", "fact", ",", "String", "host", ",", "int", "port", ",", "int", "timeout", ")", "throws", "MikrotikApiException", "{", "return", "ApiConnectionImpl", ".", "connect", "(", "fact", ",", "host", ...
Create a new API connection to the give device on the supplied port using the supplied socket factory to create the socket. @param fact SocketFactory to use for TCP socket creation. @param host The host to which to connect. @param port The TCP port to use. @param timeout The connection timeout to use when opening the ...
[ "Create", "a", "new", "API", "connection", "to", "the", "give", "device", "on", "the", "supplied", "port", "using", "the", "supplied", "socket", "factory", "to", "create", "the", "socket", "." ]
7e9c0000a582b7bea042965bd91a6ae7c79a44a0
https://github.com/GideonLeGrange/mikrotik-java/blob/7e9c0000a582b7bea042965bd91a6ae7c79a44a0/src/main/java/me/legrange/mikrotik/ApiConnection.java#L47-L49
train
GideonLeGrange/mikrotik-java
src/main/java/me/legrange/mikrotik/ApiConnection.java
ApiConnection.connect
public static ApiConnection connect(String host) throws MikrotikApiException { return connect(SocketFactory.getDefault(), host, DEFAULT_PORT, DEFAULT_COMMAND_TIMEOUT); }
java
public static ApiConnection connect(String host) throws MikrotikApiException { return connect(SocketFactory.getDefault(), host, DEFAULT_PORT, DEFAULT_COMMAND_TIMEOUT); }
[ "public", "static", "ApiConnection", "connect", "(", "String", "host", ")", "throws", "MikrotikApiException", "{", "return", "connect", "(", "SocketFactory", ".", "getDefault", "(", ")", ",", "host", ",", "DEFAULT_PORT", ",", "DEFAULT_COMMAND_TIMEOUT", ")", ";", ...
Create a new API connection to the give device on the default API port. @param host The host to which to connect. @return The ApiConnection @throws me.legrange.mikrotik.MikrotikApiException Thrown if there is a problem connecting
[ "Create", "a", "new", "API", "connection", "to", "the", "give", "device", "on", "the", "default", "API", "port", "." ]
7e9c0000a582b7bea042965bd91a6ae7c79a44a0
https://github.com/GideonLeGrange/mikrotik-java/blob/7e9c0000a582b7bea042965bd91a6ae7c79a44a0/src/main/java/me/legrange/mikrotik/ApiConnection.java#L59-L61
train
GideonLeGrange/mikrotik-java
src/main/java/me/legrange/mikrotik/impl/ApiConnectionImpl.java
ApiConnectionImpl.connect
public static ApiConnection connect(SocketFactory fact, String host, int port, int timeOut) throws ApiConnectionException { ApiConnectionImpl con = new ApiConnectionImpl(); con.open(host, port, fact, timeOut); return con; }
java
public static ApiConnection connect(SocketFactory fact, String host, int port, int timeOut) throws ApiConnectionException { ApiConnectionImpl con = new ApiConnectionImpl(); con.open(host, port, fact, timeOut); return con; }
[ "public", "static", "ApiConnection", "connect", "(", "SocketFactory", "fact", ",", "String", "host", ",", "int", "port", ",", "int", "timeOut", ")", "throws", "ApiConnectionException", "{", "ApiConnectionImpl", "con", "=", "new", "ApiConnectionImpl", "(", ")", "...
Create a new API connection to the give device on the supplied port @param fact The socket factory used to construct the connection socket. @param host The host to which to connect. @param port The TCP port to use. @param timeOut The connection timeout @return The ApiConnection @throws me.legrange.mikrotik.ApiConnecti...
[ "Create", "a", "new", "API", "connection", "to", "the", "give", "device", "on", "the", "supplied", "port" ]
7e9c0000a582b7bea042965bd91a6ae7c79a44a0
https://github.com/GideonLeGrange/mikrotik-java/blob/7e9c0000a582b7bea042965bd91a6ae7c79a44a0/src/main/java/me/legrange/mikrotik/impl/ApiConnectionImpl.java#L42-L46
train
GideonLeGrange/mikrotik-java
src/main/java/me/legrange/mikrotik/impl/ApiConnectionImpl.java
ApiConnectionImpl.open
private void open(String host, int port, SocketFactory fact, int conTimeout) throws ApiConnectionException { try { InetAddress ia = InetAddress.getByName(host.trim()); sock = fact.createSocket(); sock.connect(new InetSocketAddress(ia, port), conTimeout); in = new ...
java
private void open(String host, int port, SocketFactory fact, int conTimeout) throws ApiConnectionException { try { InetAddress ia = InetAddress.getByName(host.trim()); sock = fact.createSocket(); sock.connect(new InetSocketAddress(ia, port), conTimeout); in = new ...
[ "private", "void", "open", "(", "String", "host", ",", "int", "port", ",", "SocketFactory", "fact", ",", "int", "conTimeout", ")", "throws", "ApiConnectionException", "{", "try", "{", "InetAddress", "ia", "=", "InetAddress", ".", "getByName", "(", "host", "....
Start the API. Connects to the Mikrotik
[ "Start", "the", "API", ".", "Connects", "to", "the", "Mikrotik" ]
7e9c0000a582b7bea042965bd91a6ae7c79a44a0
https://github.com/GideonLeGrange/mikrotik-java/blob/7e9c0000a582b7bea042965bd91a6ae7c79a44a0/src/main/java/me/legrange/mikrotik/impl/ApiConnectionImpl.java#L138-L159
train
GideonLeGrange/mikrotik-java
src/main/java/me/legrange/mikrotik/impl/Scanner.java
Scanner.next
Token next() throws ScanException { text = null; switch (c) { case '\n': return EOL; case ' ': case '\t': return whiteSpace(); case ',': nextChar(); return COMMA; case '/': ...
java
Token next() throws ScanException { text = null; switch (c) { case '\n': return EOL; case ' ': case '\t': return whiteSpace(); case ',': nextChar(); return COMMA; case '/': ...
[ "Token", "next", "(", ")", "throws", "ScanException", "{", "text", "=", "null", ";", "switch", "(", "c", ")", "{", "case", "'", "'", ":", "return", "EOL", ";", "case", "'", "'", ":", "case", "'", "'", ":", "return", "whiteSpace", "(", ")", ";", ...
return the next token from the text
[ "return", "the", "next", "token", "from", "the", "text" ]
7e9c0000a582b7bea042965bd91a6ae7c79a44a0
https://github.com/GideonLeGrange/mikrotik-java/blob/7e9c0000a582b7bea042965bd91a6ae7c79a44a0/src/main/java/me/legrange/mikrotik/impl/Scanner.java#L60-L93
train
GideonLeGrange/mikrotik-java
src/main/java/me/legrange/mikrotik/impl/Scanner.java
Scanner.name
private Token name() throws ScanException { text = new StringBuilder(); while (!in(c, "[ \t\r\n=<>!]")) { text.append(c); nextChar(); } String val = text.toString().toLowerCase(Locale.getDefault()); switch (val) { case "where": ...
java
private Token name() throws ScanException { text = new StringBuilder(); while (!in(c, "[ \t\r\n=<>!]")) { text.append(c); nextChar(); } String val = text.toString().toLowerCase(Locale.getDefault()); switch (val) { case "where": ...
[ "private", "Token", "name", "(", ")", "throws", "ScanException", "{", "text", "=", "new", "StringBuilder", "(", ")", ";", "while", "(", "!", "in", "(", "c", ",", "\"[ \\t\\r\\n=<>!]\"", ")", ")", "{", "text", ".", "append", "(", "c", ")", ";", "nextC...
process 'name' tokens which could be key words or text
[ "process", "name", "tokens", "which", "could", "be", "key", "words", "or", "text" ]
7e9c0000a582b7bea042965bd91a6ae7c79a44a0
https://github.com/GideonLeGrange/mikrotik-java/blob/7e9c0000a582b7bea042965bd91a6ae7c79a44a0/src/main/java/me/legrange/mikrotik/impl/Scanner.java#L115-L135
train
GideonLeGrange/mikrotik-java
src/main/java/me/legrange/mikrotik/impl/Scanner.java
Scanner.quotedText
private Token quotedText(char quote) throws ScanException { nextChar(); // eat the '"' text = new StringBuilder(); while (c != quote) { if (c == '\n') { throw new ScanException("Unclosed quoted text, reached end of line."); } text.append(c); ...
java
private Token quotedText(char quote) throws ScanException { nextChar(); // eat the '"' text = new StringBuilder(); while (c != quote) { if (c == '\n') { throw new ScanException("Unclosed quoted text, reached end of line."); } text.append(c); ...
[ "private", "Token", "quotedText", "(", "char", "quote", ")", "throws", "ScanException", "{", "nextChar", "(", ")", ";", "// eat the '\"'", "text", "=", "new", "StringBuilder", "(", ")", ";", "while", "(", "c", "!=", "quote", ")", "{", "if", "(", "c", "...
process quoted text
[ "process", "quoted", "text" ]
7e9c0000a582b7bea042965bd91a6ae7c79a44a0
https://github.com/GideonLeGrange/mikrotik-java/blob/7e9c0000a582b7bea042965bd91a6ae7c79a44a0/src/main/java/me/legrange/mikrotik/impl/Scanner.java#L140-L152
train
GideonLeGrange/mikrotik-java
src/main/java/me/legrange/mikrotik/impl/Scanner.java
Scanner.nextChar
private void nextChar() { if (pos < line.length()) { c = line.charAt(pos); pos++; } else { c = '\n'; } }
java
private void nextChar() { if (pos < line.length()) { c = line.charAt(pos); pos++; } else { c = '\n'; } }
[ "private", "void", "nextChar", "(", ")", "{", "if", "(", "pos", "<", "line", ".", "length", "(", ")", ")", "{", "c", "=", "line", ".", "charAt", "(", "pos", ")", ";", "pos", "++", ";", "}", "else", "{", "c", "=", "'", "'", ";", "}", "}" ]
return the next character from the line of text
[ "return", "the", "next", "character", "from", "the", "line", "of", "text" ]
7e9c0000a582b7bea042965bd91a6ae7c79a44a0
https://github.com/GideonLeGrange/mikrotik-java/blob/7e9c0000a582b7bea042965bd91a6ae7c79a44a0/src/main/java/me/legrange/mikrotik/impl/Scanner.java#L179-L186
train
GideonLeGrange/mikrotik-java
src/main/java/me/legrange/mikrotik/impl/Parser.java
Parser.parse
static Command parse(String text) throws ParseException { Parser parser = new Parser(text); return parser.parse(); }
java
static Command parse(String text) throws ParseException { Parser parser = new Parser(text); return parser.parse(); }
[ "static", "Command", "parse", "(", "String", "text", ")", "throws", "ParseException", "{", "Parser", "parser", "=", "new", "Parser", "(", "text", ")", ";", "return", "parser", ".", "parse", "(", ")", ";", "}" ]
parse the given bit of text into a Command object
[ "parse", "the", "given", "bit", "of", "text", "into", "a", "Command", "object" ]
7e9c0000a582b7bea042965bd91a6ae7c79a44a0
https://github.com/GideonLeGrange/mikrotik-java/blob/7e9c0000a582b7bea042965bd91a6ae7c79a44a0/src/main/java/me/legrange/mikrotik/impl/Parser.java#L15-L18
train
GideonLeGrange/mikrotik-java
src/main/java/me/legrange/mikrotik/impl/Parser.java
Parser.parse
private Command parse() throws ParseException { command(); while (!is(Token.WHERE, Token.RETURN, Token.EOL)) { param(); } if (token == Token.WHERE) { where(); } if (token == Token.RETURN) { returns(); } expect(Token.EOL...
java
private Command parse() throws ParseException { command(); while (!is(Token.WHERE, Token.RETURN, Token.EOL)) { param(); } if (token == Token.WHERE) { where(); } if (token == Token.RETURN) { returns(); } expect(Token.EOL...
[ "private", "Command", "parse", "(", ")", "throws", "ParseException", "{", "command", "(", ")", ";", "while", "(", "!", "is", "(", "Token", ".", "WHERE", ",", "Token", ".", "RETURN", ",", "Token", ".", "EOL", ")", ")", "{", "param", "(", ")", ";", ...
run parse on the internal data and return the command object
[ "run", "parse", "on", "the", "internal", "data", "and", "return", "the", "command", "object" ]
7e9c0000a582b7bea042965bd91a6ae7c79a44a0
https://github.com/GideonLeGrange/mikrotik-java/blob/7e9c0000a582b7bea042965bd91a6ae7c79a44a0/src/main/java/me/legrange/mikrotik/impl/Parser.java#L21-L34
train
GideonLeGrange/mikrotik-java
src/main/java/me/legrange/mikrotik/impl/Parser.java
Parser.next
private void next() throws ScanException { token = scanner.next(); while (token == Token.WS) { token = scanner.next(); } text = scanner.text(); }
java
private void next() throws ScanException { token = scanner.next(); while (token == Token.WS) { token = scanner.next(); } text = scanner.text(); }
[ "private", "void", "next", "(", ")", "throws", "ScanException", "{", "token", "=", "scanner", ".", "next", "(", ")", ";", "while", "(", "token", "==", "Token", ".", "WS", ")", "{", "token", "=", "scanner", ".", "next", "(", ")", ";", "}", "text", ...
move to the next token returned by the scanner
[ "move", "to", "the", "next", "token", "returned", "by", "the", "scanner" ]
7e9c0000a582b7bea042965bd91a6ae7c79a44a0
https://github.com/GideonLeGrange/mikrotik-java/blob/7e9c0000a582b7bea042965bd91a6ae7c79a44a0/src/main/java/me/legrange/mikrotik/impl/Parser.java#L194-L200
train
GoSimpleLLC/nbvcxz
src/main/java/me/gosimple/nbvcxz/resources/AdjacencyGraphUtil.java
AdjacencyGraphUtil.calcAverageDegree
public static double calcAverageDegree(HashMap<Character, String[]> keys) { double average = 0d; for (Map.Entry<Character, String[]> entry : keys.entrySet()) { average += neighborsNumber(entry.getValue()); } return average / (double) keys.size(); }
java
public static double calcAverageDegree(HashMap<Character, String[]> keys) { double average = 0d; for (Map.Entry<Character, String[]> entry : keys.entrySet()) { average += neighborsNumber(entry.getValue()); } return average / (double) keys.size(); }
[ "public", "static", "double", "calcAverageDegree", "(", "HashMap", "<", "Character", ",", "String", "[", "]", ">", "keys", ")", "{", "double", "average", "=", "0d", ";", "for", "(", "Map", ".", "Entry", "<", "Character", ",", "String", "[", "]", ">", ...
Calculates the average "degree" of a keyboard or keypad. On the qwerty keyboard, 'g' has degree 6, being adjacent to 'ftyhbv' and '\' has degree 1. @param keys a keyboard or keypad @return the average degree for this keyboard or keypad
[ "Calculates", "the", "average", "degree", "of", "a", "keyboard", "or", "keypad", ".", "On", "the", "qwerty", "keyboard", "g", "has", "degree", "6", "being", "adjacent", "to", "ftyhbv", "and", "\\", "has", "degree", "1", "." ]
a86fb24680e646efdf78d6fda9d68a5410145f56
https://github.com/GoSimpleLLC/nbvcxz/blob/a86fb24680e646efdf78d6fda9d68a5410145f56/src/main/java/me/gosimple/nbvcxz/resources/AdjacencyGraphUtil.java#L281-L289
train
GoSimpleLLC/nbvcxz
src/main/java/me/gosimple/nbvcxz/resources/AdjacencyGraphUtil.java
AdjacencyGraphUtil.neighborsNumber
public static int neighborsNumber(String[] neighbors) { int sum = 0; for (String s : neighbors) { if (s != null) { sum++; } } return sum; }
java
public static int neighborsNumber(String[] neighbors) { int sum = 0; for (String s : neighbors) { if (s != null) { sum++; } } return sum; }
[ "public", "static", "int", "neighborsNumber", "(", "String", "[", "]", "neighbors", ")", "{", "int", "sum", "=", "0", ";", "for", "(", "String", "s", ":", "neighbors", ")", "{", "if", "(", "s", "!=", "null", ")", "{", "sum", "++", ";", "}", "}", ...
Count how many neighbors a key has @param neighbors the neighbors @return the number of neighbors
[ "Count", "how", "many", "neighbors", "a", "key", "has" ]
a86fb24680e646efdf78d6fda9d68a5410145f56
https://github.com/GoSimpleLLC/nbvcxz/blob/a86fb24680e646efdf78d6fda9d68a5410145f56/src/main/java/me/gosimple/nbvcxz/resources/AdjacencyGraphUtil.java#L298-L309
train
GoSimpleLLC/nbvcxz
src/main/java/me/gosimple/nbvcxz/resources/AdjacencyGraphUtil.java
AdjacencyGraphUtil.getNeighbors
public static Set<Character> getNeighbors(final AdjacencyGraph adjacencyGraph, final Character key) { final Set<Character> neighbors = new HashSet<>(); if (adjacencyGraph.getKeyMap().containsKey(key)) { String[] tmp_neighbors = adjacencyGraph.getKeyMap().get(key); fo...
java
public static Set<Character> getNeighbors(final AdjacencyGraph adjacencyGraph, final Character key) { final Set<Character> neighbors = new HashSet<>(); if (adjacencyGraph.getKeyMap().containsKey(key)) { String[] tmp_neighbors = adjacencyGraph.getKeyMap().get(key); fo...
[ "public", "static", "Set", "<", "Character", ">", "getNeighbors", "(", "final", "AdjacencyGraph", "adjacencyGraph", ",", "final", "Character", "key", ")", "{", "final", "Set", "<", "Character", ">", "neighbors", "=", "new", "HashSet", "<>", "(", ")", ";", ...
Returns a set of neighbors for a specific character. @param adjacencyGraph the graph you are using to get the neighbors. @param key the character you are getting neighbors for. @return A set of characters which are neighbors to the passed in character.
[ "Returns", "a", "set", "of", "neighbors", "for", "a", "specific", "character", "." ]
a86fb24680e646efdf78d6fda9d68a5410145f56
https://github.com/GoSimpleLLC/nbvcxz/blob/a86fb24680e646efdf78d6fda9d68a5410145f56/src/main/java/me/gosimple/nbvcxz/resources/AdjacencyGraphUtil.java#L318-L338
train
GoSimpleLLC/nbvcxz
src/main/java/me/gosimple/nbvcxz/resources/AdjacencyGraphUtil.java
AdjacencyGraphUtil.getTurns
public static int getTurns(final AdjacencyGraph adjacencyGraph, final String part) { int direction = 0; int turns = 1; char[] parts = part.toCharArray(); for (int i1 = 0; i1 < parts.length; i1++) { Character character = parts[i1]; if (i1 + 1 >= parts....
java
public static int getTurns(final AdjacencyGraph adjacencyGraph, final String part) { int direction = 0; int turns = 1; char[] parts = part.toCharArray(); for (int i1 = 0; i1 < parts.length; i1++) { Character character = parts[i1]; if (i1 + 1 >= parts....
[ "public", "static", "int", "getTurns", "(", "final", "AdjacencyGraph", "adjacencyGraph", ",", "final", "String", "part", ")", "{", "int", "direction", "=", "0", ";", "int", "turns", "=", "1", ";", "char", "[", "]", "parts", "=", "part", ".", "toCharArray...
Returns the number of turns in the part passed in based on the adjacency graph. @param adjacencyGraph the graph you are using to get the neighbors. @param part the string you are getting turns for. @return the number of turns in this string for the {@code AdjacencyGraph}
[ "Returns", "the", "number", "of", "turns", "in", "the", "part", "passed", "in", "based", "on", "the", "adjacency", "graph", "." ]
a86fb24680e646efdf78d6fda9d68a5410145f56
https://github.com/GoSimpleLLC/nbvcxz/blob/a86fb24680e646efdf78d6fda9d68a5410145f56/src/main/java/me/gosimple/nbvcxz/resources/AdjacencyGraphUtil.java#L347-L390
train