@Override public String toString() { return toString(_charset); }
private static GifCommentDirectory readCommentBlock(SequentialReader reader, int blockSizeBytes) throws IOException { byte[] buffer = gatherBytes(reader, blockSizeBytes); return new GifCommentDirectory(new StringValue(buffer, Charsets.ASCII)); }
/** * Performs the XMP data extraction, adding found values to the specified instance of {@link Metadata}. * <p> * The extraction is done with Adobe's XMPCore library. */ public void extract(@NotNull final StringValue xmpString, @NotNull Metadata metadata) { extract(xmpString.getBytes(), metadata, null); }
directory.setStringValue(PngDirectory.TAG_ICC_PROFILE_NAME, new StringValue(profileNameBytes, _latin1Encoding)); byte compressionMethod = reader.getInt8(); String keyword = keywordsv.toString(); int bytesLeft = bytes.length - (keywordsv.getBytes().length + 1); StringValue value = reader.getNullTerminatedStringValue(bytesLeft, _latin1Encoding); List<KeyValuePair> textPairs = new ArrayList<KeyValuePair>(); String keyword = keywordsv.toString(); byte compressionMethod = reader.getInt8(); int bytesLeft = bytes.length - (keywordsv.getBytes().length + 1 + 1); byte[] textBytes = null; if (compressionMethod == 0) { } 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); String keyword = keywordsv.toString(); byte compressionFlag = reader.getInt8(); byte compressionMethod = reader.getInt8(); int bytesLeft = bytes.length - (keywordsv.getBytes().length + 1 + 1 + 1 + languageTagBytes.length + 1 + translatedKeywordBytes.length + 1); byte[] textBytes = null; if (compressionFlag == 0) {
directory.setStringValue(PngDirectory.TAG_ICC_PROFILE_NAME, new StringValue(profileNameBytes, _latin1Encoding)); byte compressionMethod = reader.getInt8(); String keyword = keywordsv.toString(); int bytesLeft = bytes.length - (keywordsv.getBytes().length + 1); StringValue value = reader.getNullTerminatedStringValue(bytesLeft, _latin1Encoding); List<KeyValuePair> textPairs = new ArrayList<KeyValuePair>(); String keyword = keywordsv.toString(); byte compressionMethod = reader.getInt8(); int bytesLeft = bytes.length - (keywordsv.getBytes().length + 1 + 1); byte[] textBytes = null; if (compressionMethod == 0) { } 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); String keyword = keywordsv.toString(); byte compressionFlag = reader.getInt8(); byte compressionMethod = reader.getInt8(); int bytesLeft = bytes.length - (keywordsv.getBytes().length + 1 + 1 + 1 + languageTagBytes.length + 1 + translatedKeywordBytes.length + 1); byte[] textBytes = null; if (compressionFlag == 0) {
/** * 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 zero-byte is not reached within this limit, * reading will stop and the string will be truncated to this length. * @return The read string. * @throws IOException The buffer does not contain enough bytes to satisfy this request. */ @NotNull public String getNullTerminatedString(int maxLengthBytes, Charset charset) throws IOException { return getNullTerminatedStringValue(maxLengthBytes, charset).toString(); }
/** * 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); }
return null; } else if (o instanceof StringValue) { return ((StringValue)o).getBytes(); } else if (o instanceof Rational[]) { Rational[] rationals = (Rational[])o;
String[] strings = new String[stringValues.length]; for (int i = 0; i < strings.length; i++) strings[i] = stringValues[i].toString(); return strings;
@NotNull public StringValue getStringValue(int bytesRequested, @Nullable Charset charset) throws IOException { return new StringValue(getBytes(bytesRequested), charset); }
/** * Performs the XMP data extraction, adding found values to the specified instance of {@link Metadata}. * <p> * The extraction is done with Adobe's XMPCore library. */ public void extract(@NotNull final StringValue xmpString, @NotNull Metadata metadata) { extract(xmpString.getBytes(), metadata, null); }
if(svalue == null) return null; return svalue.toString(); case TAG_USER_LABEL: return _directory.getString(tagType);
@NotNull public StringValue getStringValue(int index, int bytesRequested, @Nullable Charset charset) throws IOException { return new StringValue(getBytes(index, bytesRequested), charset); }
return null; } else if (o instanceof StringValue) { return ((StringValue)o).getBytes(); } else if (o instanceof Rational[]) { Rational[] rationals = (Rational[])o;
if(svalue == null) return null; return svalue.toString(); case TAG_CONTRAST: case TAG_BRIGHTNESS:
@NotNull public StringValue getNullTerminatedStringValue(int index, int maxLengthBytes, @Nullable Charset charset) throws IOException { byte[] bytes = getNullTerminatedBytes(index, maxLengthBytes); return new StringValue(bytes, charset); }
@Override public String toString() { return toString(_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)); } } }
/** * 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 zero-byte is not reached within this limit, * reading will stop and the string will be truncated to this length. * @return The read string. * @throws IOException The buffer does not contain enough bytes to satisfy this request. */ @NotNull public String getNullTerminatedString(int maxLengthBytes, Charset charset) throws IOException { return getNullTerminatedStringValue(maxLengthBytes, charset).toString(); }
byte[] bytes = reader.getBytes(tagByteCount); Charset charSet = Iso2022Converter.guessCharSet(bytes); string = charSet != null ? new StringValue(bytes, charSet) : new StringValue(bytes, null);