<commit_before>package extern.ukimplement.jus4test;

import java.io.File;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.swing.JOptionPane;

import uk.co.mmscomputing.device.scanner.Scanner;
import uk.co.mmscomputing.device.scanner.ScannerDevice;
import uk.co.mmscomputing.device.scanner.ScannerListener;
import uk.co.mmscomputing.device.scanner.ScannerIOException;
import uk.co.mmscomputing.device.scanner.ScannerIOMetadata;

public class ScannerTest implements ScannerListener {

    static ScannerTest app;

    Scanner scanner;

    public ScannerTest(String[] argv) throws ScannerIOException {
        scanner = Scanner.getDevice();
        scanner.addListener(this);
        /*scanner.select();
        scanner.acquire();*/

        if (scanner == null) {
            System.out.println("no se obtuve control sobre el controlador");
        } else {
            JOptionPane.showMessageDialog(null, "Devices : " + scanner.getDeviceNames().length);
            if (scanner.getDeviceNames().length >= 1) {
                for (String deviceName : scanner.getDeviceNames()) {
                    JOptionPane.showMessageDialog(null, deviceName);
                    //System.out.println(deviceName);
                }
            }
        }
        //scanner.waitToExit();
        //--
    }

    @Override
    public void update(ScannerIOMetadata.Type type, ScannerIOMetadata metadata) {
        if (type.equals(ScannerIOMetadata.ACQUIRED)) {
            //--
            System.out.println("Acquired ejec");
            //--
            BufferedImage image = metadata.getImage();
            System.out.println("Have an image now!");
            try {
                ImageIO.write(image, "png", new File("mmsc_image.png"));
            } catch (IOException e) {
                System.out.println(e.getMessage());
            }
        } else if (type.equals(ScannerIOMetadata.NEGOTIATE)) {
            //--
            System.out.println("Negotiate ejec");
            //--
            ScannerDevice device = metadata.getDevice();
            try {
//        device.setShowUserInterface(true);
//        device.setShowProgressBar(true);
//        device.setResolution(100);
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
        } else if (type.equals(ScannerIOMetadata.STATECHANGE)) {
            //--
            System.out.println("State Change ejec");
            //--
            System.err.println("State : " + metadata.getStateStr());
            if (metadata.isFinished()) {
                System.exit(0);
            }
        } else if (type.equals(ScannerIOMetadata.EXCEPTION)) {
            System.out.println(metadata.getException().getMessage());
        }
    }

    public static void main(String[] argv) {
         JOptionPane.showMessageDialog(null, "Search Scanner Devices");
        try {
            app = new ScannerTest(argv);
        } catch (ScannerIOException e) {
            JOptionPane.showMessageDialog(null, e.getMessage());
        }
    }
}<commit_msg>validacion del api<commit_after>package extern.ukimplement.jus4test;

import java.io.File;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.swing.JOptionPane;

import uk.co.mmscomputing.device.scanner.Scanner;
import uk.co.mmscomputing.device.scanner.ScannerDevice;
import uk.co.mmscomputing.device.scanner.ScannerListener;
import uk.co.mmscomputing.device.scanner.ScannerIOException;
import uk.co.mmscomputing.device.scanner.ScannerIOMetadata;

public class ScannerTest implements ScannerListener {

    static ScannerTest app;

    Scanner scanner;

    public ScannerTest(String[] argv) throws ScannerIOException {
        scanner = Scanner.getDevice();
        if (!scanner.isAPIInstalled()) {
            JOptionPane.showMessageDialog(null, "No se encuentra instalado el DMS para TWAIN \n por favor instale twainapp.win[x32?x64].installer.msi", "Error", JOptionPane.ERROR_MESSAGE);
        } else {
            scanner.addListener(this);
            /*scanner.select();
        scanner.acquire();*/

            if (scanner == null) {
                System.out.println("no se obtuve control sobre el controlador");
            } else {
                JOptionPane.showMessageDialog(null, "Devices : " + scanner.getDeviceNames().length);
                if (scanner.getDeviceNames().length >= 1) {
                    for (String deviceName : scanner.getDeviceNames()) {
                        JOptionPane.showMessageDialog(null, deviceName);
                        //System.out.println(deviceName);
                    }
                }
            }
            scanner.waitToExit();
            //--
        }
    }

    @Override
    public void update(ScannerIOMetadata.Type type, ScannerIOMetadata metadata) {
        if (type.equals(ScannerIOMetadata.ACQUIRED)) {
            //--
            System.out.println("Acquired ejec");
            //--
            BufferedImage image = metadata.getImage();
            System.out.println("Have an image now!");
            try {
                ImageIO.write(image, "png", new File("mmsc_image.png"));
            } catch (IOException e) {
                System.out.println(e.getMessage());
            }
        } else if (type.equals(ScannerIOMetadata.NEGOTIATE)) {
            //--
            System.out.println("Negotiate ejec");
            //--
            ScannerDevice device = metadata.getDevice();
            try {
//        device.setShowUserInterface(true);
//        device.setShowProgressBar(true);
//        device.setResolution(100);
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
        } else if (type.equals(ScannerIOMetadata.STATECHANGE)) {
            //--
            System.out.println("State Change ejec");
            //--
            System.err.println("State : " + metadata.getStateStr());
            if (metadata.isFinished()) {
                System.exit(0);
            }
        } else if (type.equals(ScannerIOMetadata.EXCEPTION)) {
            System.out.println(metadata.getException().getMessage());
        }
    }

    public static void main(String[] argv) {
        JOptionPane.showMessageDialog(null, "Search Scanner Devices");
        try {
            app = new ScannerTest(argv);
        } catch (ScannerIOException e) {
            JOptionPane.showMessageDialog(null, e.getMessage());
        }
    }
}
{'fraction_non_alphanumeric': 0.11951032899770467, 'fraction_numerical': 0.002448355011476664, 'mean_word_length': 2.0119815668202765, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4625896', 'n_tokens_mistral': 1867, 'n_tokens_neox': 1827, 'n_words': 307}