@Override protected void generateContent() { if (isDouble) { content = ByteUtils.getIsoBytes(value); } else { content = ByteUtils.getIsoBytes((int) value); } }
static byte[] getIsoBytes(int n, ByteBuffer buffer) { boolean negative = false; if (n < 0) { negative = true; n = -n; } int intLen = intSize(n); ByteBuffer buf = buffer == null ? new ByteBuffer(intLen + (negative ? 1 : 0)) : buffer; for (int i = 0; i < intLen; i++) { buf.prepend(bytes[n % 10]); n /= 10; } if (negative) buf.prepend((byte) '-'); return buffer == null ? buf.getInternalBuffer() : null; }
v = (long) d; int intLen = longSize(v); buf = buffer == null ? new ByteBuffer(intLen + (negative ? 1 : 0)) : buffer; for (int i = 0; i < intLen; i++) {
static byte[] getIsoBytes(int n, ByteBuffer buffer) { boolean negative = false; if (n < 0) { negative = true; n = -n; } int intLen = intSize(n); ByteBuffer buf = buffer == null ? new ByteBuffer(intLen + (negative ? 1 : 0)) : buffer; for (int i = 0; i < intLen; i++) { buf.prepend(bytes[n % 10]); n /= 10; } if (negative) buf.prepend((byte) '-'); return buffer == null ? buf.getInternalBuffer() : null; }
v = (long) d; int intLen = longSize(v); buf = buffer == null ? new ByteBuffer(intLen + (negative ? 1 : 0)) : buffer; for (int i = 0; i < intLen; i++) {
public static byte[] getIsoBytes(byte pre, String text) { return getIsoBytes(pre, text, (byte) 0); }
static byte[] getIsoBytes(double d, ByteBuffer buffer) { return getIsoBytes(d, buffer, HighPrecision); }
public static byte[] getIsoBytes(double d) { return getIsoBytes(d, null); }
static byte[] getIsoBytes(double d, ByteBuffer buffer) { return getIsoBytes(d, buffer, HighPrecision); }
public static byte[] getIsoBytes(double d) { return getIsoBytes(d, null); }
public static byte[] getIsoBytes(int n) { return getIsoBytes(n, null); }
public static byte[] getIsoBytes(byte pre, String text) { return getIsoBytes(pre, text, (byte) 0); }
public static byte[] getIsoBytes(int n) { return getIsoBytes(n, null); }
/** * Gets bytes of String-value without considering encoding. * * @return byte array */ protected byte[] getIsoBytes(PdfString string) { return ByteUtils.getIsoBytes(string.getValue()); }
@Override public String toString() { if (content != null) { return new String(content); } else if (isDouble) { return new String(ByteUtils.getIsoBytes(getValue())); } else { return new String(ByteUtils.getIsoBytes(intValue())); } }
public ByteBuffer append(String str) { return append(ByteUtils.getIsoBytes(str)); }
public T writeString(String value) { return writeBytes(ByteUtils.getIsoBytes(value)); }
public ByteBuffer append(String str) { return append(ByteUtils.getIsoBytes(str)); }
public T writeString(String value) { return writeBytes(ByteUtils.getIsoBytes(value)); }
/** * Gets file ID, either {@link PdfName#ID} key of trailer or a newly generated id. * * @return byte array represents file ID. * @see PdfEncryption#generateNewDocumentId() */ public byte[] getOriginalFileId() { PdfArray id = trailer.getAsArray(PdfName.ID); if (id != null) { return ByteUtils.getIsoBytes(id.getAsString(0).getValue()); } else { return PdfEncryption.generateNewDocumentId(); } }