Package org.lilyproject.bytes.impl

Examples of org.lilyproject.bytes.impl.DataInputImpl


            return new Link();
        }

        Link.LinkBuilder builder = Link.newBuilder();
        if (recordIdLength > 0) {
            RecordId id = decode(new DataInputImpl(recordIdBytes), idGenerator);
            builder.recordId(id);
        }

        if (args != null && args.length() > 0) {
            argsFromString(args, builder, args /* does not matter, should never be invalid */);
 
View Full Code Here


        if (buffer == null) {
            return true;
        }

        final RecordId recordId = idGenerator.fromBytes(new DataInputImpl(buffer, offset, length));

        final SortedMap<String, String> recordVariantProperties = recordId.getVariantProperties();

        // check if the record has all expected variant properties
        if (containsAllExpectedDimensions(recordVariantProperties) &&
View Full Code Here

        return newAbsoluteRecordId(tableName, newRecordId(userProvided));
    }

    @Override
    public RecordId fromBytes(byte[] bytes) {
        return fromBytes(new DataInputImpl(bytes));
    }
View Full Code Here

    @Override
    public DataInput[] splitInMasterAndVariant(DataInput dataInput) {
        if (dataInput.getSize() - dataInput.getPosition() > UUID_LENGTH) {

            DataInput keyInput = new DataInputImpl(((DataInputImpl) dataInput), dataInput.getPosition(),
                    dataInput.getPosition() + 16);

            DataInput variantInput = new DataInputImpl(((DataInputImpl) dataInput), dataInput.getPosition() + 16,
                    dataInput.getSize() - 17);

            return new DataInput[]{keyInput, variantInput};
        } else {
            return new DataInput[]{dataInput, null};
View Full Code Here

        if (sepPos == -1) {
            return new DataInput[]{dataInput, null};
        } else {
            DataInput keyInput =
                    new DataInputImpl(((DataInputImpl) dataInput), dataInput.getPosition(), sepPos - dataInput.getPosition());
            DataInput variantInput =
                    new DataInputImpl(((DataInputImpl) dataInput), sepPos + 1, dataInput.getSize() - (sepPos + 1));

            return new DataInput[]{keyInput, variantInput};
        }
    }
View Full Code Here

    }

    public String toString() {
        if (string == null) {
            if (uuid == null) {
                DataInput dataInput = new DataInputImpl(bytes);
                this.uuid = new UUID(dataInput.readLong(), dataInput.readLong());
            }
            this.string = uuid.toString();
        }
        return string;
    }
View Full Code Here

        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

        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

        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

        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

TOP

Related Classes of org.lilyproject.bytes.impl.DataInputImpl

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.