Example usage for java.lang String contentEquals

List of usage examples for java.lang String contentEquals

Introduction

In this page you can find the example usage for java.lang String contentEquals.

Prototype

public boolean contentEquals(CharSequence cs) 

Source Link

Document

Compares this string to the specified CharSequence .

Usage

From source file:com.mozilla.SUTAgentAndroid.SUTAgentAndroid.java

public boolean setUpNetwork(String sIniFile) {
    boolean bRet = false;
    int lcv = 0;/*from  w ww  . ja  va2  s . com*/
    int lcv2 = 0;
    WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    WifiConfiguration wc = new WifiConfiguration();
    DoCommand tmpdc = new DoCommand(getApplication());

    String ssid = tmpdc.GetIniData("Network Settings", "SSID", sIniFile);
    String auth = tmpdc.GetIniData("Network Settings", "AUTH", sIniFile);
    String encr = tmpdc.GetIniData("Network Settings", "ENCR", sIniFile);
    String key = tmpdc.GetIniData("Network Settings", "KEY", sIniFile);
    String eap = tmpdc.GetIniData("Network Settings", "EAP", sIniFile);
    String adhoc = tmpdc.GetIniData("Network Settings", "ADHOC", sIniFile);

    Toast.makeText(getApplication().getApplicationContext(), "Starting and configuring network",
            Toast.LENGTH_LONG).show();
    /*
            ContentResolver cr = getContentResolver();
            int nRet;
            try {
    nRet = Settings.System.getInt(cr, Settings.System.WIFI_USE_STATIC_IP);
    String foo2 = "" + nRet;
            } catch (SettingNotFoundException e1) {
    e1.printStackTrace();
            }
    */
    /*
            wc.SSID = "\"Mozilla-Build\"";
            wc.preSharedKey  = "\"MozillaBuildQA500\"";
            wc.hiddenSSID = true;
            wc.status = WifiConfiguration.Status.ENABLED;
            wc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
            wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
            wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
            wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
            wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
            wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
            wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
    */
    wc.SSID = "\"" + ssid + "\"";
    //        wc.SSID = "\"Mozilla-G\"";
    //        wc.SSID = "\"Mozilla\"";

    if (auth.contentEquals("wpa2")) {
        wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
        wc.preSharedKey = null;
    }

    if (encr.contentEquals("aes")) {
        wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
        wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
    }

    if (eap.contentEquals("peap")) {
        wc.eap.setValue("PEAP");
        wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP);
        wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X);
    }

    wc.status = WifiConfiguration.Status.ENABLED;

    if (!wifi.isWifiEnabled())
        wifi.setWifiEnabled(true);

    while (wifi.getWifiState() != WifiManager.WIFI_STATE_ENABLED) {
        Thread.yield();
        if (++lcv > 10000)
            return (bRet);
    }

    wl = wifi.createWifiLock(WifiManager.WIFI_MODE_FULL, "SUTAgent");
    if (wl != null)
        wl.acquire();

    WifiConfiguration foo = null;
    int nNetworkID = -1;

    List<WifiConfiguration> connsLst = wifi.getConfiguredNetworks();
    int nConns = connsLst.size();
    for (int i = 0; i < nConns; i++) {

        foo = connsLst.get(i);
        if (foo.SSID.equalsIgnoreCase(wc.SSID)) {
            nNetworkID = foo.networkId;
            wc.networkId = foo.networkId;
            break;
        }
    }

    int res;

    if (nNetworkID != -1) {
        res = wifi.updateNetwork(wc);
    } else {
        res = wifi.addNetwork(wc);
    }

    Log.d("WifiPreference", "add Network returned " + res);

    boolean b = wifi.enableNetwork(res, true);
    Log.d("WifiPreference", "enableNetwork returned " + b);

    wifi.saveConfiguration();

    WifiInfo wi = wifi.getConnectionInfo();
    SupplicantState ss = wi.getSupplicantState();

    lcv = 0;
    lcv2 = 0;

    while (ss.compareTo(SupplicantState.COMPLETED) != 0) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        if (wi != null)
            wi = null;
        if (ss != null)
            ss = null;
        wi = wifi.getConnectionInfo();
        ss = wi.getSupplicantState();
        if (++lcv > 60) {
            if (++lcv2 > 5) {
                Toast.makeText(getApplication().getApplicationContext(),
                        "Unable to start and configure network", Toast.LENGTH_LONG).show();
                return (bRet);
            } else {
                Toast.makeText(getApplication().getApplicationContext(), "Resetting wifi interface",
                        Toast.LENGTH_LONG).show();
                if (wl != null)
                    wl.release();
                wifi.setWifiEnabled(false);
                while (wifi.getWifiState() != WifiManager.WIFI_STATE_DISABLED) {
                    Thread.yield();
                }

                wifi.setWifiEnabled(true);
                while (wifi.getWifiState() != WifiManager.WIFI_STATE_ENABLED) {
                    Thread.yield();
                }
                b = wifi.enableNetwork(res, true);
                Log.d("WifiPreference", "enableNetwork returned " + b);
                if (wl != null)
                    wl.acquire();
                lcv = 0;
            }
        }
    }

    lcv = 0;
    while (getLocalIpAddress() == null) {
        if (++lcv > 10000)
            return (bRet);
    }

    Toast.makeText(getApplication().getApplicationContext(), "Network started and configured",
            Toast.LENGTH_LONG).show();
    bRet = true;

    return (bRet);
}

From source file:ch.kostceco.tools.kostval.validation.modulepdfa.impl.ValidationAvalidationAiModuleImpl.java

