_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q165900
DefaultConnectionPool.incrementGenerationOnSocketException
validation
private void incrementGenerationOnSocketException(final InternalConnection connection, final Throwable t) { if (t instanceof MongoSocketException && !(t instanceof MongoSocketReadTimeoutException)) { if (LOGGER.isWarnEnabled()) { LOGGER.warn(format("Got socket exception on connection...
java
{ "resource": "" }
q165901
ClassMap.getAncestry
validation
public static <T> List<Class<?>> getAncestry(final Class<T> clazz) { return ClassAncestry.getAncestry(clazz); }
java
{ "resource": "" }
q165902
ReplaceOptions.createReplaceOptions
validation
@Deprecated public static ReplaceOptions createReplaceOptions(final UpdateOptions updateOptions) { notNull("updateOptions", updateOptions); List<? extends Bson> arrayFilters = updateOptions.getArrayFilters(); isTrue("ArrayFilters should be empty.", arrayFilters == null || arrayFilters.isEm...
java
{ "resource": "" }
q165903
Base64.decode
validation
public static byte[] decode(final String s) { int delta = s.endsWith("==") ? 2 : s.endsWith("=") ? 1 : 0; byte[] buffer = new byte[s.length() * BYTES_PER_UNENCODED_BLOCK / BYTES_PER_ENCODED_BLOCK - delta]; int mask = 0xFF; int pos = 0; for (int i = 0; i < s.length(); i += BYTES_P...
java
{ "resource": "" }
q165904
Base64.encode
validation
public static String encode(final byte[] in) { int modulus = 0; int bitWorkArea = 0; int numEncodedBytes = (in.length / BYTES_PER_UNENCODED_BLOCK) * BYTES_PER_ENCODED_BLOCK + ((in.length % BYTES_PER_UNENCODED_BLOCK == 0) ? 0 : 4); byte[] buffer = new byte[numEncodedByte...
java
{ "resource": "" }
q165905
Mongo.getAddress
validation
@Deprecated @SuppressWarnings("deprecation") @Nullable public ServerAddress getAddress() { ClusterDescription description = getClusterDescription(); if (description.getPrimaries().isEmpty()) { return null; } return description.getPrimaries().get(0).getAddress(); ...
java
{ "resource": "" }
q165906
Mongo.getReplicaSetStatus
validation
@SuppressWarnings("deprecation") @Deprecated @Nullable public ReplicaSetStatus getReplicaSetStatus() { ClusterDescription clusterDescription = getClusterDescription(); return clusterDescription.getType() == REPLICA_SET && clusterDescription.getConnectionMode() == MULTIPLE ? ne...
java
{ "resource": "" }
q165907
Mongo.getDatabaseNames
validation
@Deprecated public List<String> getDatabaseNames() { return new MongoIterableImpl<DBObject>(null, createOperationExecutor(), ReadConcern.DEFAULT, primary(), options.getRetryReads()) { @Override public ReadOperation<BatchCursor<DBObject>> asReadOperation() { ...
java
{ "resource": "" }
q165908
Mongo.fsync
validation
@Deprecated public CommandResult fsync(final boolean async) { DBObject command = new BasicDBObject("fsync", 1); if (async) { command.put("async", 1); } return getDB(ADMIN_DATABASE_NAME).command(command); }
java
{ "resource": "" }
q165909
Mongo.fsyncAndLock
validation
@Deprecated public CommandResult fsyncAndLock() { DBObject command = new BasicDBObject("fsync", 1); command.put("lock", 1); return getDB(ADMIN_DATABASE_NAME).command(command); }
java
{ "resource": "" }
q165910
Mongo.unlock
validation
@Deprecated public DBObject unlock() { return DBObjects.toDBObject(createOperationExecutor().execute(new FsyncUnlockOperation(), readPreference, readConcern)); }
java
{ "resource": "" }
q165911
BsonValue.asNumber
validation
public BsonNumber asNumber() { if (getBsonType() != BsonType.INT32 && getBsonType() != BsonType.INT64 && getBsonType() != BsonType.DOUBLE) { throw new BsonInvalidOperationException(format("Value expected to be of a numerical BSON type is of unexpected type %s", ...
java
{ "resource": "" }
q165912
ConnectionId.withServerValue
validation
public ConnectionId withServerValue(final int serverValue) { isTrue("server value is null", this.serverValue == null); return new ConnectionId(serverId, localValue, serverValue); }
java
{ "resource": "" }
q165913
ClassAncestry.computeAncestry
validation
private static List<Class<?>> computeAncestry(final Class<?> c) { List<Class<?>> result = new ArrayList<Class<?>>(); result.add(Object.class); computeAncestry(c, result); Collections.reverse(result); return unmodifiableList(new ArrayList<Class<?>>(result)); }
java
{ "resource": "" }
q165914
Geometry.toJson
validation
@SuppressWarnings({"unchecked", "rawtypes", "deprecation"}) public String toJson() { StringWriter stringWriter = new StringWriter(); JsonWriter writer = new JsonWriter(stringWriter, new JsonWriterSettings()); Codec codec = getRegistry().get(getClass()); codec.encode(writer, this, Enc...
java
{ "resource": "" }
q165915
MapReduceWithInlineResultsOperation.execute
validation
@Override @SuppressWarnings("unchecked") public MapReduceBatchCursor<T> execute(final ReadBinding binding) { return executeCommand(binding, namespace.getDatabaseName(), getCommandCreator(binding.getSessionContext()), CommandResultDocumentCodec.create(decoder, "results"), transformer(), f...
java
{ "resource": "" }
q165916
IndexOptions.getExpireAfter
validation
@Nullable public Long getExpireAfter(final TimeUnit timeUnit) { if (expireAfterSeconds == null) { return null; } return timeUnit.convert(expireAfterSeconds, TimeUnit.SECONDS); }
java
{ "resource": "" }
q165917
GroupCommand.toDBObject
validation
public DBObject toDBObject() { DBObject args = new BasicDBObject("ns", collectionName).append("cond", condition) .append("$reduce", reduce) .append("initial", initial); if (keys...
java
{ "resource": "" }
q165918
ClusterDescription.getLogicalSessionTimeoutMinutes
validation
public Integer getLogicalSessionTimeoutMinutes() { Integer retVal = null; for (ServerDescription cur : getServersByPredicate(new Predicate() { @Override public boolean apply(final ServerDescription serverDescription) { return serverDescription.isPrimary() || serve...
java
{ "resource": "" }
q165919
ClusterDescription.getAll
validation
@Deprecated public Set<ServerDescription> getAll() { Set<ServerDescription> serverDescriptionSet = new TreeSet<ServerDescription>(new Comparator<ServerDescription>() { @Override public int compare(final ServerDescription o1, final ServerDescription o2) { int val = o1....
java
{ "resource": "" }
q165920
ClusterDescription.getByServerAddress
validation
@Deprecated public ServerDescription getByServerAddress(final ServerAddress serverAddress) { for (final ServerDescription cur : serverDescriptions) { if (cur.isOk() && cur.getAddress().equals(serverAddress)) { return cur; } } return null; }
java
{ "resource": "" }
q165921
ClusterDescription.getPrimaries
validation
@Deprecated public List<ServerDescription> getPrimaries() { return getServersByPredicate(new Predicate() { public boolean apply(final ServerDescription serverDescription) { return serverDescription.isPrimary(); } }); }
java
{ "resource": "" }
q165922
ClusterDescription.getSecondaries
validation
@Deprecated public List<ServerDescription> getSecondaries() { return getServersByPredicate(new Predicate() { public boolean apply(final ServerDescription serverDescription) { return serverDescription.isSecondary(); } }); }
java
{ "resource": "" }
q165923
ClusterDescription.getSecondaries
validation
@Deprecated public List<ServerDescription> getSecondaries(final TagSet tagSet) { return getServersByPredicate(new Predicate() { public boolean apply(final ServerDescription serverDescription) { return serverDescription.isSecondary() && serverDescription.hasTags(tagSet); ...
java
{ "resource": "" }
q165924
ClusterDescription.getAny
validation
@Deprecated public List<ServerDescription> getAny() { return getServersByPredicate(new Predicate() { public boolean apply(final ServerDescription serverDescription) { return serverDescription.isOk(); } }); }
java
{ "resource": "" }
q165925
ClusterDescription.getAnyPrimaryOrSecondary
validation
@Deprecated public List<ServerDescription> getAnyPrimaryOrSecondary() { return getServersByPredicate(new Predicate() { public boolean apply(final ServerDescription serverDescription) { return serverDescription.isPrimary() || serverDescription.isSecondary(); } ...
java
{ "resource": "" }
q165926
ClusterDescription.getAnyPrimaryOrSecondary
validation
@Deprecated public List<ServerDescription> getAnyPrimaryOrSecondary(final TagSet tagSet) { return getServersByPredicate(new Predicate() { public boolean apply(final ServerDescription serverDescription) { return (serverDescription.isPrimary() || serverDescription.isSecondary()) &&...
java
{ "resource": "" }
q165927
ClusterDescription.getShortDescription
validation
public String getShortDescription() { StringBuilder serverDescriptions = new StringBuilder(); String delimiter = ""; for (final ServerDescription cur : this.serverDescriptions) { serverDescriptions.append(delimiter).append(cur.getShortDescription()); delimiter = ", "; ...
java
{ "resource": "" }
q165928
MongoCredential.createCredential
validation
public static MongoCredential createCredential(final String userName, final String database, final char[] password) { return new MongoCredential(null, userName, database, password); }
java
{ "resource": "" }
q165929
MongoCredential.createScramSha256Credential
validation
public static MongoCredential createScramSha256Credential(final String userName, final String source, final char[] password) { return new MongoCredential(SCRAM_SHA_256, userName, source, password); }
java
{ "resource": "" }
q165930
MongoCredential.createPlainCredential
validation
public static MongoCredential createPlainCredential(final String userName, final String source, final char[] password) { return new MongoCredential(PLAIN, userName, source, password); }
java
{ "resource": "" }
q165931
MongoCredential.withMechanismProperty
validation
public <T> MongoCredential withMechanismProperty(final String key, final T value) { return new MongoCredential(this, key, value); }
java
{ "resource": "" }
q165932
MongoCredential.withMechanism
validation
public MongoCredential withMechanism(final AuthenticationMechanism mechanism) { if (this.mechanism != null) { throw new IllegalArgumentException("Mechanism already set"); } return new MongoCredential(mechanism, userName, source, password, mechanismProperties); }
java
{ "resource": "" }
q165933
MongoCredential.getMechanismProperty
validation
@SuppressWarnings("unchecked") @Nullable public <T> T getMechanismProperty(final String key, @Nullable final T defaultValue) { notNull("key", key); T value = (T) mechanismProperties.get(key.toLowerCase()); return (value == null) ? defaultValue : value; }
java
{ "resource": "" }
q165934
OutputBuffer.toByteArray
validation
public byte[] toByteArray() { try { ByteArrayOutputStream bout = new ByteArrayOutputStream(size()); pipe(bout); return bout.toByteArray(); } catch (IOException ioe) { throw new RuntimeException("should be impossible", ioe); } }
java
{ "resource": "" }
q165935
ClassMapBasedObjectSerializer.addObjectSerializer
validation
@SuppressWarnings("rawtypes") void addObjectSerializer(final Class c, final ObjectSerializer serializer) { _serializers.put(c, serializer); }
java
{ "resource": "" }
q165936
UpdateRequest.multi
validation
public UpdateRequest multi(final boolean isMulti) { if (isMulti && updateType == Type.REPLACE) { throw new IllegalArgumentException("Replacements can not be multi"); } this.isMulti = isMulti; return this; }
java
{ "resource": "" }
q165937
RequestMessage.encode
validation
public void encode(final BsonOutput bsonOutput, final SessionContext sessionContext) { notNull("sessionContext", sessionContext); int messageStartPosition = bsonOutput.getPosition(); writeMessagePrologue(bsonOutput); EncodingMetadata encodingMetadata = encodeMessageBodyWithMetadata(bsonO...
java
{ "resource": "" }
q165938
RequestMessage.writeMessagePrologue
validation
protected void writeMessagePrologue(final BsonOutput bsonOutput) { bsonOutput.writeInt32(0); // length: will set this later bsonOutput.writeInt32(id); bsonOutput.writeInt32(0); // response to bsonOutput.writeInt32(opCode.getValue()); }
java
{ "resource": "" }
q165939
RequestMessage.addDocument
validation
protected void addDocument(final BsonDocument document, final BsonOutput bsonOutput, final FieldNameValidator validator) { addDocument(document, getCodec(document), EncoderContext.builder().build(), bsonOutput, validator, settings.getMaxDocumentSize() + DOCUMEN...
java
{ "resource": "" }
q165940
RequestMessage.addCollectibleDocument
validation
protected void addCollectibleDocument(final BsonDocument document, final BsonOutput bsonOutput, final FieldNameValidator validator) { addDocument(document, getCodec(document), EncoderContext.builder().isEncodingCollectibleDocument(true).build(), bsonOutput, validator, settings.getMaxDocument...
java
{ "resource": "" }
q165941
RequestMessage.backpatchMessageLength
validation
protected void backpatchMessageLength(final int startPosition, final BsonOutput bsonOutput) { int messageLength = bsonOutput.getPosition() - startPosition; bsonOutput.writeInt32(bsonOutput.getPosition() - messageLength, messageLength); }
java
{ "resource": "" }
q165942
GridFSInputFile.createChunk
validation
protected DBObject createChunk(final Object id, final int currentChunkNumber, final byte[] writeBuffer) { return new BasicDBObject("files_id", id) .append("n", currentChunkNumber) .append("data", writeBuffer); }
java
{ "resource": "" }
q165943
DBCursor.copy
validation
public DBCursor copy() { return new DBCursor(collection, filter, findOptions, executor, decoderFactory, decoder, retryReads); }
java
{ "resource": "" }
q165944
DBCursor.hasNext
validation
@Override public boolean hasNext() { if (closed) { throw new IllegalStateException("Cursor has been closed"); } if (cursor == null) { FindOperation<DBObject> operation = getQueryOperation(decoder); if (operation.getCursorType() == CursorType.Tailable) { ...
java
{ "resource": "" }
q165945
DBCursor.tryNext
validation
@Nullable public DBObject tryNext() { if (cursor == null) { FindOperation<DBObject> operation = getQueryOperation(decoder); if (!operation.getCursorType().isTailable()) { throw new IllegalArgumentException("Can only be used with a tailable cursor"); } ...
java
{ "resource": "" }
q165946
DBCursor.toArray
validation
public List<DBObject> toArray(final int max) { checkIteratorOrArray(IteratorOrArray.ARRAY); fillArray(max - 1); return all; }
java
{ "resource": "" }
q165947
DBCursor.one
validation
@Nullable public DBObject one() { DBCursor findOneCursor = copy().limit(-1); try { return findOneCursor.hasNext() ? findOneCursor.next() : null; } finally { findOneCursor.close(); } }
java
{ "resource": "" }
q165948
DBCursor.getReadPreference
validation
public ReadPreference getReadPreference() { ReadPreference readPreference = findOptions.getReadPreference(); if (readPreference != null) { return readPreference; } return collection.getReadPreference(); }
java
{ "resource": "" }
q165949
DBCursor.getReadConcern
validation
ReadConcern getReadConcern() { ReadConcern readConcern = findOptions.getReadConcern(); if (readConcern != null) { return readConcern; } return collection.getReadConcern(); }
java
{ "resource": "" }
q165950
BasicBSONCallback._put
validation
protected void _put(final String name, final Object value) { cur().put(name, !BSON.hasDecodeHooks() ? value : BSON.applyDecodingHooks(value)); }
java
{ "resource": "" }
q165951
DefaultDBEncoder.putDBRef
validation
protected void putDBRef(final String name, final DBRef ref) { BasicDBObject dbRefDocument = new BasicDBObject("$ref", ref.getCollectionName()).append("$id", ref.getId()); if (ref.getDatabaseName() != null) { dbRefDocument.put("$db", ref.getDatabaseName()); } putObject(name, ...
java
{ "resource": "" }
q165952
BulkWriteResult.unacknowledged
validation
public static BulkWriteResult unacknowledged() { return new BulkWriteResult() { @Override public boolean wasAcknowledged() { return false; } @Override public int getInsertedCount() { throw getUnacknowledgedWriteExceptio...
java
{ "resource": "" }
q165953
ServerAddress.getSocketAddress
validation
public InetSocketAddress getSocketAddress() { try { return new InetSocketAddress(InetAddress.getByName(host), port); } catch (UnknownHostException e) { throw new MongoSocketException(e.getMessage(), this, e); } }
java
{ "resource": "" }
q165954
ServerAddress.getSocketAddresses
validation
public List<InetSocketAddress> getSocketAddresses() { try { InetAddress[] inetAddresses = InetAddress.getAllByName(host); List<InetSocketAddress> inetSocketAddressList = new ArrayList<InetSocketAddress>(); for (InetAddress inetAddress : inetAddresses) { inetSo...
java
{ "resource": "" }
q165955
Filters.ne
validation
public static <TItem> Bson ne(final String fieldName, @Nullable final TItem value) { return new OperatorFilter<TItem>("$ne", fieldName, value); }
java
{ "resource": "" }
q165956
Filters.gt
validation
public static <TItem> Bson gt(final String fieldName, final TItem value) { return new OperatorFilter<TItem>("$gt", fieldName, value); }
java
{ "resource": "" }
q165957
Filters.lt
validation
public static <TItem> Bson lt(final String fieldName, final TItem value) { return new OperatorFilter<TItem>("$lt", fieldName, value); }
java
{ "resource": "" }
q165958
Filters.gte
validation
public static <TItem> Bson gte(final String fieldName, final TItem value) { return new OperatorFilter<TItem>("$gte", fieldName, value); }
java
{ "resource": "" }
q165959
Filters.lte
validation
public static <TItem> Bson lte(final String fieldName, final TItem value) { return new OperatorFilter<TItem>("$lte", fieldName, value); }
java
{ "resource": "" }
q165960
Filters.or
validation
public static Bson or(final Iterable<Bson> filters) { return new OrNorFilter(OrNorFilter.Operator.OR, filters); }
java
{ "resource": "" }
q165961
Filters.nor
validation
public static Bson nor(final Iterable<Bson> filters) { return new OrNorFilter(OrNorFilter.Operator.NOR, filters); }
java
{ "resource": "" }
q165962
Filters.exists
validation
public static Bson exists(final String fieldName, final boolean exists) { return new OperatorFilter<BsonBoolean>("$exists", fieldName, BsonBoolean.valueOf(exists)); }
java
{ "resource": "" }
q165963
Filters.text
validation
@Deprecated public static Bson text(final String search, final String language) { notNull("search", search); return text(search, new TextSearchOptions().language(language)); }
java
{ "resource": "" }
q165964
Filters.text
validation
public static Bson text(final String search, final TextSearchOptions textSearchOptions) { notNull("search", search); notNull("textSearchOptions", textSearchOptions); return new TextFilter(search, textSearchOptions); }
java
{ "resource": "" }
q165965
Filters.elemMatch
validation
public static Bson elemMatch(final String fieldName, final Bson filter) { return new Bson() { @Override public <TDocument> BsonDocument toBsonDocument(final Class<TDocument> documentClass, final CodecRegistry codecRegistry) { return new BsonDocument(fieldName, new BsonDoc...
java
{ "resource": "" }
q165966
Filters.geoWithinBox
validation
public static Bson geoWithinBox(final String fieldName, final double lowerLeftX, final double lowerLeftY, final double upperRightX, final double upperRightY) { BsonDocument box = new BsonDocument("$box", new BsonArray(asList(...
java
{ "resource": "" }
q165967
Filters.geoWithinPolygon
validation
public static Bson geoWithinPolygon(final String fieldName, final List<List<Double>> points) { BsonArray pointsArray = new BsonArray(); for (List<Double> point : points) { pointsArray.add(new BsonArray(asList(new BsonDouble(point.get(0)), new BsonDouble(point.get(1))))); } Bs...
java
{ "resource": "" }
q165968
Filters.geoWithinCenter
validation
public static Bson geoWithinCenter(final String fieldName, final double x, final double y, final double radius) { BsonDocument center = new BsonDocument("$center", new BsonArray(Arrays.<BsonValue>asList(new BsonArray(asList(new BsonDouble(x), ...
java
{ "resource": "" }
q165969
Filters.near
validation
public static Bson near(final String fieldName, final Point geometry, @Nullable final Double maxDistance, @Nullable final Double minDistance) { return new GeometryOperatorFilter<Point>("$near", fieldName, geometry, maxDistance, minDistance); }
java
{ "resource": "" }
q165970
Filters.near
validation
public static Bson near(final String fieldName, final double x, final double y, @Nullable final Double maxDistance, @Nullable final Double minDistance) { return createNearFilterDocument(fieldName, x, y, maxDistance, minDistance, "$near"); }
java
{ "resource": "" }
q165971
BSON.regexFlags
validation
public static int regexFlags(final String s) { int flags = 0; if (s == null) { return flags; } for (final char f : s.toLowerCase().toCharArray()) { flags |= regexFlag(f); } return flags; }
java
{ "resource": "" }
q165972
BSON.regexFlag
validation
public static int regexFlag(final char c) { int flag = FLAG_LOOKUP[c]; if (flag == 0) { throw new IllegalArgumentException(String.format("Unrecognized flag [%c]", c)); } return flag; }
java
{ "resource": "" }
q165973
BSON.regexFlags
validation
public static String regexFlags(final int flags) { int processedFlags = flags; StringBuilder buf = new StringBuilder(); for (int i = 0; i < FLAG_LOOKUP.length; i++) { if ((processedFlags & FLAG_LOOKUP[i]) > 0) { buf.append((char) i); processedFlags -=...
java
{ "resource": "" }
q165974
IndexRequest.textVersion
validation
public IndexRequest textVersion(final Integer textVersion) { if (textVersion != null) { isTrueArgument("textVersion must be 1, 2 or 3", VALID_TEXT_INDEX_VERSIONS.contains(textVersion)); } this.textVersion = textVersion; return this; }
java
{ "resource": "" }
q165975
IndexRequest.sphereVersion
validation
public IndexRequest sphereVersion(final Integer sphereVersion) { if (sphereVersion != null) { isTrueArgument("sphereIndexVersion must be 1, 2 or 3", VALID_SPHERE_INDEX_VERSIONS.contains(sphereVersion)); } this.sphereVersion = sphereVersion; return this; }
java
{ "resource": "" }
q165976
DBCollectionFindOptions.copy
validation
public DBCollectionFindOptions copy() { DBCollectionFindOptions copiedOptions = new DBCollectionFindOptions(); copiedOptions.batchSize(batchSize); copiedOptions.limit(limit); copiedOptions.modifiers(modifiers); copiedOptions.projection(projection); copiedOptions.maxTime(m...
java
{ "resource": "" }
q165977
Assertions.convertToType
validation
@SuppressWarnings("unchecked") public static <T> T convertToType(final Class<T> clazz, final Object value, final String errorMessage) { if (!clazz.isAssignableFrom(value.getClass())) { throw new IllegalArgumentException(errorMessage); } return (T) value; }
java
{ "resource": "" }
q165978
DBEncoderAdapter.encode
validation
@Override public void encode(final BsonWriter writer, final DBObject document, final EncoderContext encoderContext) { BasicOutputBuffer buffer = new BasicOutputBuffer(); try { encoder.writeObject(buffer, document); BsonBinaryReader reader = new BsonBinaryReader(new ByteBuffer...
java
{ "resource": "" }
q165979
MixedBulkWriteOperation.execute
validation
@Override public BulkWriteResult execute(final WriteBinding binding) { return withReleasableConnection(binding, new CallableWithConnectionAndSource<BulkWriteResult>() { @Override public BulkWriteResult call(final ConnectionSource connectionSource, final Connection connection) { ...
java
{ "resource": "" }
q165980
BulkWriteRequestBuilder.upsert
validation
public BulkUpdateRequestBuilder upsert() { return new BulkUpdateRequestBuilder(bulkWriteOperation, query, true, codec, replacementCodec, collation, null); }
java
{ "resource": "" }
q165981
BulkWriteRequestBuilder.arrayFilters
validation
public BulkUpdateRequestBuilder arrayFilters(final List<? extends DBObject> arrayFilters) { return new BulkUpdateRequestBuilder(bulkWriteOperation, query, false, codec, replacementCodec, collation, arrayFilters); }
java
{ "resource": "" }
q165982
MapReduceToCollectionOperation.execute
validation
@Override public MapReduceStatistics execute(final WriteBinding binding) { return withConnection(binding, new OperationHelper.CallableWithConnection<MapReduceStatistics>() { @Override public MapReduceStatistics call(final Connection connection) { validateCollation(con...
java
{ "resource": "" }
q165983
MongoClients.init
validation
public static synchronized void init(final MongoEmbeddedSettings mongoEmbeddedSettings) { if (mongoEmbeddedLibrary != null) { throw new MongoClientEmbeddedException("The mongo embedded library has already been initialized"); } try { mongoEmbeddedLibrary = MongoEmbeddedCAP...
java
{ "resource": "" }
q165984
MongoClients.create
validation
public static synchronized MongoClient create(final MongoClientSettings mongoClientSettings) { if (mongoEmbeddedLibrary == null) { throw new MongoClientEmbeddedException("The mongo embedded library must be initialized first."); } try { Cluster cluster = new EmbeddedCluste...
java
{ "resource": "" }
q165985
MongoClients.close
validation
public static synchronized void close() { if (mongoEmbeddedLibrary != null) { try { mongoEmbeddedLibrary.close(); } catch (Exception e) { throw new MongoClientEmbeddedException(format("Could not close the mongo embedded library.%n" ...
java
{ "resource": "" }
q165986
SslHelper.enableSni
validation
public static void enableSni(final String host, final SSLParameters sslParameters) { if (SNI_SSL_HELPER != null) { SNI_SSL_HELPER.enableSni(host, sslParameters); } }
java
{ "resource": "" }
q165987
Bytes.getType
validation
@SuppressWarnings("deprecation") public static byte getType(final Object object) { if (object == null) { return NULL; } if (object instanceof Integer || object instanceof Short || object instanceof Byte || object instanceof AtomicInteger) { ...
java
{ "resource": "" }
q165988
MapReduceCommand.toDBObject
validation
public DBObject toDBObject() { BasicDBObject cmd = new BasicDBObject(); cmd.put("mapreduce", mapReduce); cmd.put("map", map); cmd.put("reduce", reduce); if (verbose != null) { cmd.put("verbose", verbose); } BasicDBObject out = new BasicDBObject(); ...
java
{ "resource": "" }
q165989
ClusterSettings.getShortDescription
validation
public String getShortDescription() { return "{" + (hosts.isEmpty() ? "" : "hosts=" + hosts) + (srvHost == null ? "" : ", srvHost=" + srvHost) + ", mode=" + mode + ", requiredClusterType=" + requiredClusterType + ", serverSelectionTime...
java
{ "resource": "" }
q165990
UpdateResult.acknowledged
validation
public static UpdateResult acknowledged(final long matchedCount, @Nullable final Long modifiedCount, @Nullable final BsonValue upsertedId) { return new AcknowledgedUpdateResult(matchedCount, modifiedCount, upsertedId); }
java
{ "resource": "" }
q165991
GridFSFile.getContentType
validation
@Deprecated public String getContentType() { if (extraElements != null && extraElements.containsKey("contentType")) { return extraElements.getString("contentType"); } else { throw new MongoGridFSException("No contentType data for this GridFS file"); } }
java
{ "resource": "" }
q165992
GridFSFile.getAliases
validation
@Deprecated @SuppressWarnings("unchecked") public List<String> getAliases() { if (extraElements != null && extraElements.containsKey("aliases")) { return (List<String>) extraElements.get("aliases"); } else { throw new MongoGridFSException("No aliases data for this GridFS ...
java
{ "resource": "" }
q165993
AbstractByteBufBsonDocument.getFirstKey
validation
public String getFirstKey() { return findInDocument(new Finder<String>() { @Override public String find(final BsonReader bsonReader) { return bsonReader.readName(); } @Override public String notFound() { throw new NoSuc...
java
{ "resource": "" }
q165994
EncoderContext.encodeWithChildContext
validation
public <T> void encodeWithChildContext(final Encoder<T> encoder, final BsonWriter writer, final T value) { encoder.encode(writer, value, DEFAULT_CONTEXT); }
java
{ "resource": "" }
q165995
ReadConcern.asDocument
validation
public BsonDocument asDocument() { BsonDocument readConcern = new BsonDocument(); if (level != null) { readConcern.put("level", new BsonString(level.getValue())); } return readConcern; }
java
{ "resource": "" }
q165996
SnappyCompressor.compress
validation
@Override public void compress(final List<ByteBuf> source, final BsonOutput target) { int uncompressedSize = getUncompressedSize(source); byte[] singleByteArraySource = new byte[uncompressedSize]; copy(source, singleByteArraySource); try { byte[] out = new byte[Snappy.m...
java
{ "resource": "" }
q165997
BasicBSONObject.getString
validation
public String getString(final String key) { Object foo = get(key); if (foo == null) { return null; } return foo.toString(); }
java
{ "resource": "" }
q165998
BasicBSONObject.getBoolean
validation
public boolean getBoolean(final String key, final boolean def) { Object foo = get(key); if (foo == null) { return def; } if (foo instanceof Number) { return ((Number) foo).intValue() > 0; } if (foo instanceof Boolean) { return (Boolean)...
java
{ "resource": "" }
q165999
BasicBSONObject.getObjectId
validation
public ObjectId getObjectId(final String field, final ObjectId def) { Object foo = get(field); return (foo != null) ? (ObjectId) foo : def; }
java
{ "resource": "" }