Package org.lilyproject.bytes.api

Examples of org.lilyproject.bytes.api.DataOutput


        }
        return string;
    }

    private byte[] idToBytes(UUID uuid) {
        DataOutput dataOutput = new DataOutputImpl(16);
        dataOutput.writeLong(uuid.getMostSignificantBits());
        dataOutput.writeLong(uuid.getLeastSignificantBits());
        return dataOutput.toByteArray();
    }
View Full Code Here


        assertTrue(link.copyAll());
        assertEquals(recordId, link.getMasterRecordId());

        assertEquals("USER.123", link.toString());
        assertEquals(link, Link.fromString(link.toString(), idGenerator));
        DataOutput dataOutput = new DataOutputImpl();
        link.write(dataOutput);
        assertEquals(link, Link.read(new DataInputImpl(dataOutput.toByteArray()), idGenerator));

        RecordId ctx = idGenerator.newRecordId("0");
        RecordId resolved = link.resolve(ctx, idGenerator);
        assertEquals(recordId, resolved);
View Full Code Here

        Link link = Link.newBuilder().recordId(recordId).copyAll(false).create();
        assertEquals(masterRecordId, link.getMasterRecordId());
        assertEquals("USER.123.!*,branch=dev,lang=en", link.toString());
        assertEquals(link, Link.fromString(link.toString(), idGenerator));
        DataOutput dataOutput = new DataOutputImpl();
        link.write(dataOutput);
        assertEquals(link, Link.read(new DataInputImpl(dataOutput.toByteArray()), idGenerator));


        assertEquals(2, link.getVariantProps().size());
        assertEquals(Link.PropertyMode.SET, link.getVariantProps().get("lang").getMode());
        assertEquals("en", link.getVariantProps().get("lang").getValue());
View Full Code Here

        RecordId recordId = idGenerator.newRecordId("123");

        Link link = Link.newBuilder().recordId(recordId).remove("lang").set("x", "1").create();
        assertEquals("USER.123.-lang,x=1", link.toString());
        assertEquals(link, Link.fromString(link.toString(), idGenerator));
        DataOutput dataOutput = new DataOutputImpl();
        link.write(dataOutput);
        assertEquals(link, Link.read(new DataInputImpl(dataOutput.toByteArray()), idGenerator));


        Map<String, String> ctxVarProps = new HashMap<String, String>();
        ctxVarProps.put("lang", "en");
        ctxVarProps.put("branch", "dev");
View Full Code Here

        RecordId recordId = idGenerator.newRecordId("123");

        Link link = Link.newBuilder().recordId(recordId).copyAll(false).copy("branch").set("x", "1").create();
        assertEquals("USER.123.!*,+branch,x=1", link.toString());
        assertEquals(link, Link.fromString(link.toString(), idGenerator));
        DataOutput dataOutput = new DataOutputImpl();
        link.write(dataOutput);
        assertEquals(link, Link.read(new DataInputImpl(dataOutput.toByteArray()), idGenerator));


        Map<String, String> ctxVarProps = new HashMap<String, String>();
        ctxVarProps.put("lang", "en");
        ctxVarProps.put("branch", "dev");
View Full Code Here

    public void testLinkToSelf() {
        Link link = Link.newBuilder().create();
        assertNull(link.getMasterRecordId());
        assertEquals(".", link.toString());
        assertEquals(link, Link.fromString(link.toString(), idGenerator));
        DataOutput dataOutput = new DataOutputImpl();
        link.write(dataOutput);
        assertEquals(link, Link.read(new DataInputImpl(dataOutput.toByteArray()), idGenerator));


        Map<String, String> varProps = new HashMap<String, String>();
        varProps.put("lang", "en");
        varProps.put("branch", "dev");
View Full Code Here

    public void testLinkToMaster() {
        Link link = Link.newBuilder().copyAll(false).create();
        assertNull(link.getMasterRecordId());
        assertEquals(".!*", link.toString());
        assertEquals(link, Link.fromString(link.toString(), idGenerator));
        DataOutput dataOutput = new DataOutputImpl();
        link.write(dataOutput);
        assertEquals(link, Link.read(new DataInputImpl(dataOutput.toByteArray()), idGenerator));


        Map<String, String> varProps = new HashMap<String, String>();
        varProps.put("lang", "en");
        varProps.put("branch", "dev");
View Full Code Here

    }

    @Override
    public byte[] toBytes() {
        if (recordIdBytes == null) {
            DataOutput dataOutput = new DataOutputImpl();
            writeBytes(dataOutput);
            recordIdBytes = dataOutput.toByteArray();
        }
        return recordIdBytes;
    }
View Full Code Here

                .recordType(new QName(ns, "rt2"))
                .field(new QName(ns,"field1"), "def")
                .create();


        DataOutput dataOutput = new DataOutputImpl();

        // Do a write and lets not get exceptions
        recordVT.write(createdRecord, dataOutput, new IdentityRecordStack());

        DataInput dataInput = new DataInputImpl(dataOutput.toByteArray());

        // Do a read and lets not get exceptions
        Record readRecord = recordVT.read(dataInput);

        assertEquals(createdRecord.getFields(), readRecord.getFields());
View Full Code Here

            byte[] bytes = ((RecordRvtImpl)value).getBytes();
            if (bytes != null) {
                return bytes;
            }
        }
        DataOutput dataOutput = new DataOutputImpl();
        encodeData(value, dataOutput, parentRecords);
        return dataOutput.toByteArray();
    }
View Full Code Here

TOP

Related Classes of org.lilyproject.bytes.api.DataOutput

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.