Package org.infinispan.schematic.document

Examples of org.infinispan.schematic.document.ObjectId$Externalizer


        assertSame(expected, actual);
    }

    @Test
    public void shouldCorrectlyWriteObjectId() {
        ObjectId id = new ObjectId(300, 200, 9, 15);
        String expected = "{ \"$oid\" : \"0000012c0000c8000900000f\" }";
        String actual = writer.write(id);
        assertSame(expected, actual);
    }
View Full Code Here


    @Test
    public void shouldRoundTripSimpleBsonObjectWithObjectId() {
        // print = true;
        int time = Math.abs((int) new Date().getTime());
        if (print) System.out.println("time value: " + time);
        input = new BasicDocument("foo", new ObjectId(time, 1, 2, 3));
        assertRoundtrip(input);
    }
View Full Code Here

            value = "MaxKey";
        } else if (value instanceof Symbol) {
            Symbol symbol = (Symbol)value;
            value = new org.bson.types.Symbol(symbol.getSymbol());
        } else if (value instanceof ObjectId) {
            ObjectId id = (ObjectId)value;
            value = new org.bson.types.ObjectId(id.getBytes());
        } else if (value instanceof Timestamp) {
            Timestamp ts = (Timestamp)value;
            value = new BSONTimestamp(ts.getTime(), ts.getInc());
        } else if (value instanceof CodeWithScope) {
            CodeWithScope code = (CodeWithScope)value;
View Full Code Here

        } else if (value instanceof MaxKey) {
            value = JsonToken.VALUE_STRING;
        } else if (value instanceof Symbol) {
            value = new de.undercouch.bson4jackson.types.Symbol(((Symbol)value).getSymbol());
        } else if (value instanceof ObjectId) {
            ObjectId id = (ObjectId)value;
            value = new de.undercouch.bson4jackson.types.ObjectId(id.getTime(), id.getMachine(), id.getInc());
        } else if (value instanceof Timestamp) {
            Timestamp ts = (Timestamp)value;
            value = new de.undercouch.bson4jackson.types.Timestamp(ts.getTime(), ts.getInc());
        } else if (value instanceof CodeWithScope) {
            CodeWithScope code = (CodeWithScope)value;
View Full Code Here

        assert obj.equals(value);
    }

    @Test
    public void shouldParseDocumentWithObjectId() throws Exception {
        ObjectId obj = new ObjectId(300, 200, 9, 15);
        value = parser(writer.write(obj)).parseValue();
        assert obj.equals(value);
    }
View Full Code Here

      return BsonUtils.readObjectId(bytes);
   }

   @Override
   public ObjectId createObjectId(int time, int machine, int process, int inc) {
      return new ObjectId(time, machine, process, inc);
   }
View Full Code Here

               + ((bytes[3] & 0xff) << 0);
      int machine = ((bytes[4] & 0xff) << 16) + ((bytes[5] & 0xff) << 8) + ((bytes[6] & 0xff) << 0);
      int process = ((bytes[7] & 0xff) << 8) + ((bytes[8] & 0xff) << 0);
      int inc = ((bytes[9] & 0xff) << 16) + ((bytes[10] & 0xff) << 8) + ((bytes[11] & 0xff) << 0);
      // Create the value object ...
      return new ObjectId(time, machine, process, inc);
   }
View Full Code Here

TOP

Related Classes of org.infinispan.schematic.document.ObjectId$Externalizer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.