@Override
public boolean validate(File valDatei, File directoryOfLogfile) throws ValidationApdfvalidationException {
    @SuppressWarnings("unused")
    boolean valid = false;

    // Version & Level herausfinden
    String pdfa1 = getConfigurationService().pdfa1();
    String pdfa2 = getConfigurationService().pdfa2();

    Integer pdfaVer1 = 0;//from  w  w w.  ja  v a2s  . c  o m
    Integer pdfaVer2 = 0;

    /* Nicht vergessen in "src/main/resources/config/applicationContext-services.xml" beim
     * entsprechenden Modul die property anzugeben: <property name="configurationService"
     * ref="configurationService" /> */

    // Vorbereitung fr eine allfllige Festhaltung bei unterschiedlichen Validierungsresultaten in
    // einer PDF_Diagnosedatei
    File pdfDia = null;
    String pdfDiaPath = getConfigurationService().getPathToDiagnose();

    try {
        pdfDia = new File(pdfDiaPath + File.separator + "PDF-Diagnosedaten.kost-val.xml");
        if (!pdfDia.exists()) {
            pdfDia.createNewFile();
            PrintWriter output;
            BufferedWriter buffer;
            FileWriter fileWriter;
            fileWriter = new FileWriter(pdfDia);
            buffer = new BufferedWriter(fileWriter);
            output = new PrintWriter(buffer);
            try {
                output.print(getTextResourceService().getText(MESSAGE_XML_DIAHEADER) + "\n");
                output.print(getTextResourceService().getText(MESSAGE_XML_DIAEND));
            } finally {
                output.close();
                buffer.close();
                fileWriter.close();
            }
        }
        File xslDiaOrig = new File("resources" + File.separator + "kost-val_PDFdia.xsl");
        File xslDiaCopy = new File(pdfDiaPath + File.separator + "kost-val_PDFdia.xsl");
        if (!xslDiaCopy.exists()) {
            Util.copyFile(xslDiaOrig, xslDiaCopy);
        }
    } catch (IOException e) {
        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                + getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage()));
    }

    /* Neu soll die Validierung mit PDFTron konfigurier bar sein Mgliche Werte 1A, 1B und no sowie
     * 2A, 2B, 2U und no Da Archive beide Versionen erlauben knnen sind es 2 config eintrge Es
     * gibt mehre Mglichkeiten das PDF in der gewnschten Version zu testen - Unterscheidung anhand
     * DROID --> braucht viel Zeit auch mit KaD_Signaturefile - Unterscheidung anhand PDF/A-Eintrag
     * wie Droid aber selber programmiert --> ist viel schneller */
    if (pdfa2.equals("2A") || pdfa2.equals("2B") || pdfa2.equals("2U")) {
        // gltiger Konfigurationseintrag und V2 erlaubt
        pdfaVer2 = 2;
    } else {
        // v2 nicht erlaubt oder falscher eintrag
        pdfa2 = "no";
    }
    if (pdfa1.equals("1A") || pdfa1.equals("1B")) {
        // gltiger Konfigurationseintrag und V1 erlaubt
        pdfaVer1 = 1;
    } else {
        // v1 nicht erlaubt oder falscher eintrag
        pdfa1 = "no";
    }
    if (pdfa1 == "no" && pdfa2 == "no") {
        // keine Validierung mglich. keine PDFA-Versionen konfiguriert
        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                + getTextResourceService().getText(ERROR_XML_A_PDFA_NOCONFIG));
        valid = false;
        return false;
    }

    String level = "no";
    // Richtiges Level definieren
    if (pdfaVer1 != 1) {
        // Level 1 nicht erlaubt --> Level 2
        level = pdfa2;
    } else if (pdfaVer2 != 2) {
        // Level 2 nicht erlaubt --> Level 1
        level = pdfa1;
    } else {
        try {
            // Beide sind mglich --> Level je nach File auswhlen
            pdfaVer1 = 0;
            pdfaVer2 = 0;
            BufferedReader in = new BufferedReader(new FileReader(valDatei));
            String line;
            while ((line = in.readLine()) != null) {
                // hufige Partangaben: pdfaid:part>1< pdfaid:part='1' pdfaid:part="1"
                if (line.contains("pdfaid:part")) {
                    // pdfaid:part
                    if (line.contains("pdfaid:part>1<")) {
                        level = pdfa1;
                        pdfaVer1 = 1;
                    } else if (line.contains("pdfaid:part='1'")) {
                        level = pdfa1;
                        pdfaVer1 = 1;
                    } else if (line.contains("pdfaid:part=\"1\"")) {
                        level = pdfa1;
                        pdfaVer1 = 1;
                    } else if (line.contains("pdfaid:part>2<")) {
                        level = pdfa2;
                        pdfaVer2 = 2;
                    } else if (line.contains("pdfaid:part='2'")) {
                        level = pdfa2;
                        pdfaVer2 = 2;
                    } else if (line.contains("pdfaid:part=\"2\"")) {
                        level = pdfa2;
                        pdfaVer2 = 2;
                    } else if (line.contains("pdfaid:part") && line.contains("1")) {
                        // PDFA-Version = 1
                        level = pdfa1;
                        pdfaVer1 = 1;
                    } else if (line.contains("pdfaid:part") && line.contains("2")) {
                        // PDFA-Version = 2
                        level = pdfa2;
                        pdfaVer2 = 2;
                    }
                }
                if (pdfaVer1 == 0 && pdfaVer2 == 0) {
                    // der Part wurde nicht gefunden --> Level 2
                    level = pdfa2;
                }
            }
        } catch (Throwable e) {
            getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                    + getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage()));
        }
    }
    getMessageService().logError(getTextResourceService().getText(MESSAGE_PDFAVALIDATION_VL, level));

    // Start mit der Erkennung

    // Eine PDF Datei (.pdf / .pdfa) muss mit %PDF [25504446] beginnen
    if (valDatei.isDirectory()) {
        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                + getTextResourceService().getText(ERROR_XML_A_PDFA_ISDIRECTORY));
        return false;
    } else if ((valDatei.getAbsolutePath().toLowerCase().endsWith(".pdf")
            || valDatei.getAbsolutePath().toLowerCase().endsWith(".pdfa"))) {

        FileReader fr = null;

        try {
            fr = new FileReader(valDatei);
            BufferedReader read = new BufferedReader(fr);

            // Hex 25 in Char umwandeln
            String str1 = "25";
            int i1 = Integer.parseInt(str1, 16);
            char c1 = (char) i1;
            // Hex 50 in Char umwandeln
            String str2 = "50";
            int i2 = Integer.parseInt(str2, 16);
            char c2 = (char) i2;
            // Hex 44 in Char umwandeln
            String str3 = "44";
            int i3 = Integer.parseInt(str3, 16);
            char c3 = (char) i3;
            // Hex 46 in Char umwandeln
            String str4 = "46";
            int i4 = Integer.parseInt(str4, 16);
            char c4 = (char) i4;

            // auslesen der ersten 4 Zeichen der Datei
            int length;
            int i;
            char[] buffer = new char[4];
            length = read.read(buffer);
            for (i = 0; i != length; i++)
                ;

            // die beiden charArrays (soll und ist) mit einander vergleichen IST = c1c2c3c4
            char[] charArray1 = buffer;
            char[] charArray2 = new char[] { c1, c2, c3, c4 };

            if (Arrays.equals(charArray1, charArray2)) {
                // hchstwahrscheinlich ein PDF da es mit 25504446 respektive %PDF beginnt
                valid = true;
            } else {
                // Droid-Erkennung, damit Details ausgegeben werden knnen
                String nameOfSignature = getConfigurationService().getPathToDroidSignatureFile();
                if (nameOfSignature == null) {
                    getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                            + getTextResourceService().getText(MESSAGE_XML_CONFIGURATION_ERROR_NO_SIGNATURE));
                    return false;
                }
                // existiert die SignatureFile am angebenen Ort?
                File fnameOfSignature = new File(nameOfSignature);
                if (!fnameOfSignature.exists()) {
                    getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                            + getTextResourceService().getText(MESSAGE_XML_CA_DROID));
                    return false;
                }

                Droid droid = null;
                try {
                    /* kleiner Hack, weil die Droid libraries irgendwo ein System.out drin haben, welche den
                     * Output stren Util.switchOffConsole() als Kommentar markieren wenn man die
                     * Fehlermeldung erhalten mchte */
                    Util.switchOffConsole();
                    droid = new Droid();

                    droid.readSignatureFile(nameOfSignature);

                } catch (Exception e) {
                    getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                            + getTextResourceService().getText(ERROR_XML_CANNOT_INITIALIZE_DROID));
                    return false;
                } finally {
                    Util.switchOnConsole();
                }
                File file = valDatei;
                String puid = "";
                IdentificationFile ifile = droid.identify(file.getAbsolutePath());
                for (int x = 0; x < ifile.getNumHits(); x++) {
                    FileFormatHit ffh = ifile.getHit(x);
                    FileFormat ff = ffh.getFileFormat();
                    puid = ff.getPUID();
                }
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                        + getTextResourceService().getText(ERROR_XML_A_PDFA_INCORRECTFILE, puid));
                return false;
            }
        } catch (Exception e) {
            getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                    + getTextResourceService().getText(ERROR_XML_A_PDFA_INCORRECTFILE));
            return false;
        }
    } else {
        // die Datei endet nicht mit pdf oder pdfa -> Fehler
        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                + getTextResourceService().getText(ERROR_XML_A_PDFA_INCORRECTFILEENDING));
        return false;
    }
    // Ende der Erkennung

    boolean isValid = false;
    boolean dual = false;

    // Initialisierung PDFTron -> berprfen der Angaben: existiert die PdftronExe am angebenen Ort?
    String pathToPdftronExe = getConfigurationService().getPathToPdftronExe();
    String producerFirstValidator = getConfigurationService().firstValidator();
    String dualValidation = getConfigurationService().dualValidation();

    /* Nicht vergessen in "src/main/resources/config/applicationContext-services.xml" beim
     * entsprechenden Modul die property anzugeben: <property name="configurationService"
     * ref="configurationService" /> */

    if (dualValidation.contentEquals("dual")) {
        // Duale Validierung gewnscht
        dual = true;
    }
    if (!producerFirstValidator.contentEquals("PDFTron")) {
        // nicht der Validator von PDFTron --> PDFTools wird verwendet
        producerFirstValidator = "PDFTools";
    }

    File fPdftronExe = new File(pathToPdftronExe);
    if (!fPdftronExe.exists() || !fPdftronExe.getName().equals("pdfa.exe")) {
        // Keine Duale Validierung mglich
        if (dualValidation.contentEquals("dual") || producerFirstValidator.contentEquals("PDFTron")) {
            getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                    + getTextResourceService().getText(ERROR_XML_PDFTRON_MISSING));
            dual = false;
            producerFirstValidator = "PDFTools";
        }
    }

    pathToPdftronExe = "\"" + pathToPdftronExe + "\"";

    String pdfTools = "";
    String pdfTron = "";
    String newPdfDiaTxt = "";

    try {
        int iCategory = 999999999;
        // Create object
        PdfValidatorAPI docPdf = new PdfValidatorAPI();

        // TODO: Erledigt Start mit PDFTron
        if (producerFirstValidator.contentEquals("PDFTron")) {
            // zuerst mit PDFTron und danach ggf mit PDFTools
            File report;
            Document doc = null;

            try {

                // Pfad zum Programm Pdftron
                File pdftronExe = new File(pathToPdftronExe);
                File output = directoryOfLogfile;
                String pathToPdftronOutput = output.getAbsolutePath();
                StringBuffer command = new StringBuffer(pdftronExe + " ");
                command.append("-l " + level);
                command.append(" -o ");
                command.append("\"");
                command.append(output.getAbsolutePath());
                command.append("\"");
                command.append(" ");
                command.append("\"");
                command.append(valDatei.getAbsolutePath());
                command.append("\"");

                Process proc = null;
                Runtime rt = null;

                try {
                    /* Der Name des generierten Reports lautet per default report.xml und es scheint keine
                     * Mglichkeit zu geben, dies zu bersteuern. */
                    report = new File(pathToPdftronOutput, "report.xml");

                    // falls das File bereits existiert, z.B. von einem vorhergehenden Durchlauf, lschen
                    // wir es
                    if (report.exists()) {
                        report.delete();
                    }

                    Util.switchOffConsole();

                    rt = Runtime.getRuntime();
                    proc = rt.exec(command.toString().split(" "));
                    // .split(" ") ist notwendig wenn in einem Pfad ein Doppelleerschlag vorhanden ist!

                    // Fehleroutput holen
                    StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), "ERROR");

                    // Output holen
                    StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), "OUTPUT");

                    // Threads starten
                    errorGobbler.start();
                    outputGobbler.start();

                    // Warte, bis wget fertig ist
                    proc.waitFor();

                    Util.switchOnConsole();
                } catch (Exception e) {
                    getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                            + getTextResourceService().getText(ERROR_XML_A_PDFA_SERVICEFAILED, e.getMessage()));
                    return false;
                } finally {
                    if (proc != null) {
                        closeQuietly(proc.getOutputStream());
                        closeQuietly(proc.getInputStream());
                        closeQuietly(proc.getErrorStream());
                    }
                }
                // Ende PDFTRON direkt auszulsen

                String pathToPdftronReport = report.getAbsolutePath();
                BufferedInputStream bis = new BufferedInputStream(new FileInputStream(pathToPdftronReport));
                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                DocumentBuilder db = dbf.newDocumentBuilder();
                doc = db.parse(bis);
                doc.normalize();

                Integer passCount = new Integer(0);
                NodeList nodeLstI = doc.getElementsByTagName("Pass");

                // Valide pdfa-Dokumente enthalten "<Validation> <Pass FileName..." Anzahl pass = anzahl
                // Valider pdfa
                for (int s = 0; s < nodeLstI.getLength(); s++) {
                    passCount = passCount + 1;
                    // Valide PDFA-Datei Module A-J sind Valid
                    isValid = true;
                }

                if (passCount == 0) {
                    if (dual) {
                        // Duale Validierung mit PDFTools

                        if (docPdf.open(valDatei.getAbsolutePath(), "", NativeLibrary.COMPLIANCE.ePDFUnk)) {
                            // PDF Konnte geffnet werden
                            docPdf.setStopOnError(true);
                            docPdf.setReportingLevel(1);
                        } else {
                            docPdf.setStopOnError(true);
                            docPdf.setReportingLevel(1);
                            if (docPdf.getErrorCode() == NativeLibrary.ERRORCODE.PDF_E_PASSWORD) {
                                getMessageService().logError(getTextResourceService()
                                        .getText(MESSAGE_XML_MODUL_A_PDFA)
                                        + getTextResourceService().getText(ERROR_XML_A_PDFTOOLS_ENCRYPTED));
                                return false;
                            } else {
                                getMessageService().logError(getTextResourceService()
                                        .getText(MESSAGE_XML_MODUL_A_PDFA)
                                        + getTextResourceService().getText(ERROR_XML_A_PDFTOOLS_DAMAGED));
                                return false;
                            }
                        }

                        /* ePDFA1a 5122 ePDFA1b 5121 ePDFA2a 5891 ePDFA2b 5889 ePDFA2u 5890 */
                        if (level.contentEquals("1A")) {
                            if (docPdf.open(valDatei.getAbsolutePath(), "", 5122)) {
                                docPdf.validate();
                            }
                        } else if (level.contentEquals("1B")) {
                            if (docPdf.open(valDatei.getAbsolutePath(), "", 5121)) {
                                docPdf.validate();
                            }
                        } else if (level.contentEquals("2A")) {
                            if (docPdf.open(valDatei.getAbsolutePath(), "", 5891)) {
                                docPdf.validate();
                            }
                        } else if (level.contentEquals("2B")) {
                            if (docPdf.open(valDatei.getAbsolutePath(), "", 5889)) {
                                docPdf.validate();
                            }
                        } else if (level.contentEquals("2U")) {
                            if (docPdf.open(valDatei.getAbsolutePath(), "", 5890)) {
                                docPdf.validate();
                            }
                        } else {
                            // Validierung nach 2b
                            level = "2B";
                            if (docPdf.open(valDatei.getAbsolutePath(), "", 5889)) {
                                docPdf.validate();
                            }
                        }

                        // Error Category
                        iCategory = docPdf.getCategories();
                        /* die Zahl kann auch eine Summe von Kategorien sein z.B. 6144=2048+4096 ->
                         * getCategoryText gibt nur die erste Kategorie heraus (z.B. 2048) */

                        int success = 0;

                        /* ErrorCode kann ungleich Null sein, wenn es nur eine Information zu einer nicht
                         * einhaltung einer Empfehlung gefunden wurde.
                         * 
                         * Entsprechend wird der ErrorCode ignoriert. */

                        PdfError err = docPdf.getFirstError();
                        PdfError err1 = docPdf.getFirstError();

                        @SuppressWarnings("unused")
                        int iError = 0;
                        while (err != null) {
                            iError = err1.getErrorCode();
                            success = success + 1;
                            // Get next error
                            err = docPdf.getNextError();
                        }

                        if (success == 0 && iCategory == 0) {
                            // valide
                            isValid = true;

                            // Diskrepanz => PDF-Diagnosedaten ErrorCodes von PDFTron holen
                            NodeList nodeLst = doc.getElementsByTagName("Error");
                            String errorCodes = "";
                            for (int s = 0; s < nodeLst.getLength(); s++) {
                                Node dateiNode = nodeLst.item(s);
                                NamedNodeMap nodeMap = dateiNode.getAttributes();
                                Node errorNode = nodeMap.getNamedItem("Code");
                                String errorCode = errorNode.getNodeValue();
                                errorCodes = errorCodes + "  " + errorCode;
                            }

                            pdfTools = "<PDFTools><iCategory>0</iCategory><iError>0</iError></PDFTools>";
                            pdfTron = "<PDFTron><Code>" + errorCodes + "</Code></PDFTron>";
                            newPdfDiaTxt = "<Validation><ValFile>" + valDatei.getAbsolutePath()
                                    + "</ValFile><PdfaVL>" + level + "</PdfaVL>" + pdfTools + pdfTron
                                    + "</Validation>\n" + getTextResourceService().getText(MESSAGE_XML_DIAEND);
                            Util.pdfDia(newPdfDiaTxt, pdfDia);
                            Util.amp(pdfDia);

                        } else {
                            // invalid
                            isValid = false;
                        }
                    } else {
                        // keine duale Validierung -> invalid
                        isValid = false;
                    }
                }

            } catch (Exception e) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                        + getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage()));
                return false;
            }
        } else {
            // TODO: Erledigt Start mit PDFTools
            // zuerst mit PDFTools und danach ggf mit PDFTron

            if (docPdf.open(valDatei.getAbsolutePath(), "", NativeLibrary.COMPLIANCE.ePDFUnk)) {
                // PDF Konnte geffnet werden
            } else {
                if (docPdf.getErrorCode() == NativeLibrary.ERRORCODE.PDF_E_PASSWORD) {
                    getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                            + getTextResourceService().getText(ERROR_XML_A_PDFTOOLS_ENCRYPTED));
                    return false;
                } else {
                    getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                            + getTextResourceService().getText(ERROR_XML_A_PDFTOOLS_DAMAGED));
                    return false;
                }
            }

            /* ePDFA1a 5122 ePDFA1b 5121 ePDFA2a 5891 ePDFA2b 5889 ePDFA2u 5890 */
            if (level.contentEquals("1A")) {
                if (docPdf.open(valDatei.getAbsolutePath(), "", 5122)) {
                    docPdf.validate();
                }
            } else if (level.contentEquals("1B")) {
                if (docPdf.open(valDatei.getAbsolutePath(), "", 5121)) {
                    docPdf.validate();
                }
            } else if (level.contentEquals("2A")) {
                if (docPdf.open(valDatei.getAbsolutePath(), "", 5891)) {
                    docPdf.validate();
                }
            } else if (level.contentEquals("2B")) {
                if (docPdf.open(valDatei.getAbsolutePath(), "", 5889)) {
                    docPdf.validate();
                }
            } else if (level.contentEquals("2U")) {
                if (docPdf.open(valDatei.getAbsolutePath(), "", 5890)) {
                    docPdf.validate();
                }
            } else {
                // Validierung nach 2b
                level = "2B";
                if (docPdf.open(valDatei.getAbsolutePath(), "", 5889)) {
                    docPdf.validate();
                }
            }

            docPdf.setStopOnError(false);
            docPdf.setReportingLevel(2);

            // Error Category
            iCategory = docPdf.getCategories();
            /* die Zahl kann auch eine Summe von Kategorien sein z.B. 6144=2048+4096 -> getCategoryText
             * gibt nur die erste Kategorie heraus (z.B. 2048) */

            int success = 0;

            PdfError err = docPdf.getFirstError();
            PdfError err1 = docPdf.getFirstError();

            int iError = 0;
            while (err != null) {
                iError = err1.getErrorCode();
                success = success + 1;
                // Get next error
                err = docPdf.getNextError();
            }

            if (success == 0 && iCategory == 0) {
                // valide
                isValid = true;
            } else {
                if (dual) {
                    // duale Validierung
                    File report;
                    Document doc = null;

                    try {
                        // Pfad zum Programm Pdftron
                        File pdftronExe = new File(pathToPdftronExe);
                        File output = directoryOfLogfile;
                        String pathToPdftronOutput = output.getAbsolutePath();
                        StringBuffer command = new StringBuffer(pdftronExe + " ");
                        command.append("-l " + level);
                        command.append(" -o ");
                        command.append("\"");
                        command.append(output.getAbsolutePath());
                        command.append("\"");
                        command.append(" ");
                        command.append("\"");
                        command.append(valDatei.getAbsolutePath());
                        command.append("\"");

                        Process proc = null;
                        Runtime rt = null;

                        try {
                            /* Der Name des generierten Reports lautet per default report.xml und es scheint
                             * keine Mglichkeit zu geben, dies zu bersteuern. */
                            report = new File(pathToPdftronOutput, "report.xml");

                            // falls das File bereits existiert, z.B. von einemvorhergehenden Durchlauf, lschen
                            // wir es
                            if (report.exists()) {
                                report.delete();
                            }

                            Util.switchOffConsole();

                            rt = Runtime.getRuntime();
                            proc = rt.exec(command.toString().split(" "));
                            // .split(" ") ist notwendig wenn in einem Pfad ein Doppelleerschlag vorhanden ist!

                            // Fehleroutput holen
                            StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream(), "ERROR");

                            // Output holen
                            StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), "OUTPUT");

                            // Threads starten
                            errorGobbler.start();
                            outputGobbler.start();

                            // Warte, bis wget fertig ist
                            proc.waitFor();

                            Util.switchOnConsole();
                        } catch (Exception e) {
                            getMessageService()
                                    .logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                                            + getTextResourceService().getText(ERROR_XML_A_PDFA_SERVICEFAILED,
                                                    e.getMessage()));
                            return false;
                        } finally {
                            if (proc != null) {
                                closeQuietly(proc.getOutputStream());
                                closeQuietly(proc.getInputStream());
                                closeQuietly(proc.getErrorStream());
                            }
                        }
                        // Ende PDFTRON direkt auszulsen

                        String pathToPdftronReport = report.getAbsolutePath();
                        BufferedInputStream bis = new BufferedInputStream(
                                new FileInputStream(pathToPdftronReport));
                        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                        DocumentBuilder db = dbf.newDocumentBuilder();
                        doc = db.parse(bis);
                        doc.normalize();

                        Integer passCount = new Integer(0);
                        NodeList nodeLstI = doc.getElementsByTagName("Pass");

                        // Valide pdfa-Dokumente enthalten "<Validation> <Pass FileName..." Anzahl pass =
                        // anzahl Valider pdfa
                        for (int s = 0; s < nodeLstI.getLength(); s++) {
                            passCount = passCount + 1;
                            // Valide PDFA-Datei Module A-J sind Valid
                            isValid = true;

                            // Diskrepanz => PDF-Diagnosedaten
                            pdfTools = "<PDFTools><iCategory>" + iCategory + "</iCategory><iError>" + iError
                                    + "</iError></PDFTools>";
                            pdfTron = "<PDFTron><Code>Pass</Code></PDFTron>";
                            newPdfDiaTxt = "<Validation><ValFile>" + valDatei.getAbsolutePath()
                                    + "</ValFile><PdfaVL>" + level + "</PdfaVL>" + pdfTools + pdfTron
                                    + "</Validation>\n" + getTextResourceService().getText(MESSAGE_XML_DIAEND);
                            Util.pdfDia(newPdfDiaTxt, pdfDia);
                            Util.amp(pdfDia);

                        }
                        if (passCount == 0) {
                            // Invalide PDFA-Datei (doppelt besttigt)
                            isValid = false;
                        }

                    } catch (Exception e) {
                        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                                + getTextResourceService().getText(ERROR_XML_A_PDFA_SERVICEFAILED,
                                        e.getMessage()));
                        return false;
                    }
                } else {
                    // keine duale Validierung -> invalid
                    isValid = false;
                }
            }
        }

        // TODO: Erledigt: Fehler Auswertung

        if (!isValid) {
            // Invalide PDFA-Datei

            boolean exponent0 = false;
            boolean exponent1 = false;
            boolean exponent2 = false;
            boolean exponent3 = false;
            boolean exponent4 = false;
            boolean exponent5 = false;
            boolean exponent6 = false;
            boolean exponent7 = false;
            boolean exponent8 = false;
            boolean exponent9 = false;
            boolean exponent10 = false;
            boolean exponent11 = false;
            boolean exponent12 = false;
            boolean exponent13 = false;
            boolean exponent14 = false;
            boolean exponent15 = false;
            boolean exponent16 = false;
            boolean exponent17 = false;
            boolean exponent18 = false;

            int iExp0 = (int) Math.pow(2, 0);
            int iExp1 = (int) Math.pow(2, 1);
            int iExp2 = (int) Math.pow(2, 2);
            int iExp3 = (int) Math.pow(2, 3);
            int iExp4 = (int) Math.pow(2, 4);
            int iExp5 = (int) Math.pow(2, 5);
            int iExp6 = (int) Math.pow(2, 6);
            int iExp7 = (int) Math.pow(2, 7);
            int iExp8 = (int) Math.pow(2, 8);
            int iExp9 = (int) Math.pow(2, 9);
            int iExp10 = (int) Math.pow(2, 10);
            int iExp11 = (int) Math.pow(2, 11);
            int iExp12 = (int) Math.pow(2, 12);
            int iExp13 = (int) Math.pow(2, 13);
            int iExp14 = (int) Math.pow(2, 14);
            int iExp15 = (int) Math.pow(2, 15);
            int iExp16 = (int) Math.pow(2, 16);
            int iExp17 = (int) Math.pow(2, 17);
            int iExp18 = (int) Math.pow(2, 18);

            if (producerFirstValidator.contentEquals("PDFTools") || dual) {
                // Invalide Kategorien von PDF-Tools
                if (iCategory >= iExp18) {
                    exponent18 = true;
                    iCategory = iCategory - iExp18;
                }
                if (iCategory >= iExp17) {
                    exponent17 = true;
                    iCategory = iCategory - iExp17;
                }
                if (iCategory >= iExp16) {
                    exponent16 = true;
                    iCategory = iCategory - iExp16;
                }
                if (iCategory >= iExp15) {
                    exponent15 = true;
                    iCategory = iCategory - iExp15;
                }
                if (iCategory >= iExp14) {
                    exponent14 = true;
                    iCategory = iCategory - iExp14;
                }
                if (iCategory >= iExp13) {
                    exponent13 = true;
                    iCategory = iCategory - iExp13;
                }
                if (iCategory >= iExp12) {
                    exponent12 = true;
                    iCategory = iCategory - iExp12;
                }
                if (iCategory >= iExp11) {
                    exponent11 = true;
                    iCategory = iCategory - iExp11;
                }
                if (iCategory >= iExp10) {
                    exponent10 = true;
                    iCategory = iCategory - iExp10;
                }
                if (iCategory >= iExp9) {
                    exponent9 = true;
                    iCategory = iCategory - iExp9;
                }
                if (iCategory >= iExp8) {
                    exponent8 = true;
                    iCategory = iCategory - iExp8;
                }
                if (iCategory >= iExp7) {
                    exponent7 = true;
                    iCategory = iCategory - iExp7;
                }
                if (iCategory >= iExp6) {
                    exponent6 = true;
                    iCategory = iCategory - iExp6;
                }
                if (iCategory >= iExp5) {
                    exponent5 = true;
                    iCategory = iCategory - iExp5;
                }
                if (iCategory >= iExp4) {
                    exponent4 = true;
                    iCategory = iCategory - iExp4;
                }
                if (iCategory >= iExp3) {
                    exponent3 = true;
                    iCategory = iCategory - iExp3;
                }
                if (iCategory >= iExp2) {
                    exponent2 = true;
                    iCategory = iCategory - iExp2;
                }
                if (iCategory >= iExp1) {
                    exponent1 = true;
                    iCategory = iCategory - iExp1;
                }
                if (iCategory >= iExp0) {
                    exponent0 = true;
                    iCategory = iCategory - iExp0;
                }
            } else {
                iCategory = 0;
            }

            File report = new File(directoryOfLogfile.getAbsolutePath(), "report.xml");
            Document doc = null;

            if (producerFirstValidator.contentEquals("PDFTron") || dual) {
                // aus dem Output von Pdftron die Fehlercodes extrahieren und bersetzen

                String pathToPdftronReport = report.getAbsolutePath();
                BufferedInputStream bis = new BufferedInputStream(new FileInputStream(pathToPdftronReport));
                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                DocumentBuilder db = dbf.newDocumentBuilder();
                doc = db.parse(bis);
                doc.normalize();

                // Bsp. fr einen Error Code: <Error Code="e_PDFA173" die erste Ziffer nach e_PDFA ist der
                // Error Code.
            }
            /** Modul A **/
            if (exponent1) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                        + getTextResourceService().getText(ERROR_XML_AI_1, "iCategory_1"));
            }
            if (exponent2) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                        + getTextResourceService().getText(ERROR_XML_AI_2, "iCategory_2"));
            }
            if (producerFirstValidator.contentEquals("PDFTron") || dual) {
                // aus dem Output von Pdftron die Fehlercodes extrahieren und bersetzen

                String errorDigitA = "Fehler";

                NodeList nodeLst = doc.getElementsByTagName("Error");
                /* Bsp. fr einen Error Code: <Error Code="e_PDFA173" die erste Ziffer nach e_PDFA ist der
                 * Error Code. */
                for (int s = 0; s < nodeLst.getLength(); s++) {
                    Node dateiNode = nodeLst.item(s);
                    NamedNodeMap nodeMap = dateiNode.getAttributes();
                    Node errorNode = nodeMap.getNamedItem("Code");
                    String errorCode = errorNode.getNodeValue();
                    String errorCodeMsg = "error.xml.ai." + errorCode.substring(2);
                    Node errorNodeM = nodeMap.getNamedItem("Message");
                    String errorMessage = errorNodeM.getNodeValue();
                    errorDigitA = errorCode.substring(6, 7);

                    // der Error Code kann auch "Unknown" sein, dieser wird in den Code "0" bersetzt
                    if (errorDigitA.equals("U")) {
                        errorDigitA = "0";
                    }
                    if (errorDigitA.equals("n")) {
                        errorDigitA = "0";
                    }
                    try {
                        if (errorDigitA.equals("0")) {

                            // Allgemeiner Fehler -> A
                            isValid = false;
                            getMessageService()
                                    .logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                                            + getTextResourceService().getText(errorCodeMsg, errorCode));
                        }
                    } catch (Exception e) {
                        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                                + getTextResourceService().getText(ERROR_XML_AI_TRANSLATE, errorCode,
                                        errorMessage));
                    }
                }
                if (errorDigitA.equals("Fehler")) {
                    // Fehler bei der Initialisierung Passierte bei einem Leerschlag im Namen
                    isValid = false;
                    getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                            + getTextResourceService().getText(ERROR_XML_A_PDFA_INIT));
                    return false;
                }
            }

            /** Modul B **/
            if (exponent0) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_B_PDFA)
                        + getTextResourceService().getText(ERROR_XML_AI_0, "iCategory_0"));
            }
            if (exponent7) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_B_PDFA)
                        + getTextResourceService().getText(ERROR_XML_AI_7, "iCategory_7"));
            }
            if (exponent18) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_B_PDFA)
                        + getTextResourceService().getText(ERROR_XML_AI_18, "iCategory_18"));
            }
            if (producerFirstValidator.contentEquals("PDFTron") || dual) {
                // Analog Modul A
                NodeList nodeLst = doc.getElementsByTagName("Error");
                for (int s = 0; s < nodeLst.getLength(); s++) {
                    Node dateiNode = nodeLst.item(s);
                    NamedNodeMap nodeMap = dateiNode.getAttributes();
                    Node errorNode = nodeMap.getNamedItem("Code");
                    String errorCode = errorNode.getNodeValue();
                    String errorCodeMsg = "error.xml.ai." + errorCode.substring(2);
                    Node errorNodeM = nodeMap.getNamedItem("Message");
                    String errorMessage = errorNodeM.getNodeValue();
                    String errorDigit = errorCode.substring(6, 7);
                    try {
                        if (errorDigit.equals("1")) {
                            // Struktur Fehler -> B
                            isValid = false;
                            getMessageService()
                                    .logError(getTextResourceService().getText(MESSAGE_XML_MODUL_B_PDFA)
                                            + getTextResourceService().getText(errorCodeMsg, errorCode));
                        }
                    } catch (Exception e) {
                        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_B_PDFA)
                                + getTextResourceService().getText(ERROR_XML_AI_TRANSLATE, errorCode,
                                        errorMessage));
                    }
                }
            }

            /** Modul C **/
            if (exponent3) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_C_PDFA)
                        + getTextResourceService().getText(ERROR_XML_AI_3, "iCategory_3"));
            }
            if (exponent4) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_C_PDFA)
                        + getTextResourceService().getText(ERROR_XML_AI_4, "iCategory_4"));
            }
            if (exponent5) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_C_PDFA)
                        + getTextResourceService().getText(ERROR_XML_AI_5, "iCategory_5"));
            }
            if (exponent6) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_C_PDFA)
                        + getTextResourceService().getText(ERROR_XML_AI_6, "iCategory_6"));
            }
            if (producerFirstValidator.contentEquals("PDFTron") || dual) {
                // Analog Modul A
                NodeList nodeLst = doc.getElementsByTagName("Error");
                for (int s = 0; s < nodeLst.getLength(); s++) {
                    Node dateiNode = nodeLst.item(s);
                    NamedNodeMap nodeMap = dateiNode.getAttributes();
                    Node errorNode = nodeMap.getNamedItem("Code");
                    String errorCode = errorNode.getNodeValue();
                    String errorCodeMsg = "error.xml.ai." + errorCode.substring(2);
                    Node errorNodeM = nodeMap.getNamedItem("Message");
                    String errorMessage = errorNodeM.getNodeValue();
                    String errorDigit = errorCode.substring(6, 7);
                    try {
                        if (errorDigit.equals("2")) {
                            // Grafik Fehler -> C
                            isValid = false;
                            getMessageService()
                                    .logError(getTextResourceService().getText(MESSAGE_XML_MODUL_C_PDFA)
                                            + getTextResourceService().getText(errorCodeMsg, errorCode));
                        }
                    } catch (Exception e) {
                        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_C_PDFA)
                                + getTextResourceService().getText(ERROR_XML_AI_TRANSLATE, errorCode,
                                        errorMessage));
                    }
                }
            }
            /** Modul D **/
            if (exponent8) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_D_PDFA)
                        + getTextResourceService().getText(ERROR_XML_AI_8, "iCategory_8"));
            }
            if (exponent9) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_D_PDFA)
                        + getTextResourceService().getText(ERROR_XML_AI_9, "iCategory_9"));
            }
            if (producerFirstValidator.contentEquals("PDFTron") || dual) {
                // Analog Modul A
                NodeList nodeLst = doc.getElementsByTagName("Error");
                for (int s = 0; s < nodeLst.getLength(); s++) {
                    Node dateiNode = nodeLst.item(s);
                    NamedNodeMap nodeMap = dateiNode.getAttributes();
                    Node errorNode = nodeMap.getNamedItem("Code");
                    String errorCode = errorNode.getNodeValue();
                    String errorCodeMsg = "error.xml.ai." + errorCode.substring(2);
                    Node errorNodeM = nodeMap.getNamedItem("Message");
                    String errorMessage = errorNodeM.getNodeValue();
                    String errorDigit = errorCode.substring(6, 7);
                    try {
                        if (errorDigit.equals("3")) {
                            // Schrift Fehler -> D
                            isValid = false;
                            getMessageService()
                                    .logError(getTextResourceService().getText(MESSAGE_XML_MODUL_D_PDFA)
                                            + getTextResourceService().getText(errorCodeMsg, errorCode));
                        }
                    } catch (Exception e) {
                        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_D_PDFA)
                                + getTextResourceService().getText(ERROR_XML_AI_TRANSLATE, errorCode,
                                        errorMessage));
                    }
                }
            }
            /** Modul E **/
            if (exponent10) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_E_PDFA)
                        + getTextResourceService().getText(ERROR_XML_AI_10, "iCategory_10"));
            }
            if (producerFirstValidator.contentEquals("PDFTron") || dual) {
                // Analog Modul A
                NodeList nodeLst = doc.getElementsByTagName("Error");
                for (int s = 0; s < nodeLst.getLength(); s++) {
                    Node dateiNode = nodeLst.item(s);
                    NamedNodeMap nodeMap = dateiNode.getAttributes();
                    Node errorNode = nodeMap.getNamedItem("Code");
                    String errorCode = errorNode.getNodeValue();
                    String errorCodeMsg = "error.xml.ai." + errorCode.substring(2);
                    Node errorNodeM = nodeMap.getNamedItem("Message");
                    String errorMessage = errorNodeM.getNodeValue();
                    String errorDigit = errorCode.substring(6, 7);
                    try {
                        if (errorDigit.equals("4")) {
                            // Transparenz Fehler -> E
                            isValid = false;
                            getMessageService()
                                    .logError(getTextResourceService().getText(MESSAGE_XML_MODUL_E_PDFA)
                                            + getTextResourceService().getText(errorCodeMsg, errorCode));
                        }
                    } catch (Exception e) {
                        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_E_PDFA)
                                + getTextResourceService().getText(ERROR_XML_AI_TRANSLATE, errorCode,
                                        errorMessage));
                    }
                }
            }
            /** Modul F **/
            if (exponent11) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_F_PDFA)
                        + getTextResourceService().getText(ERROR_XML_AI_11, "iCategory_11"));
            }
            if (exponent12) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_F_PDFA)
                        + getTextResourceService().getText(ERROR_XML_AI_12, "iCategory_12"));
            }
            if (exponent13) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_F_PDFA)
                        + getTextResourceService().getText(ERROR_XML_AI_13, "iCategory_13"));
            }
            if (exponent14) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_F_PDFA)
                        + getTextResourceService().getText(ERROR_XML_AI_14, "iCategory_14"));
            }
            if (producerFirstValidator.contentEquals("PDFTron") || dual) {
                // Analog Modul A
                NodeList nodeLst = doc.getElementsByTagName("Error");
                for (int s = 0; s < nodeLst.getLength(); s++) {
                    Node dateiNode = nodeLst.item(s);
                    NamedNodeMap nodeMap = dateiNode.getAttributes();
                    Node errorNode = nodeMap.getNamedItem("Code");
                    String errorCode = errorNode.getNodeValue();
                    String errorCodeMsg = "error.xml.ai." + errorCode.substring(2);
                    Node errorNodeM = nodeMap.getNamedItem("Message");
                    String errorMessage = errorNodeM.getNodeValue();
                    String errorDigit = errorCode.substring(6, 7);
                    try {
                        if (errorDigit.equals("5")) {
                            // Annotations Fehler -> F
                            isValid = false;
                            getMessageService()
                                    .logError(getTextResourceService().getText(MESSAGE_XML_MODUL_F_PDFA)
                                            + getTextResourceService().getText(errorCodeMsg, errorCode));
                        }
                    } catch (Exception e) {
                        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_F_PDFA)
                                + getTextResourceService().getText(ERROR_XML_AI_TRANSLATE, errorCode,
                                        errorMessage));
                    }
                }
            }
            /** Modul G **/
            if (exponent15) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_G_PDFA)
                        + getTextResourceService().getText(ERROR_XML_AI_15, "iCategory_15"));
            }
            if (producerFirstValidator.contentEquals("PDFTron") || dual) {
                // Analog Modul A
                NodeList nodeLst = doc.getElementsByTagName("Error");
                for (int s = 0; s < nodeLst.getLength(); s++) {
                    Node dateiNode = nodeLst.item(s);
                    NamedNodeMap nodeMap = dateiNode.getAttributes();
                    Node errorNode = nodeMap.getNamedItem("Code");
                    String errorCode = errorNode.getNodeValue();
                    String errorCodeMsg = "error.xml.ai." + errorCode.substring(2);
                    Node errorNodeM = nodeMap.getNamedItem("Message");
                    String errorMessage = errorNodeM.getNodeValue();
                    String errorDigit = errorCode.substring(6, 7);
                    try {
                        if (errorDigit.equals("6")) {
                            // Aktions Fehler -> G
                            isValid = false;
                            getMessageService()
                                    .logError(getTextResourceService().getText(MESSAGE_XML_MODUL_G_PDFA)
                                            + getTextResourceService().getText(errorCodeMsg, errorCode));
                        }
                        // neu sind die Interaktionen (J) bei den Aktionen (G)
                        if (errorDigit.equals("9")) {
                            // Interaktions Fehler -> J
                            isValid = false;
                            getMessageService()
                                    .logError(getTextResourceService().getText(MESSAGE_XML_MODUL_G_PDFA)
                                            + getTextResourceService().getText(errorCodeMsg, errorCode));
                        }
                    } catch (Exception e) {
                        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_G_PDFA)
                                + getTextResourceService().getText(ERROR_XML_AI_TRANSLATE, errorCode,
                                        errorMessage));
                    }
                }
            }
            /** Modul H **/
            if (exponent16) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_H_PDFA)
                        + getTextResourceService().getText(ERROR_XML_AI_16, "iCategory_16"));
            }
            if (producerFirstValidator.contentEquals("PDFTron") || dual) {
                // Analog Modul A
                NodeList nodeLst = doc.getElementsByTagName("Error");
                for (int s = 0; s < nodeLst.getLength(); s++) {
                    Node dateiNode = nodeLst.item(s);
                    NamedNodeMap nodeMap = dateiNode.getAttributes();
                    Node errorNode = nodeMap.getNamedItem("Code");
                    String errorCode = errorNode.getNodeValue();
                    String errorCodeMsg = "error.xml.ai." + errorCode.substring(2);
                    Node errorNodeM = nodeMap.getNamedItem("Message");
                    String errorMessage = errorNodeM.getNodeValue();
                    String errorDigit = errorCode.substring(6, 7);
                    try {
                        if (errorDigit.equals("7")) {
                            // Metadaten Fehler -> H
                            isValid = false;
                            getMessageService()
                                    .logError(getTextResourceService().getText(MESSAGE_XML_MODUL_H_PDFA)
                                            + getTextResourceService().getText(errorCodeMsg, errorCode));
                        }
                    } catch (Exception e) {
                        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_H_PDFA)
                                + getTextResourceService().getText(ERROR_XML_AI_TRANSLATE, errorCode,
                                        errorMessage));
                    }
                }
            }
            /** Modul I **/
            if (exponent17) {
                getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_I_PDFA)
                        + getTextResourceService().getText(ERROR_XML_AI_17, "iCategory_17"));
            }
            if (producerFirstValidator.contentEquals("PDFTron") || dual) {
                // Analog Modul A
                NodeList nodeLst = doc.getElementsByTagName("Error");
                for (int s = 0; s < nodeLst.getLength(); s++) {
                    Node dateiNode = nodeLst.item(s);
                    NamedNodeMap nodeMap = dateiNode.getAttributes();
                    Node errorNode = nodeMap.getNamedItem("Code");
                    String errorCode = errorNode.getNodeValue();
                    String errorCodeMsg = "error.xml.ai." + errorCode.substring(2);
                    Node errorNodeM = nodeMap.getNamedItem("Message");
                    String errorMessage = errorNodeM.getNodeValue();
                    String errorDigit = errorCode.substring(6, 7);
                    try {
                        if (errorDigit.equals("8")) {
                            // Zugnglichkeit Fehler -> I
                            isValid = false;
                            getMessageService()
                                    .logError(getTextResourceService().getText(MESSAGE_XML_MODUL_I_PDFA)
                                            + getTextResourceService().getText(errorCodeMsg, errorCode));
                        }
                    } catch (Exception e) {
                        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_I_PDFA)
                                + getTextResourceService().getText(ERROR_XML_AI_TRANSLATE, errorCode,
                                        errorMessage));
                    }
                }
            }
            /** Modul J **/
            // neu sind die Interaktionen (J) bei den Aktionen (G)

            docPdf.close();

            // Destroy the object
            docPdf.destroyObject();

        }
    } catch (Exception e) {
        getMessageService().logError(getTextResourceService().getText(MESSAGE_XML_MODUL_A_PDFA)
                + getTextResourceService().getText(ERROR_XML_UNKNOWN, e.getMessage()));
    }
    return isValid;
}

