Source

fantomongo / fan / ObjectID.fan

Diff from to

fan/ObjectID.fan

     this.machine = IpAddr.local.bytes.toDigest("MD5").readS4.and(0xFFFFFFFF)
   }
 
-  new makeAll(Int inc, Int time, Int machine)
+  new makeAll(Int time, Int machine, Int inc)
   { 
-    this.inc = inc
     this.time = time
     this.machine = machine
+    this.inc = inc
   }
   
   new fromStream(InStream ins)
   {
+    endian := ins.endian
+    ins.endian = Endian.big
     this.time = ins.readS4.and(0xFFFFFFFF)
     this.machine = ins.readS4.and(0xFFFFFFFF)
     this.inc = ins.readS4.and(0xFFFFFFFF)
+    ins.endian = endian
   }
   
   ** Parse ObjectID from according to the string format defined in mongodb documentation
         throw Err("invalid ObjectID format")
       return null
     }
-    return makeAll(s[16..23].toInt(16).and(0xFFFFFFFF),
-                   s[0..7].toInt(16).and(0xFFFFFFFF),
-                   s[8..15].toInt(16).and(0xFFFFFFFF))
+
+    return makeAll(s[0..7].toInt(16).and(0xFFFFFFFF),
+                   s[8..15].toInt(16).and(0xFFFFFFFF),
+                   s[16..23].toInt(16).and(0xFFFFFFFF))
   }
   
   override Str toStr()
   
   OutStream write(OutStream o)
   {
-    return o.writeI4(time).writeI4(machine).writeI4(inc)
+    endian := o.endian
+    o.endian = Endian.big
+    o = o.writeI4(time).writeI4(machine).writeI4(inc)
+    o.endian = endian
+    return o
   }
   
   static Bool isValid(Str s)