Package uk.co.nimp.scard.log

Examples of uk.co.nimp.scard.log.ScardPrintStreamLogHandler


                    for (int i = 0; i < selectedTerminals.size(); i++) {
                        GenericTerminal terminal = selectedTerminals.get(i);
                        //terminal.closeAllLogs();//this close System.out !
                        for (ScardLogHandler logHandler : terminal.getLogs()) {
                            if (logHandler instanceof ScardPrintStreamLogHandler) {
                                ScardPrintStreamLogHandler printStreamLogHandler = (ScardPrintStreamLogHandler) logHandler;
                                if (printStreamLogHandler.getPrintStream() == System.out) {
                                    terminal.removeLog(logHandler);
                                } else {
                                    terminal.closeLog(logHandler);
                                }

                            } else {
                                terminal.closeLog(logHandler);
                            }
                        }
                        String baseName = outputFile.getAbsolutePath();
                        String ext = AFileUtilities.extractFileExtension(baseName);

                        String name =  terminal.getName() ;
                        //TODO: make sure that name don't contain forbiden characters like ":" and so on...
                        name=name.replace(':', '_');
                        name=name.replace('\\', '_');
                        name=name.replace('/', '_');
                        name=name.replace('*', '_');
                        name=baseName.substring(0, baseName.length() - ext.length()) +name+ "." + ext;
                        File logFile = new File(name);
                        logFiles.set(i, logFile);
                        PrintStream ps = new PrintStream(logFile);
                        ScardPrintStreamLogHandler printStreamLogHandler = new ScardPrintStreamLogHandler(ps);
                        terminal.addLogHandler(printStreamLogHandler);
                    }
                    System.out.println("Logging to " + outputFile.getCanonicalPath());
                    //outputFile = null;
                    //argContext.setOutputFile(null);
View Full Code Here


                            System.out.println("MP65 terminal not detected.");
                            return;
                        }
                        MP65Terminal mp65 = (MP65Terminal) terminals.get(0);
                         terminals = manager.list();
                        mp65.addLogHandler(new ScardPrintStreamLogHandler(System.out));
                        System.out.println("Please insert a card in terminal "+ mp65.getName());
                        while(false==mp65.isCardPresent()){
                            try {
                                Thread.sleep(200);
                            } catch (InterruptedException ex) {
View Full Code Here

    public void monitorStream() throws IOException{
        if(null==logHandler){
            pos = new PipedOutputStream();
            outStream=new PrintStream(pos);
            logHandler=new ScardPrintStreamLogHandler(outStream, this);
            terminal.addLogHandler(logHandler);
            super.monitorStream(pos);
        }
    }
View Full Code Here

        } else {
            selectedTerminals.add(Utilities.terminalChooser(availableTerminals));
        }
        if (1 == selectedTerminals.size()) {
            PrintStream ps = System.out;
            ScardPrintStreamLogHandler printStreamLogHandler = new ScardPrintStreamLogHandler(ps);
            GenericTerminal terminal = selectedTerminals.get(0);
            terminal.addLogHandler(printStreamLogHandler);
        }
    }
View Full Code Here

        File in = arg.getSingleFile(ARG_SET_PRINT_STREAM_LOG);
        List<ScardLogHandler> handlers = new ArrayList<ScardLogHandler>();
        handlers.addAll(terminal.getLogs());//avoid java.util.ConcurrentModificationException in the loop below
        for (ScardLogHandler logHandler : handlers) {
            if (logHandler instanceof ScardPrintStreamLogHandler) {
                ScardPrintStreamLogHandler printStreamLogHandler = (ScardPrintStreamLogHandler) logHandler;
                if (printStreamLogHandler.getPrintStream() == System.out) {
                    //do nothing//terminal.removeLog(logHandler);
                } else {
                    //remove previous one
                    terminal.closeLog(logHandler);
                }
            }
        }
        String name = AFileUtilities.appendToFileName(in, AFileUtilities.generateValidFileName(terminal.getName()));
        logFile = new File(name);
        checkParent(logFile);
        PrintStream ps = new PrintStream(logFile);
        ScardPrintStreamLogHandler printStreamLogHandler = new ScardPrintStreamLogHandler(ps);
        terminal.addLogHandler(printStreamLogHandler);
        logHandlersStack.push(printStreamLogHandler);
        System.out.println("Logging to " + logFile.getCanonicalPath());
        return true;
    }
View Full Code Here

    boolean processCloseAllLogs(Arg arg, CommandLine cl) throws IOException {
        List<ScardLogHandler> handlers = new ArrayList<ScardLogHandler>();
        handlers.addAll(terminal.getLogs());//avoid java.util.ConcurrentModificationException in the loop below
        for (ScardLogHandler logHandler : handlers) {
            if (logHandler instanceof ScardPrintStreamLogHandler) {
                ScardPrintStreamLogHandler printStreamLogHandler = (ScardPrintStreamLogHandler) logHandler;
                if (printStreamLogHandler.getPrintStream() == System.out) {
                    //do nothing//terminal.removeLog(logHandler);
                } else {
                    //remove
                    terminal.closeLog(logHandler);
                }
View Full Code Here

                System.out.println("Smartware terminal not detected.");
                return;
            }
            SmartwareTerminal terminal = (SmartwareTerminal) terminals.get(0);
            terminals = manager.list();
            terminal.addLogHandler(new ScardPrintStreamLogHandler(System.out));
            System.out.println("Please insert a card in terminal " + terminal.getName());
            while (false == terminal.isCardPresent()) {
                try {
                    Thread.sleep(200);
                } catch (InterruptedException ex) {
View Full Code Here

TOP

Related Classes of uk.co.nimp.scard.log.ScardPrintStreamLogHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.