From source file:de.intranda.goobi.plugins.CSICMixedImport.java

private String getActualProjectName(String name) {
    if (name.contentEquals("0006_PMSC_GR_EEA")) {
        return "0006_PMSC";
    }/*from w w w  .ja  v  a 2 s  .c o  m*/
    return name;
}

From source file:org.okinawaopenlabs.orientdb.client.DaoImpl.java

@Override
public Map<String, Object> getNodeInfoFromDeviceName(Connection conn, String deviceName) throws SQLException {
    final String fname = "getNodeInfoFromDeviceName";
    if (logger.isTraceEnabled()) {
        logger.trace(String.format("%s(conn=%s, deviceName=%s) - start", fname, conn, deviceName));
    }/*from ww w .  java2s. c  o m*/
    Map<String, Object> map = null;
    try {
        List<Map<String, Object>> infoMapList = this.getNodeInfoList(conn);

        for (Map<String, Object> infoMap : infoMapList) {
            if (deviceName.contentEquals((String) infoMap.get("name"))) {
                return infoMap;
            }
        }

        // not found.
        return null;
    } catch (Exception e) {
        throw new SQLException(e.getMessage());
    } finally {
        if (logger.isTraceEnabled()) {
            logger.trace(String.format("%s(ret=%s) - end", fname, map));
        }
    }
}

