private static GifCommentDirectory readCommentBlock(SequentialReader reader, int blockSizeBytes) throws IOException { byte[] buffer = gatherBytes(reader, blockSizeBytes); return new GifCommentDirectory(new StringValue(buffer, Charsets.ASCII)); }
/** * Creates a String from the stream, ending where <code>byte=='\0'</code> or where <code>length==maxLength</code>. * * @param maxLengthBytes The maximum number of bytes to read. If a <code>\0</code> byte is not reached within this limit, * reading will stop and the string will be truncated to this length. * @param charset The <code>Charset</code> to register with the returned <code>StringValue</code>, or <code>null</code> if the encoding * is unknown * @return The read string. * @throws IOException The buffer does not contain enough bytes to satisfy this request. */ @NotNull public StringValue getNullTerminatedStringValue(int maxLengthBytes, Charset charset) throws IOException { byte[] bytes = getNullTerminatedBytes(maxLengthBytes); return new StringValue(bytes, charset); }
@NotNull public StringValue getStringValue(int bytesRequested, @Nullable Charset charset) throws IOException { return new StringValue(getBytes(bytesRequested), charset); }
@NotNull public StringValue getNullTerminatedStringValue(int index, int maxLengthBytes, @Nullable Charset charset) throws IOException { byte[] bytes = getNullTerminatedBytes(index, maxLengthBytes); return new StringValue(bytes, charset); }
@NotNull public StringValue getStringValue(int index, int bytesRequested, @Nullable Charset charset) throws IOException { return new StringValue(getBytes(index, bytesRequested), charset); }
public void readJpegSegments(@NotNull Iterable<byte[]> segments, @NotNull Metadata metadata, @NotNull JpegSegmentType segmentType) { for (byte[] segmentBytes : segments) { JpegCommentDirectory directory = new JpegCommentDirectory(); metadata.addDirectory(directory); // The entire contents of the directory are the comment directory.setStringValue(JpegCommentDirectory.TAG_COMMENT, new StringValue(segmentBytes, null)); } } }
byte[] bytes = reader.getBytes(tagByteCount); Charset charSet = Iso2022Converter.guessCharSet(bytes); string = charSet != null ? new StringValue(bytes, charSet) : new StringValue(bytes, null);
directory.setInt(ReconyxHyperFireMakernoteDirectory.TAG_AMBIENT_TEMPERATURE, reader.getInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_AMBIENT_TEMPERATURE)); directory.setStringValue(ReconyxHyperFireMakernoteDirectory.TAG_SERIAL_NUMBER, new StringValue(reader.getBytes(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_SERIAL_NUMBER, 28), Charsets.UTF_16LE));
directory.setStringValue(PngDirectory.TAG_ICC_PROFILE_NAME, new StringValue(profileNameBytes, _latin1Encoding)); byte compressionMethod = reader.getInt8(); } else { List<KeyValuePair> textPairs = new ArrayList<KeyValuePair>(); textPairs.add(new KeyValuePair(keyword, new StringValue(textBytes, _latin1Encoding))); PngDirectory directory = new PngDirectory(PngChunkType.zTXt); directory.setObject(PngDirectory.TAG_TEXTUAL_DATA, textPairs); } else { List<KeyValuePair> textPairs = new ArrayList<KeyValuePair>(); textPairs.add(new KeyValuePair(keyword, new StringValue(textBytes, _latin1Encoding))); PngDirectory directory = new PngDirectory(PngChunkType.iTXt); directory.setObject(PngDirectory.TAG_TEXTUAL_DATA, textPairs);
directory.setStringValue(ReconyxUltraFireMakernoteDirectory.TAG_SERIAL_NUMBER, new StringValue(reader.getBytes(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TAG_SERIAL_NUMBER, 14), Charsets.UTF_8));
private static GifCommentDirectory readCommentBlock(SequentialReader reader, int blockSizeBytes) throws IOException { byte[] buffer = gatherBytes(reader, blockSizeBytes); return new GifCommentDirectory(new StringValue(buffer, Charsets.ASCII)); }
/** * Creates a String from the stream, ending where <code>byte=='\0'</code> or where <code>length==maxLength</code>. * * @param maxLengthBytes The maximum number of bytes to read. If a <code>\0</code> byte is not reached within this limit, * reading will stop and the string will be truncated to this length. * @param charset The <code>Charset</code> to register with the returned <code>StringValue</code>, or <code>null</code> if the encoding * is unknown * @return The read string. * @throws IOException The buffer does not contain enough bytes to satisfy this request. */ @NotNull public StringValue getNullTerminatedStringValue(int maxLengthBytes, Charset charset) throws IOException { byte[] bytes = getNullTerminatedBytes(maxLengthBytes); return new StringValue(bytes, charset); }
@NotNull public StringValue getStringValue(int index, int bytesRequested, @Nullable Charset charset) throws IOException { return new StringValue(getBytes(index, bytesRequested), charset); }
@NotNull public StringValue getStringValue(int bytesRequested, @Nullable Charset charset) throws IOException { return new StringValue(getBytes(bytesRequested), charset); }
@NotNull public StringValue getNullTerminatedStringValue(int index, int maxLengthBytes, @Nullable Charset charset) throws IOException { byte[] bytes = getNullTerminatedBytes(index, maxLengthBytes); return new StringValue(bytes, charset); }
public void readJpegSegments(@NotNull Iterable<byte[]> segments, @NotNull Metadata metadata, @NotNull JpegSegmentType segmentType) { for (byte[] segmentBytes : segments) { JpegCommentDirectory directory = new JpegCommentDirectory(); metadata.addDirectory(directory); // The entire contents of the directory are the comment directory.setStringValue(JpegCommentDirectory.TAG_COMMENT, new StringValue(segmentBytes, null)); } } }
byte[] bytes = reader.getBytes(tagByteCount); Charset charSet = Iso2022Converter.guessCharSet(bytes); string = charSet != null ? new StringValue(bytes, charSet) : new StringValue(bytes, null);
directory.setInt(ReconyxHyperFireMakernoteDirectory.TAG_AMBIENT_TEMPERATURE, reader.getInt16(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_AMBIENT_TEMPERATURE)); directory.setStringValue(ReconyxHyperFireMakernoteDirectory.TAG_SERIAL_NUMBER, new StringValue(reader.getBytes(makernoteOffset + ReconyxHyperFireMakernoteDirectory.TAG_SERIAL_NUMBER, 28), Charsets.UTF_16LE));
directory.setStringValue(PngDirectory.TAG_ICC_PROFILE_NAME, new StringValue(profileNameBytes, _latin1Encoding)); byte compressionMethod = reader.getInt8(); } else { List<KeyValuePair> textPairs = new ArrayList<KeyValuePair>(); textPairs.add(new KeyValuePair(keyword, new StringValue(textBytes, _latin1Encoding))); PngDirectory directory = new PngDirectory(PngChunkType.zTXt); directory.setObject(PngDirectory.TAG_TEXTUAL_DATA, textPairs); } else { List<KeyValuePair> textPairs = new ArrayList<KeyValuePair>(); textPairs.add(new KeyValuePair(keyword, new StringValue(textBytes, _latin1Encoding))); PngDirectory directory = new PngDirectory(PngChunkType.iTXt); directory.setObject(PngDirectory.TAG_TEXTUAL_DATA, textPairs);
directory.setStringValue(ReconyxUltraFireMakernoteDirectory.TAG_SERIAL_NUMBER, new StringValue(reader.getBytes(makernoteOffset + ReconyxUltraFireMakernoteDirectory.TAG_SERIAL_NUMBER, 14), Charsets.UTF_8));