BinaryFileWriteStream.java
/**
* Copyright 2010,2021 Nikolas S Boyd.
Permission is granted to copy this work provided this copyright statement is retained in all copies.
*/
package Hoot.Streams;
import Hoot.Runtime.Functions.*;
import Hoot.Runtime.Faces.*;
import Hoot.Runtime.Values.*;
import Hoot.Runtime.Blocks.*;
import Smalltalk.Core.*;
import Smalltalk.Blocks.*;
import Smalltalk.Magnitudes.*;
import Hoot.Behaviors.*;
import Hoot.Behaviors.Nil;
import Hoot.Behaviors.Object;
import Hoot.Behaviors.True;
import Hoot.Behaviors.False;
import Hoot.Behaviors.Boolean;
import Hoot.Magnitudes.*;
import Hoot.Magnitudes.Integer;
import Hoot.Magnitudes.Character;
import Hoot.Magnitudes.Float;
import Hoot.Magnitudes.Double;
import Hoot.Collections.*;
import Hoot.Collections.String;
import java.io.*;
import Hoot.Magnitudes.Integer;
import Hoot.Collections.CharacterString;
import Hoot.Runtime.Functions.Exceptional.Handler;
import Smalltalk.Magnitudes.Ordinal;
import Smalltalk.Collections.CollectedReadably;
import Smalltalk.Streams.*;
public class BinaryFileWriteStream extends FileWriteStream<Integer>
{
public static Metaclass type() { return (Metaclass)Metaclass.$class; }
@Override public Metaclass $class() { return (Metaclass)Metaclass.$class; }
public static class Metaclass extends FileWriteStream.Metaclass
{
static final BinaryFileWriteStream.Metaclass $class = new BinaryFileWriteStream.Metaclass();
public Metaclass() {
this(BinaryFileWriteStream.Metaclass.class);
}
public Metaclass(java.lang.Class aClass) {
super(aClass);
}
@Override public java.lang.Class outerClass() { return BinaryFileWriteStream.class; }
/**
* @return
*/
protected BinaryFileWriteStream on(final RandomAccessFile primitiveFile)
{
java.lang.String exitID = "BinaryFileWriteStreamMetatype>>on";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
return (BinaryFileWriteStream)f0.exit(exitID, new BinaryFileWriteStream(primitiveFile));
});
}
}
/**
*
*/
protected BinaryFileWriteStream(final RandomAccessFile primitiveFile)
{
super(primitiveFile);
java.lang.String exitID = "BinaryFileWriteStream>>BinaryFileWriteStream";
Frame f0 = new Frame(exitID);
}
/**
* @return
*/
public static BinaryFileWriteStream write(final String fileName)
{
java.lang.String exitID = "BinaryFileWriteStream>>$write";
Frame f0 = new Frame(exitID);
return (BinaryFileWriteStream)FileWriteStream.type().write_type(fileName, Symbol.from("binary"));
}
/**
* @return
*/
public ByteArray contents()
{
java.lang.String exitID = "BinaryFileWriteStream>>contents";
Frame f0 = new Frame(exitID);
Integer pose = this.position();
this.reset();
ByteArray result = this.nextBytes(this.length());
this.position(pose);
return (ByteArray)result;
}
/**
* @return
*/
@Override public BinaryFileWriteStream nextPut(final Integer element)
{
java.lang.String exitID = "BinaryFileWriteStream>>nextPut";
Frame f0 = new Frame(exitID);
Closure.with(f2 -> {
file.writeByte(element.primitiveByte());
return null;
}, "").runLoud();
return (BinaryFileWriteStream)this;
}
/**
* @return
*/
public BinaryFileWriteStream nextPutAll(final byte ... elements)
{
java.lang.String exitID = "BinaryFileWriteStream>>nextPutAll";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
Closure.with(f2 -> {
file.write(elements);
return (BinaryFileWriteStream)f0.exit(exitID, null);
}, "").runLoud();
return (BinaryFileWriteStream)f0.exit(exitID, this);
});
}
/**
* @return
*/
public BinaryFileWriteStream nextPutAll(final java.lang.String elements)
{
java.lang.String exitID = "BinaryFileWriteStream>>nextPutAll";
Frame f0 = new Frame(exitID);
return f0.evaluate(() -> {
Closure.with(f2 -> {
file.writeBytes(elements);
return (BinaryFileWriteStream)f0.exit(exitID, null);
}, "").runLoud();
return (BinaryFileWriteStream)f0.exit(exitID, this);
});
}
/**
* @return
*/
@Override public BinaryFileWriteStream nextPutAll(final CollectedReadably<Integer> elements)
{
java.lang.String exitID = "BinaryFileWriteStream>>nextPutAll";
Frame f0 = new Frame(exitID);
Closure.with(f2 -> {
file.writeBytes(((CharacterString)elements).primitiveString());
return null;
}, "").runLoud();
return (BinaryFileWriteStream)this;
}
/**
* @return
*/
public Boolean isText()
{
java.lang.String exitID = "BinaryFileWriteStream>>isText";
Frame f0 = new Frame(exitID);
return (Boolean)False.literal();
}
/**
* @return
*/
public Boolean isBinary()
{
java.lang.String exitID = "BinaryFileWriteStream>>isBinary";
Frame f0 = new Frame(exitID);
return (Boolean)True.literal();
}
/**
* @return
*/
public Symbol externalType()
{
java.lang.String exitID = "BinaryFileWriteStream>>externalType";
Frame f0 = new Frame(exitID);
return (Symbol)Symbol.from("binary");
}
}