From source file:com.dns.api.compiletime.ManagementAPI.java

/**
 * Create a new XFR configuration for the named domain/sub
 * @param domain The name of the domain to create an XFR configuration for
 * @param host This host indicates the "sub" domain that the XFR will work on, set as NULL to create XFR for the root of the domain (Can be null)
 * @param master The IP address of the master server which we will poll to get updates and we will receive NOTIFY packets from
 * @param port The UDP/TCP port on which to perform the XFR transfer with the master, set to NULL to use the default of 53 (Can be null)
 * @param refresh_interval The initial refresh interval with which to perform zone transfers, set to NULL to use the default of 3600 seconds (Can be null)
 * @return A {@link JSONObject} containing the JSON response from the API server
 *///from www . ja  va 2 s .c  o  m
public JSONObject createXfrZone(String domain, String host, String master, Integer port,
        Integer refresh_interval) {

    StringBuilder uriBuilder = new StringBuilder("/api/createXfrZone/?");
    log.debug("Setting API Token");
    uriBuilder.append("AUTH_TOKEN=" + apiToken);

    if (domain == null) {
        JSONObject error = new JSONObject();
        try {
            JSONObject meta = new JSONObject();
            meta.put("success", 0);
            meta.put("error", "Required argument 'domain' is NULL");
            error.put("meta", meta);
        } catch (JSONException e) {
            log.error("An error was encountered while attempting to return an error message.", e);
        }
        return error;
    } else {
        if (domain.length() < 3) {
            try {
                JSONObject error = new JSONObject();
                JSONObject meta = new JSONObject();
                meta.put("success", 0);
                meta.put("error", "The 'domain' argument is too small to be a valid domain.");
                error.put("meta", error);
                return error;
            } catch (JSONException e) {
                log.error("An error was encountered while attempting to return an error message.", e);
            }
        } else {
            uriBuilder.append("&domain=").append(domain);
        }
    }

    if (host != null) {
        if (!host.contentEquals("") && !host.toLowerCase().contentEquals("null")) {
            uriBuilder.append("&host=").append(host);
        }
    }

    if (master != null) {
        try {
            InetAddress.getByName(master);
            uriBuilder.append("&master=").append(master);
        } catch (UnknownHostException uhe) {
            try {
                JSONObject error = new JSONObject();
                JSONObject meta = new JSONObject();
                meta.put("success", 0);
                meta.put("error",
                        "The value '" + master + "' for the 'master' server is not a valid IP address.");
                error.put("meta", meta);
                return error;
            } catch (JSONException jsone) {
                log.error("An error was encountered while attempting to return an error message.", jsone);
            }
        }
    } else {
        try {
            JSONObject error = new JSONObject();
            JSONObject meta = new JSONObject();
            meta.put("success", 0);
            meta.put("error", "The required argument 'master' is NULL");
            error.put("meta", error);
            return error;
        } catch (JSONException jsone) {
            log.error("An error was encountered while attempting to return an error message.", jsone);
        }
    }

    if (port != null) {
        uriBuilder.append("&port=").append(port);
    }

    if (refresh_interval != null) {
        uriBuilder.append("&refresh_interval=").append(refresh_interval);
    }

    return makeHttpRequest(uriBuilder.toString());
}

