java.lang.Object
me.hugmanrique.cartage.AbstractCartridge
- All Implemented Interfaces:
AutoCloseable,Cartridge
Skeleton
Cartridge implementation.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractCartridge(MemorySegment segment)protectedAbstractCartridge(MemorySegment segment, ByteOrder order) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the cartridge.voidcopyFrom(MemorySegment source)Copies the contents from the given segment to this cartridge.voidcopyTo(OutputStream stream)Copies the cartridge contents to the given stream.voidCopies the cartridge contents to the given path.voidcopyTo(MemorySegment dest)Copies the cartridge contents to the given segment.getAscii(long offset, int length)bytegetByte(long offset)voidgetBytes(long offset, byte[] dest)voidgetBytes(long offset, byte[] destArray, int destOffset, int length)intgetInt(long offset)longgetLong(long offset)shortgetShort(long offset)intgetUnsignedByte(long offset)longgetUnsignedInt(long offset)intgetUnsignedShort(long offset)getUtf8(long offset, int length)booleanReturns whether there exist any bytes between the current offset and the end of the cartridge.longoffset()Returns the cartridge's offset.order()Returns the cartridge's byte order.voidSets the cartridge's byte order.readAscii(int length)bytereadByte()voidreadBytes(byte[] dest)voidreadBytes(byte[] destArray, int destOffset, int length)intreadInt()longreadLong()shortreadString(int length, Charset charset)intlongintreadUtf8(int length)longReturns the number of bytes between the current offset and the end of the cartridge.intsetAscii(long offset, CharSequence sequence)voidsetByte(long offset, byte value)voidsetBytes(long offset, byte[] source)voidsetBytes(long offset, byte[] sourceArray, int sourceOffset, int length)voidsetInt(long offset, int value)voidsetLong(long offset, long value)voidsetOffset(long offset)Sets the cartridge's offset.voidsetShort(long offset, short value)intsetString(long offset, CharSequence sequence, Charset charset)voidsetUnsignedByte(long offset, int value)voidsetUnsignedInt(long offset, long value)voidsetUnsignedShort(long offset, int value)intsetUtf8(long offset, CharSequence sequence)longsize()Returns the size of the cartridge.voidskip(long count)Increases the cartridge's offset.toString()intwriteAscii(CharSequence sequence)voidwriteByte(byte value)voidwriteBytes(byte[] source)voidwriteBytes(byte[] source, int sourceOffset, int length)voidwriteInt(int value)voidwriteLong(long value)voidwriteShort(short value)intwriteString(CharSequence sequence, Charset charset)voidwriteUnsignedByte(int value)voidwriteUnsignedInt(long value)voidwriteUnsignedShort(int value)intwriteUtf8(CharSequence sequence)
-
Constructor Details
-
AbstractCartridge
-
AbstractCartridge
-
-
Method Details
-
order
Description copied from interface:CartridgeReturns the cartridge's byte order. -
order
Description copied from interface:CartridgeSets the cartridge's byte order. -
offset
public long offset()Description copied from interface:CartridgeReturns the cartridge's offset. -
setOffset
public void setOffset(long offset)Description copied from interface:CartridgeSets the cartridge's offset. -
size
public long size()Description copied from interface:CartridgeReturns the size of the cartridge. -
remaining
public long remaining()Description copied from interface:CartridgeReturns the number of bytes between the current offset and the end of the cartridge. -
hasRemaining
public boolean hasRemaining()Description copied from interface:CartridgeReturns whether there exist any bytes between the current offset and the end of the cartridge.- Specified by:
hasRemainingin interfaceCartridge- Returns:
trueif and only ifCartridge.remaining()equals 0
-
skip
public void skip(long count)Description copied from interface:CartridgeIncreases the cartridge's offset. -
close
public void close()Description copied from interface:CartridgeCloses the cartridge. Once closed, any subsequent operation on the cartridge will fail withIllegalStateException.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCartridge
-
readByte
public byte readByte() -
getByte
public byte getByte(long offset) -
readUnsignedByte
public int readUnsignedByte() -
getUnsignedByte
public int getUnsignedByte(long offset) -
writeByte
public void writeByte(byte value) -
setByte
public void setByte(long offset, byte value) -
writeUnsignedByte
public void writeUnsignedByte(int value) -
setUnsignedByte
public void setUnsignedByte(long offset, int value) -
readShort
public short readShort() -
getShort
public short getShort(long offset) -
readUnsignedShort
public int readUnsignedShort() -
getUnsignedShort
public int getUnsignedShort(long offset) -
writeShort
public void writeShort(short value) -
setShort
public void setShort(long offset, short value) -
writeUnsignedShort
public void writeUnsignedShort(int value) -
setUnsignedShort
public void setUnsignedShort(long offset, int value) -
readInt
public int readInt() -
getInt
public int getInt(long offset) -
readUnsignedInt
public long readUnsignedInt() -
getUnsignedInt
public long getUnsignedInt(long offset) -
writeInt
public void writeInt(int value) -
setInt
public void setInt(long offset, int value) -
writeUnsignedInt
public void writeUnsignedInt(long value) -
setUnsignedInt
public void setUnsignedInt(long offset, long value) -
readLong
public long readLong() -
getLong
public long getLong(long offset) -
writeLong
public void writeLong(long value) -
setLong
public void setLong(long offset, long value) -
readBytes
public void readBytes(byte[] dest) -
readBytes
public void readBytes(byte[] destArray, int destOffset, int length) -
getBytes
public void getBytes(long offset, byte[] dest) -
getBytes
public void getBytes(long offset, byte[] destArray, int destOffset, int length) -
writeBytes
public void writeBytes(byte[] source) -
writeBytes
public void writeBytes(byte[] source, int sourceOffset, int length) -
setBytes
public void setBytes(long offset, byte[] source) -
setBytes
public void setBytes(long offset, byte[] sourceArray, int sourceOffset, int length) -
readString
-
getString
-
readAscii
-
getAscii
-
readUtf8
-
getUtf8
-
writeString
-
setString
-
writeAscii
-
setAscii
-
writeUtf8
-
setUtf8
-
copyFrom
Description copied from interface:CartridgeCopies the contents from the given segment to this cartridge. More specifically, the bytes at offset0throughcartridge.size() - 1in the source segment are copied into this cartridge at offset0throughcartridge.size() - 1. -
copyTo
Description copied from interface:CartridgeCopies the cartridge contents to the given segment. More specifically, the bytes at offset0throughdest.byteSize() - 1in the cartridge are copied into the given segment at offset0throughdest.byteSize() - 1. -
copyTo
Description copied from interface:CartridgeCopies the cartridge contents to the given path.- Specified by:
copyToin interfaceCartridge- Parameters:
path- the destination path- Throws:
IOException- if an I/O error occurs
-
copyTo
Description copied from interface:CartridgeCopies the cartridge contents to the given stream. The stream is not closed.- Specified by:
copyToin interfaceCartridge- Parameters:
stream- the output stream- Throws:
IOException- if an I/O error occurs
-
toString
-