Skip to content

Commit 9a3b53b

Browse files
committed
[Java-475] GridFSInput constructors are now protected access
Additionally added GridFSInput.createChunk() method
1 parent 502b7fb commit 9a3b53b

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/main/com/mongodb/gridfs/GridFSInputFile.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class GridFSInputFile extends GridFSFile {
5656
* @param closeStreamOnPersist
5757
indicate the passed in input stream should be closed once the data chunk persisted
5858
*/
59-
GridFSInputFile( GridFS fs , InputStream in , String filename, boolean closeStreamOnPersist ) {
59+
protected GridFSInputFile( GridFS fs , InputStream in , String filename, boolean closeStreamOnPersist ) {
6060
_fs = fs;
6161
_in = in;
6262
_filename = filename;
@@ -81,7 +81,7 @@ public class GridFSInputFile extends GridFSFile {
8181
* @param filename
8282
* Name of the file to be created.
8383
*/
84-
GridFSInputFile( GridFS fs , InputStream in , String filename ) {
84+
protected GridFSInputFile( GridFS fs , InputStream in , String filename ) {
8585
this( fs, in, filename, false);
8686
}
8787

@@ -96,7 +96,7 @@ public class GridFSInputFile extends GridFSFile {
9696
* @param filename
9797
* Name of the file to be created.
9898
*/
99-
GridFSInputFile( GridFS fs , String filename ) {
99+
protected GridFSInputFile( GridFS fs , String filename ) {
100100
this( fs , null , filename );
101101
}
102102

@@ -108,7 +108,7 @@ public class GridFSInputFile extends GridFSFile {
108108
* @param fs
109109
* The GridFS connection handle.
110110
*/
111-
GridFSInputFile( GridFS fs ) {
111+
protected GridFSInputFile( GridFS fs ) {
112112
this( fs , null , null );
113113
}
114114

@@ -271,10 +271,7 @@ private void _dumpBuffer( boolean writePartial ) {
271271
System.arraycopy( _buffer, 0, writeBuffer, 0, _currentBufferPosition );
272272
}
273273

274-
DBObject chunk = BasicDBObjectBuilder.start()
275-
.add( "files_id", _id )
276-
.add( "n", _currentChunkNumber )
277-
.add( "data", writeBuffer ).get();
274+
DBObject chunk = createChunk(_id, _currentChunkNumber, writeBuffer);
278275

279276
_fs._chunkCollection.save( chunk );
280277

@@ -283,6 +280,13 @@ private void _dumpBuffer( boolean writePartial ) {
283280
_messageDigester.update( writeBuffer );
284281
_currentBufferPosition = 0;
285282
}
283+
284+
protected DBObject createChunk(Object id, int currentChunkNumber, byte[] writeBuffer) {
285+
return BasicDBObjectBuilder.start()
286+
.add("files_id", id)
287+
.add("n", currentChunkNumber)
288+
.add("data", writeBuffer).get();
289+
}
286290

287291
/**
288292
* Reads a buffer full from the {@link java.io.InputStream}.

0 commit comments

Comments
 (0)