From source file:net.sf.xfd.provider.ProviderBase.java

private String[] guessTypes(OS os, String filepath) {
    if ("/".equals(filepath)) {
        return new String[] { MIME_TYPE_DIR, ALT_DIR_MIME };
    }// www  .  j  a  v a  2 s  . co m

    final ObjectSet<String> mimeCandidates = new ObjectHashSet<>();

    int fd = 0;

    try {
        final Stat s = new Stat();

        final String filename = extractName(filepath);

        @DirFd
        int parentFd = os.opendir(extractParent(filepath));

        try {
            try {
                os.fstatat(parentFd, filename, s, 0);
            } catch (IOException ioe) {
                LogUtil.logCautiously("Failed to invoke stat() on " + filename, ioe);
            }

            FsType origType = null;

            if (s.type != null) {
                origType = s.type;

                switch (s.type) {
                case DIRECTORY:
                    return new String[] { MIME_TYPE_DIR, ALT_DIR_MIME };
                case CHAR_DEV:
                    return new String[] { CHAR_DEV_MIME };
                case NAMED_PIPE:
                    mimeCandidates.add(FIFO_MIME);
                    break;
                case DOMAIN_SOCKET:
                    mimeCandidates.add(SOCK_MIME);
                    break;
                case BLOCK_DEV:
                    mimeCandidates.add(BLOCK_MIME);
                case FILE:
                    try {
                        fd = os.openat(parentFd, filename, OS.O_RDONLY, 0);
                    } catch (IOException ioe) {
                        LogUtil.logCautiously("Failed to invoke open() on " + filename, ioe);
                    }
                default:
                }
            }

            os.fstatat(parentFd, filename, s, OS.AT_SYMLINK_NOFOLLOW);

            if (s.type == FsType.LINK) {
                try {
                    CharSequence resolved = os.readlinkat(parentFd, filename);

                    if (!filepath.contentEquals(resolved)) {
                        addNameCandidates(resolved, mimeCandidates);
                    }

                    if (origType == FsType.FILE) {
                        fd = os.openat(parentFd, resolved, OS.O_RDONLY, 0);
                    }
                } catch (IOException e) {
                    LogUtil.logCautiously("Error during path resolution", e);
                }
            }
        } finally {
            os.dispose(parentFd);
        }

        if (fd > 0) {
            final String contentInfo = magic.guessMime(fd);

            if (!TextUtils.isEmpty(contentInfo) && !DEFAULT_MIME.equals(contentInfo)) {
                mimeCandidates.add(contentInfo);
            }
        }
    } catch (IOException e) {
        LogUtil.logCautiously("Error during guessing mime type", e);
    } finally {
        if (fd > 0) {
            os.dispose(fd);
        }
    }

    addNameCandidates(filepath, mimeCandidates);

    return mimeCandidates.toArray(String.class);
}

