25
25
import org .bson .io .*;
26
26
27
27
class Response {
28
-
28
+
29
29
Response ( ServerAddress addr , DBCollection collection , InputStream in , BSONDecoder decoder )
30
30
throws IOException {
31
31
32
32
_host = addr ;
33
-
33
+
34
34
byte [] b = new byte [36 ];
35
35
Bits .readFully (in , b );
36
36
@@ -54,8 +54,8 @@ class Response {
54
54
else
55
55
_objects = new ArrayList <DBObject >( _num );
56
56
57
- DBCallback c = DBCallback . FACTORY . create ( collection );
58
-
57
+ DBCallback c = collection . getDB (). getMongo (). getMongoOptions (). dbCallbackFactory . create ( collection );
58
+
59
59
for ( int i =0 ; i <_num ; i ++ ){
60
60
if ( user ._toGo < 5 )
61
61
throw new IOException ( "should have more objects, but only " + user ._toGo + " bytes left" );
@@ -74,54 +74,54 @@ class Response {
74
74
public int size (){
75
75
return _num ;
76
76
}
77
-
77
+
78
78
public DBObject get ( int i ){
79
79
return _objects .get ( i );
80
80
}
81
81
82
82
public Iterator <DBObject > iterator (){
83
83
return _objects .iterator ();
84
84
}
85
-
85
+
86
86
public boolean hasGetMore ( int queryOptions ){
87
87
if ( _cursor == 0 )
88
88
return false ;
89
-
89
+
90
90
if ( _num > 0 )
91
91
return true ;
92
92
93
93
if ( ( queryOptions & Bytes .QUERYOPTION_TAILABLE ) == 0 )
94
94
return false ;
95
-
95
+
96
96
// have a tailable cursor
97
97
98
98
if ( ( _flags & Bytes .RESULTFLAG_AWAITCAPABLE ) > 0 && ( queryOptions & Bytes .QUERYOPTION_AWAITDATA ) > 0 )
99
99
return true ;
100
-
100
+
101
101
try {
102
102
Thread .sleep ( 500 );
103
103
}
104
104
catch ( Exception e ){}
105
-
105
+
106
106
return true ;
107
107
}
108
-
108
+
109
109
public long cursor (){
110
110
return _cursor ;
111
111
}
112
112
113
113
public ServerError getError (){
114
114
if ( _num != 1 )
115
115
return null ;
116
-
116
+
117
117
DBObject obj = get (0 );
118
-
118
+
119
119
if ( ServerError .getMsg ( obj , null ) == null )
120
120
return null ;
121
-
121
+
122
122
return new ServerError ( obj );
123
123
}
124
-
124
+
125
125
static class MyInputStream extends InputStream {
126
126
MyInputStream ( InputStream in , int max ){
127
127
_in = in ;
@@ -138,10 +138,10 @@ public int read()
138
138
139
139
if ( _toGo <= 0 )
140
140
return -1 ;
141
-
141
+
142
142
int val = _in .read ();
143
143
_toGo --;
144
-
144
+
145
145
return val ;
146
146
}
147
147
@@ -174,12 +174,12 @@ public String toString(){
174
174
final int _id ;
175
175
final int _responseTo ;
176
176
final int _operation ;
177
-
177
+
178
178
final int _flags ;
179
179
long _cursor ;
180
180
final int _startingFrom ;
181
181
final int _num ;
182
-
182
+
183
183
final List <DBObject > _objects ;
184
184
185
185
0 commit comments