use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class TestBinaries method testBinaryStream.
@Test
public void testBinaryStream() throws Exception {
Binary b = Bytes.from(TestRx.class.getClassLoader().getResourceAsStream("tml_with_binary.xml")).toObservable().lift(StreamDocument.createBinary()).firstOrError().blockingGet();
// 5,258
Assert.assertEquals(5258, b.getLength());
}
use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class SetMimeType method evaluate.
@Override
public Object evaluate() throws TMLExpressionException {
// application/vnd.ms-excel
Object o = getOperand(0);
if (!(o instanceof Binary)) {
throw new TMLExpressionException(this, "Mime type can only be set for binaries.");
}
Object mt = getOperand(1);
if (!(mt instanceof String)) {
throw new TMLExpressionException(this, "Mime type should be string expression.");
}
Binary b = (Binary) o;
b.setMimeType((String) mt);
return b;
}
use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class ToString method evaluate.
@Override
public final Object evaluate() throws com.dexels.navajo.expression.api.TMLExpressionException {
Object s = this.getOperands().get(0);
if (s == null) {
return null;
}
if (s instanceof com.dexels.navajo.document.types.Binary) {
Binary b = (Binary) s;
byte[] data = b.getData();
StringWriter w = new StringWriter();
for (int i = 0; i < data.length; i++) {
w.write(data[i]);
}
return w.toString();
}
if (s instanceof Money) {
Money m = (Money) s;
return m.formattedString();
}
return s.toString();
}
use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class ZipArchive method addFiles.
private final void addFiles(ZipOutputStream zo, String path, File f) throws Exception {
if (f.isFile()) {
ZipEntry entry = new ZipEntry(path + "/" + f.getName());
zo.putNextEntry(entry);
// Write file content
Binary bfi = new Binary(new FileInputStream(f));
bfi.write(zo);
} else {
path = (!path.equals("") ? path + "/" : "") + f.getName();
File[] entries = f.listFiles();
for (int i = 0; i < entries.length; i++) {
addFiles(zo, path, entries[i]);
}
}
}
use of com.dexels.navajo.document.types.Binary in project navajo by Dexels.
the class ToSecureImage method main.
public static void main(String[] args) {
try {
java.util.Locale.setDefault(new java.util.Locale("nl", "NL"));
// Tests.
ToSecureImage tm = new ToSecureImage();
for (int i = 0; i < 100; i++) {
tm.reset();
RandomString rs = new RandomString();
rs.reset();
rs.insertIntegerOperand(6);
String random = (String) rs.evaluate();
System.err.println("String[" + i + "]: " + random);
// lala
tm.insertStringOperand(new String(random));
tm.insertIntegerOperand(110);
tm.insertIntegerOperand(30);
Binary b = (Binary) tm.evaluate();
}
} catch (Exception e) {
logger.error("Error: ", e);
}
}
Aggregations