From source file:uni.oulu.mentor.TeacherVisionActivity.java

public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    SharedPreferences.Editor editor = sharedPreferences.edit();
    if (key.contentEquals("courseNamePref")) {
        String courseName = sharedPreferences.getString("courseNamePref", "");
        courseNamePref.setSummary("Value is " + courseName);
        editor.putString(key, courseName);
    } else if (key.contentEquals("lectureTopicPref")) {
        String lectureTopic = sharedPreferences.getString("lectureTopicPref", "");
        lectureTopicPref.setSummary("Value is " + lectureTopic);
        editor.putString(key, lectureTopic);
    } else if (key.contentEquals("beep")) {
        beepOn = sharedPreferences.getBoolean(key, Boolean.parseBoolean("true"));
        if (beepOn)
            beepPref.setSummary(beepPref.getSummaryOn());
        else/*from www .  jav  a 2 s . com*/
            beepPref.setSummary(beepPref.getSummaryOff());
        editor.putBoolean(key, beepOn);
    } else if (key.contentEquals("notification")) {
        notificationOn = sharedPreferences.getBoolean(key, Boolean.parseBoolean("true"));
        if (notificationOn)
            notificationPref.setSummary(notificationPref.getSummaryOn());
        else
            notificationPref.setSummary(notificationPref.getSummaryOff());
        editor.putBoolean(key, notificationOn);
    } else if (key.contentEquals("alertThresholdPref")) {
        alertThreshold = Integer.parseInt(sharedPreferences.getString(key, "1"));
        alertThresholdPref.setSummary("Value is " + sharedPreferences.getString(key, "1"));
        //editor.putInt(key, alertThreshold);
        editor.putString(key, sharedPreferences.getString(key, "1"));
    } else if (key.contentEquals("timespanPref")) {
        timeSpan = Integer.parseInt(sharedPreferences.getString(key, "1"));
        timespanPref.setSummary("Value is " + sharedPreferences.getString(key, "1"));
        //editor.putInt(key, timeSpan);
        editor.putString(key, sharedPreferences.getString(key, "1"));
    } else if (key.contentEquals("flaretimePref")) {
        int xflareTime = Integer.parseInt(sharedPreferences.getString(key, "5"));
        flaretimePref.setSummary("Value is " + sharedPreferences.getString(key, "5"));
        oneObject.setFlareTime(xflareTime * 1000);
        twoObject.setFlareTime(xflareTime * 1000);
        threeObject.setFlareTime(xflareTime * 1000);
        //editor.putInt(key, xflareTime);
        editor.putString(key, sharedPreferences.getString(key, "5"));
    } else if (key.contentEquals("speedUpPref")) {
        speedUpColor = Integer.parseInt(sharedPreferences.getString(key, "1"));
        speedUpPref.setSummary("Value is " + sharedPreferences.getString(key, "1"));
        oneObject.setSpeedUpColor(speedUpColor);
        twoObject.setSpeedUpColor(speedUpColor);
        threeObject.setSpeedUpColor(speedUpColor);
        //editor.putInt(key, speedUpColor);
        editor.putString(key, sharedPreferences.getString(key, "1"));
    } else if (key.contentEquals("slowDownPref")) {
        slowDownColor = Integer.parseInt(sharedPreferences.getString(key, "3"));
        slowDownPref.setSummary("Value is " + sharedPreferences.getString(key, "3"));
        oneObject.setSlowDownColor(slowDownColor);
        twoObject.setSlowDownColor(slowDownColor);
        threeObject.setSlowDownColor(slowDownColor);
        //editor.putInt(key, slowDownColor);
        editor.putString(key, sharedPreferences.getString(key, "3"));
    } else if (key.contentEquals("moreExamplesPref")) {
        moreExamplesColor = Integer.parseInt(sharedPreferences.getString(key, "2"));
        moreExamplesPref.setSummary("Value is " + sharedPreferences.getString(key, "2"));
        oneObject.setMoreExamplesColor(moreExamplesColor);
        twoObject.setMoreExamplesColor(moreExamplesColor);
        threeObject.setMoreExamplesColor(moreExamplesColor);
        //editor.putInt(key, moreExamplesColor);
        editor.putString(key, sharedPreferences.getString(key, "2"));
    } else if (key.contentEquals("repeatPref")) {
        repeatColor = Integer.parseInt(sharedPreferences.getString(key, "4"));
        repeatPref.setSummary("Value is " + sharedPreferences.getString(key, "4"));
        oneObject.setRepeatColor(repeatColor);
        twoObject.setRepeatColor(repeatColor);
        threeObject.setRepeatColor(repeatColor);
        //editor.putInt(key, repeatColor);
        editor.putString(key, sharedPreferences.getString(key, "4"));
    } else if (key.contentEquals("questionPref")) {
        questionColor = Integer.parseInt(sharedPreferences.getString(key, "5"));
        questionPref.setSummary("Value is " + sharedPreferences.getString(key, "5"));
        oneObject.setQuestionColor(questionColor);
        twoObject.setQuestionColor(questionColor);
        threeObject.setQuestionColor(questionColor);
        //editor.putInt(key, questionColor);
        editor.putString(key, sharedPreferences.getString(key, "5"));
    } else if (key.contentEquals("answerPref")) {
        answerColor = Integer.parseInt(sharedPreferences.getString(key, "6"));
        answerPref.setSummary("Value is " + sharedPreferences.getString(key, "6"));
        oneObject.setAnswerColor(answerColor);
        twoObject.setAnswerColor(answerColor);
        threeObject.setAnswerColor(answerColor);
        //editor.putInt(key, answerColor);
        editor.putString(key, sharedPreferences.getString(key, "6"));
    }
    //editor.clear();
    editor.commit();
}

