private int parseCount0(@NotNull String name) { try { TemporalAccessor parse = formatter.parse(name); long epochDay = parse.getLong(ChronoField.EPOCH_DAY) * 86400; if (parse.isSupported(ChronoField.SECOND_OF_DAY)) epochDay += parse.getLong(ChronoField.SECOND_OF_DAY); return Maths.toInt32((epochDay - ((epoch) / 1000)) / (length / 1000)); } catch (DateTimeParseException e) { throw new RuntimeException(String.format( "Unable to parse %s using format %s", name, format), e); } }
public static <ACS extends Appendable & CharSequence> void append(ACS a, CharSequence cs, long start, long len) { if (a instanceof StringBuilder) { if (cs instanceof Bytes) ((StringBuilder) a).append(Bytes.toString(((Bytes) cs), start, len)); else ((StringBuilder) a).append(cs.subSequence(Maths.toInt32(start), Maths.toInt32(len))); } else if (a instanceof Bytes) { ((Bytes) a).appendUtf8(cs, Maths.toInt32(start), Maths.toInt32(len)); } else { throw new UnsupportedOperationException(); } }
@Override protected void setValue(Object o, BytesIn read) throws IllegalAccessException { Collection c = (Collection) field.get(o); int length = Maths.toInt32(read.readStopBit()); if (length < 0) { if (c != null) field.set(o, null); return; } c.clear(); for (int i = 0; i < length; i++) c.add(read.readObject(componentType)); } }
private int parseCount0(@NotNull String name) { try { TemporalAccessor parse = formatter.parse(name); long epochDay = parse.getLong(ChronoField.EPOCH_DAY) * 86400; if (parse.isSupported(ChronoField.SECOND_OF_DAY)) epochDay += parse.getLong(ChronoField.SECOND_OF_DAY); return Maths.toInt32((epochDay - ((epoch) / 1000)) / (length / 1000)); } catch (DateTimeParseException e) { throw new RuntimeException(String.format( "Unable to parse %s using format %s", name, format), e); } }
@Override public long applyAsLong(@NotNull BytesStore store) { final int remaining = Maths.toInt32(store.readRemaining()); return applyAsLong(store, remaining); }
@Override public long applyAsLong(@NotNull BytesStore store) { int remaining = Maths.toInt32(store.readRemaining()); return applyAsLong(store, remaining); }
/** * parse text as an int. The terminating character is consumed. * * @return an int. */ @ForceInline default int parseInt() throws BufferUnderflowException { return Maths.toInt32(BytesInternal.parseLong(this)); }
@NotNull @Override public BytesStore<Bytes<Underlying>, Underlying> copy() { if (bytesStore.underlyingObject() instanceof ByteBuffer) { try { ByteBuffer bb = ByteBuffer.allocateDirect(Maths.toInt32(readRemaining())); @NotNull ByteBuffer bbu = (ByteBuffer) bytesStore.underlyingObject(); ByteBuffer slice = bbu.slice(); slice.position((int) readPosition()); slice.limit((int) readLimit()); bb.put(slice); bb.clear(); return (BytesStore) BytesStore.wrap(bb); } catch (IllegalArgumentException e) { throw new AssertionError(e); } } else { return (BytesStore) NativeBytes.copyOf(this); } }
@NotNull @Override public BytesStore<NativeBytesStore<Underlying>, Underlying> copy() { try { if (underlyingObject == null) { @NotNull NativeBytesStore<Void> copy = of(realCapacity(), false, true); memory.copyMemory(address, copy.address, capacity()); return (BytesStore) copy; } else if (underlyingObject instanceof ByteBuffer) { ByteBuffer bb = ByteBuffer.allocateDirect(Maths.toInt32(capacity())); bb.put((ByteBuffer) underlyingObject); bb.clear(); return (BytesStore) wrap(bb); } else { throw new UnsupportedOperationException(); } } catch (IllegalArgumentException e) { throw new AssertionError(e); } }
public static String to8bitString(@org.jetbrains.annotations.NotNull @NotNull BytesStore bytes) throws IllegalArgumentException { long pos = bytes.readPosition(); int len = Maths.toInt32(bytes.readRemaining()); @org.jetbrains.annotations.NotNull char[] chars = new char[len]; if (bytes instanceof VanillaBytes) { ((VanillaBytes) bytes).read8Bit(chars, len); } else { for (int i = 0; i < len; i++) try { chars[i] = (char) bytes.readUnsignedByte(pos + i); } catch (Exception e) { return new String(chars, 0, len) + ' ' + e; } } return StringUtils.newString(chars); }
private static void readUtf81(@org.jetbrains.annotations.NotNull @NotNull StreamingDataInput bytes, @org.jetbrains.annotations.NotNull @NotNull Appendable appendable, @org.jetbrains.annotations.NotNull @NotNull StopCharTester tester) throws IOException, BufferUnderflowException { int len = Maths.toInt32(bytes.readRemaining()); while (len-- > 0) { int c = bytes.readUnsignedByte(); if (c >= 128) { bytes.readSkip(-1); break; } if (tester.isStopChar(c)) return; appendable.append((char) c); } if (len <= 0) return; readUtf82(bytes, appendable, tester); }
if (isByteBufferBacked && size <= MAX_BYTE_BUFFER_CAPACITY) { position = ((ByteBuffer) bytesStore.underlyingObject()).position(); store = allocateNewByteBufferBackedStore(Maths.toInt32(size)); } else { store = NativeBytesStore.lazyNativeBytesStoreWithFixedCapacity(size);
throws IOException, BufferUnderflowException { @org.jetbrains.annotations.Nullable NativeBytesStore nb = (NativeBytesStore) bytes.bytesStore(); int i = 0, len = Maths.toInt32(bytes.readRemaining()); long address = nb.address + nb.translate(bytes.readPosition()); @org.jetbrains.annotations.Nullable Memory memory = nb.memory;