use of com.teradata.jaqy.interfaces.LineInput in project jaqy by Teradata.
the class RunCommand method execute.
@Override
public void execute(String[] args, boolean silent, JaqyInterpreter interpreter) throws Exception {
CommandLine cmdLine = getCommandLine(args);
String encoding = cmdLine.getOptionValue('c');
args = cmdLine.getArgs();
if (args.length == 0) {
interpreter.error("missing file name.");
}
LineInput input = null;
try {
input = LineInputFactory.getLineInput(interpreter.getPath(args[0]), encoding, false);
} catch (IOException e) {
interpreter.error("invalid file: " + args[0]);
}
if (!silent)
interpreter.println("-- Running script: " + args[0]);
interpreter.push(input);
}
use of com.teradata.jaqy.interfaces.LineInput in project jaqy by Teradata.
the class StackedLineInput method getInput.
private LineInput getInput() {
synchronized (m_lock) {
if (m_input != null)
return m_input;
if (m_inputs.isEmpty())
return null;
LineInput input = m_inputs.pop();
m_input = input;
return input;
}
}
use of com.teradata.jaqy.interfaces.LineInput in project jaqy by Teradata.
the class StackedLineInput method pop.
private LineInput pop() {
synchronized (m_lock) {
if (m_input == null)
return null;
if (m_inputs.isEmpty()) {
m_input = null;
return null;
}
LineInput input = m_inputs.pop();
m_input = input;
return input;
}
}
use of com.teradata.jaqy.interfaces.LineInput in project jaqy by Teradata.
the class Main method loadInit.
private static void loadInit(Globals globals, JaqyInterpreter interpreter, Display display, Path initFile) {
LineInput lineInput;
try {
Reader reader = new InputStreamReader(Main.class.getResourceAsStream(INTERNAL_INIT_RC), "UTF-8");
Path startDir = new FilePath(new File(System.getProperty("user.dir")));
lineInput = new ReaderLineInput(reader, startDir, false);
interpreter.push(lineInput);
interpreter.interpret(false);
} catch (Exception ex) {
ex.printStackTrace();
}
if (initFile != null && initFile.exists()) {
// check if ~/.jqrc exists
try {
lineInput = LineInputFactory.getLineInput(initFile, null, false);
interpreter.push(lineInput);
interpreter.interpret(false);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Aggregations