From source file:org.okinawaopenlabs.orientdb.client.DaoImpl.java

@Override
public String getDeviceNameFromDatapathId(Connection conn, String datapathId) throws SQLException {
    final String fname = "getDeviceNameFromDatapathId";
    if (logger.isTraceEnabled()) {
        logger.trace(String.format("%s(conn=%s, datapathId=%s) - start", fname, conn, datapathId));
    }//from  w w  w  .j a  v  a  2  s.c  o m
    String ret = null;
    try {
        //         List<Map<String, Object>> records = utilsJdbc.query(conn, SQL_GET_DEVICENAME_FROM_DATAPATHID,
        //                    new MapListHandler(), datapathId);
        //         if (records.size() <= 0) {
        //                throw new Exception(String.format(NOT_FOUND, datapathId));
        //         }
        //         ret = records.get(0).get("name").toString();
        //         return ret;
        List<Map<String, Object>> infoMapList = this.getNodeInfoList(conn);

        for (Map<String, Object> infoMap : infoMapList) {
            if (infoMap.containsKey("datapathId")) {
                if (datapathId.contentEquals((String) infoMap.get("datapathId"))) {
                    return (String) infoMap.get("name");
                }
            }
        }

        // not found.
        return null;
    } catch (Exception e) {
        throw new SQLException(e.getMessage());
    } finally {
        if (logger.isTraceEnabled()) {
            logger.trace(String.format("%s(ret=%s) - end", ret));
        }
    }
}

