14
14
* @author antoine
15
15
*/
16
16
public class DBCallback extends BasicBSONCallback {
17
-
17
+
18
18
public static interface Factory {
19
19
public DBCallback create ( DBCollection collection );
20
20
}
21
21
22
22
static class DefaultFactory implements Factory {
23
+ @ Override
23
24
public DBCallback create ( DBCollection collection ){
24
25
return new DBCallback ( collection );
25
26
}
@@ -40,30 +41,30 @@ public void gotDBRef( String name , String ns , ObjectId id ){
40
41
else
41
42
cur ().put ( name , new DBPointer ( (DBObject )cur () , name , _db , ns , id ) );
42
43
}
43
-
44
+
44
45
@ Override
45
46
public void objectStart (boolean array , String name ){
46
47
_lastName = name ;
47
48
super .objectStart ( array , name );
48
49
}
49
-
50
+
50
51
@ Override
51
52
public Object objectDone (){
52
53
BSONObject o = (BSONObject )super .objectDone ();
53
- if ( ! ( o instanceof List ) &&
54
- o .containsField ( "$ref" ) &&
54
+ if ( ! ( o instanceof List ) &&
55
+ o .containsField ( "$ref" ) &&
55
56
o .containsField ( "$id" ) ){
56
57
return cur ().put ( _lastName , new DBRef ( _db , o ) );
57
58
}
58
-
59
+
59
60
return o ;
60
61
}
61
-
62
+
62
63
@ Override
63
64
public BSONObject create (){
64
65
return _create ( null );
65
66
}
66
-
67
+
67
68
@ Override
68
69
public BSONObject create ( boolean array , List <String > path ){
69
70
if ( array )
@@ -72,7 +73,7 @@ public BSONObject create( boolean array , List<String> path ){
72
73
}
73
74
74
75
private DBObject _create ( List <String > path ){
75
-
76
+
76
77
Class c = null ;
77
78
78
79
if ( _collection != null && _collection ._objectClass != null ){
@@ -88,9 +89,9 @@ private DBObject _create( List<String> path ){
88
89
}
89
90
c = _collection .getInternalClass ( buf .toString () );
90
91
}
91
-
92
+
92
93
}
93
-
94
+
94
95
if ( c != null ){
95
96
try {
96
97
return (DBObject )c .newInstance ();
@@ -104,7 +105,7 @@ private DBObject _create( List<String> path ){
104
105
throw new MongoInternalException ( "can't instantiate a : " + c , iae );
105
106
}
106
107
}
107
-
108
+
108
109
if ( _collection != null && _collection ._name .equals ( "$cmd" ) )
109
110
return new CommandResult ();
110
111
return new BasicDBObject ();
@@ -114,7 +115,7 @@ DBObject dbget(){
114
115
DBObject o = (DBObject )get ();
115
116
return o ;
116
117
}
117
-
118
+
118
119
@ Override
119
120
public void reset (){
120
121
_lastName = null ;
0 commit comments