From source file:org.xbmc.kore.ui.BaseMediaActivity.java

private void updateNowPlayingPanel(PlayerType.PropertyValue getPropertiesResult,
        ListType.ItemsAll getItemResult) {
    String title;
    String poster;//from  w  ww.  j ava  2 s.  com
    String details = null;

    callbackHandler.removeCallbacks(hidePanelRunnable);

    // Only set state to collapsed if panel is currently hidden. This prevents collapsing
    // the panel when the user expanded the panel and started playing the item from a paused
    // state
    if (nowPlayingPanel.getPanelState() == SlidingUpPanelLayout.PanelState.HIDDEN) {
        nowPlayingPanel.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
    }

    nowPlayingPanel.setMediaProgress(getPropertiesResult.time, getPropertiesResult.totaltime);

    nowPlayingPanel.setPlayButton(getPropertiesResult.speed > 0);
    nowPlayingPanel.setShuffled(getPropertiesResult.shuffled);
    nowPlayingPanel.setRepeatMode(getPropertiesResult.repeat);
    nowPlayingPanel.setSpeed(getPropertiesResult.speed);

    switch (getItemResult.type) {
    case ListType.ItemsAll.TYPE_MOVIE:
        title = getItemResult.title;
        details = getItemResult.tagline;
        poster = TextUtils.isEmpty(getItemResult.thumbnail) ? getItemResult.fanart : getItemResult.thumbnail;
        break;
    case ListType.ItemsAll.TYPE_EPISODE:
        title = getItemResult.title;
        String seasonEpisode = String.format(getString(R.string.season_episode_abbrev), getItemResult.season,
                getItemResult.episode);
        details = String.format("%s | %s", getItemResult.showtitle, seasonEpisode);
        poster = TextUtils.isEmpty(getItemResult.art.poster) ? getItemResult.art.fanart
                : getItemResult.art.poster;
        break;
    case ListType.ItemsAll.TYPE_SONG:
        title = getItemResult.title;
        details = getItemResult.displayartist + " | " + getItemResult.album;
        poster = TextUtils.isEmpty(getItemResult.thumbnail) ? getItemResult.fanart : getItemResult.thumbnail;
        break;
    case ListType.ItemsAll.TYPE_MUSIC_VIDEO:
        title = getItemResult.title;
        details = Utils.listStringConcat(getItemResult.artist, ", ") + " | " + getItemResult.album;
        poster = TextUtils.isEmpty(getItemResult.thumbnail) ? getItemResult.fanart : getItemResult.thumbnail;
        break;
    case ListType.ItemsAll.TYPE_CHANNEL:
        title = getItemResult.label;
        details = getItemResult.title;
        poster = TextUtils.isEmpty(getItemResult.thumbnail) ? getItemResult.fanart : getItemResult.thumbnail;
        break;
    default:
        title = getItemResult.label;
        poster = TextUtils.isEmpty(getItemResult.thumbnail) ? getItemResult.fanart : getItemResult.thumbnail;
        break;
    }

    if (title.contentEquals(nowPlayingPanel.getTitle()))
        return; // Still showing same item as previous call

    nowPlayingPanel.setTitle(title);

    if (details != null) {
        nowPlayingPanel.setDetails(details);
    }

    if ((getItemResult.type.contentEquals(ListType.ItemsAll.TYPE_MUSIC_VIDEO))
            || (getItemResult.type.contentEquals(ListType.ItemsAll.TYPE_SONG))) {
        nowPlayingPanel.setNextPrevVisibility(View.VISIBLE);
    } else {
        nowPlayingPanel.setNextPrevVisibility(View.GONE);
    }

    Resources resources = getResources();
    int posterWidth = resources.getDimensionPixelOffset(R.dimen.now_playing_panel_art_width);
    int posterHeight = resources.getDimensionPixelOffset(R.dimen.now_playing_panel_height);

    // If not video, change aspect ration of poster to a square
    boolean isVideo = (getItemResult.type.equals(ListType.ItemsAll.TYPE_MOVIE))
            || (getItemResult.type.equals(ListType.ItemsAll.TYPE_EPISODE));

    nowPlayingPanel.setSquarePoster(!isVideo);

    UIUtils.loadImageWithCharacterAvatar(this, hostManager, poster, title, nowPlayingPanel.getPoster(),
            (isVideo) ? posterWidth : posterHeight, posterHeight);
}

From source file:com.eveningoutpost.dexdrip.Home.java

private void naturalLanguageRecognition(String allWords) {
    if (searchWords == null) {

        Toast.makeText(getApplicationContext(), "Word lexicon not loaded!", Toast.LENGTH_LONG).show();
        return;/*from  w ww.j  av  a 2  s . com*/
    }
    allWords = allWords.trim();
    allWords = allWords.replaceAll(":", "."); // fix real times
    allWords = allWords.replaceAll("(\\d)([a-zA-Z])", "$1 $2"); // fix like 22mm
    allWords = allWords.replaceAll("([0-9].[0-9])([0-9][0-9])", "$1 $2"); // fix multi number order like blood 3.622 grams
    allWords = allWords.toLowerCase();

    Log.d(TAG, "Processing speech input: " + allWords);

    if (allWords.contentEquals("delete last treatment") || allWords.contentEquals("cancel last treatment")
            || allWords.contentEquals("erase last treatment")) {
        Treatments.delete_last(true);
        updateCurrentBgInfo("delete last treatment");
    } else if ((allWords.contentEquals("delete all treatments"))
            || (allWords.contentEquals("delete all treatment"))) {
        Treatments.delete_all(true);
        updateCurrentBgInfo("delete all treatment");
    } else if (allWords.contentEquals("delete last calibration")
            || allWords.contentEquals("clear last calibration")) {
        Calibration.clearLastCalibration();
    } else if (allWords.contentEquals("force google reboot")) {
        SdcardImportExport.forceGMSreset();
    } else if (allWords.contentEquals("enable engineering mode")) {
        Home.setPreferencesBoolean("engineering_mode", true);
        JoH.static_toast(getApplicationContext(), "Engineering mode enabled - be careful", Toast.LENGTH_LONG);
    } else if (allWords.contentEquals("vehicle mode test")) {
        ActivityRecognizedService.spoofActivityRecogniser(mActivity, JoH.tsl() + "^" + 0);
        staticRefreshBGCharts();
    } else if (allWords.contentEquals("vehicle mode quit")) {
        ActivityRecognizedService.spoofActivityRecogniser(mActivity, JoH.tsl() + "^" + 3);
        staticRefreshBGCharts();
    } else if (allWords.contentEquals("vehicle mode walk")) {
        ActivityRecognizedService.spoofActivityRecogniser(mActivity, JoH.tsl() + "^" + 2);
        staticRefreshBGCharts();
    } else if (allWords.contentEquals("delete all glucose data")) {
        deleteAllBG(null);
        LibreAlarmReceiver.clearSensorStats();
    }

    if (allWords.contentEquals("clear battery warning")) {
        try {
            final Sensor sensor = Sensor.currentSensor();
            if (sensor != null) {
                sensor.latest_battery_level = 0;
                sensor.save();
            }
        } catch (Exception e) {
            // do nothing
        }
    }

    // reset parameters for new speech
    glucoseset = false;
    insulinset = false;
    carbsset = false;
    timeset = false;
    thisnumber = -1;
    thisword = "";

    String[] wordsArray = allWords.split(" ");
    for (int i = 0; i < wordsArray.length; i++) {
        // per word in input stream
        try {
            double thisdouble = Double.parseDouble(wordsArray[i]);
            thisnumber = thisdouble; // if no exception
            handleWordPair();
        } catch (NumberFormatException nfe) {
            // detection of number or not
            String result = classifyWord(wordsArray[i]);
            if (result != null)
                thisword = result;
            handleWordPair();
        }
    }
}