Package com.android.manifmerger.IMergerLog

Examples of com.android.manifmerger.IMergerLog.FileAndLine


            File[] libraryFiles,
            Map<String, String> injectAttributes,
            String packageOverride) {
        Document mainDoc = MergerXmlUtils.parseDocument(mainFile, mLog);
        if (mainDoc == null) {
            mLog.error(Severity.ERROR, new FileAndLine(mainFile.getAbsolutePath(), 0),
                    "Failed to read manifest file.");
            return false;
        }

        boolean success = process(mainDoc, libraryFiles, injectAttributes, packageOverride);

        if (!MergerXmlUtils.printXmlFile(mainDoc, outputFile, mLog)) {
            mLog.error(Severity.ERROR, new FileAndLine(outputFile.getAbsolutePath(), 0),
                    "Failed to write manifest file.");
            success = false;
        }

        return success;
View Full Code Here


            // We don't want the default handler which prints errors to stderr.
            builder.setErrorHandler(new ErrorHandler() {
                @Override
                public void warning(SAXParseException e) {
                    log.error(Severity.WARNING,
                            new FileAndLine(xmlFile.getAbsolutePath(), 0),
                            "Warning when parsing: %1$s",
                            e.toString());
                }
                @Override
                public void fatalError(SAXParseException e) {
                    log.error(Severity.ERROR,
                            new FileAndLine(xmlFile.getAbsolutePath(), 0),
                            "Fatal error when parsing: %1$s",
                            xmlFile.getName(), e.toString());
                }
                @Override
                public void error(SAXParseException e) {
                    log.error(Severity.ERROR,
                            new FileAndLine(xmlFile.getAbsolutePath(), 0),
                            "Error when parsing: %1$s",
                            e.toString());
                }
            });

            Document doc = builder.parse(is);
            doc.setUserData(DATA_ORIGIN_FILE, xmlFile, null /*handler*/);
            findLineNumbers(doc, 1);

            return doc;

        } catch (FileNotFoundException e) {
            log.error(Severity.ERROR,
                    new FileAndLine(xmlFile.getAbsolutePath(), 0),
                    "XML file not found");

        } catch (Exception e) {
            log.error(Severity.ERROR,
                    new FileAndLine(xmlFile.getAbsolutePath(), 0),
                    "Failed to parse XML file: %1$s",
                    e.toString());
        }

        return null;
View Full Code Here

     */
    @NonNull
    static FileAndLine xmlFileAndLine(@NonNull Node node) {
        String name = extractXmlFilename(node);
        int line = extractLineNumber(node); // 0 in case of error or unknown
        return new FileAndLine(name, line);
    }
View Full Code Here

                                 "4");                                            //$NON-NLS-1$
            tf.transform(new DOMSource(doc), new StreamResult(outFile));
            return true;
        } catch (TransformerException e) {
            log.error(Severity.ERROR,
                    new FileAndLine(outFile.getName(), 0),
                    "Failed to write XML file: %1$s",
                    e.toString());
            return false;
        }
    }
View Full Code Here

            StringWriter sw = new StringWriter();
            tf.transform(new DOMSource(doc), new StreamResult(sw));
            return sw.toString();
        } catch (TransformerException e) {
            log.error(Severity.ERROR,
                    new FileAndLine(extractXmlFilename(doc), 0),
                    "Failed to write XML file: %1$s",
                    e.toString());
            return null;
        }
    }
View Full Code Here

            return;
        }

        //                                        1=path  2=URI    3=local name
        final Pattern keyRx = Pattern.compile("^/([^\\|]+)\\|([^ ]*) +(.+)$");      //$NON-NLS-1$
        final FileAndLine docInfo = xmlFileAndLine(doc);

        nextAttribute: for (Entry<String, String> entry : attributeMap.entrySet()) {
            String key = entry.getKey();
            String value = entry.getValue();
            if (key == null || key.isEmpty()) {
View Full Code Here

            File[] libraryFiles,
            Map<String, String> injectAttributes,
            String packageOverride) {
        Document mainDoc = MergerXmlUtils.parseDocument(mainFile, mLog, this);
        if (mainDoc == null) {
            mLog.error(Severity.ERROR, new FileAndLine(mainFile.getAbsolutePath(), 0),
                    "Failed to read manifest file.");
            return false;
        }

        boolean success = process(mainDoc, libraryFiles, injectAttributes, packageOverride);

        if (!MergerXmlUtils.printXmlFile(mainDoc, outputFile, mLog)) {
            mLog.error(Severity.ERROR, new FileAndLine(outputFile.getAbsolutePath(), 0),
                    "Failed to write manifest file.");
            success = false;
        }

        return success;
View Full Code Here

            // We don't want the default handler which prints errors to stderr.
            builder.setErrorHandler(new ErrorHandler() {
                @Override
                public void warning(SAXParseException e) {
                    log.error(Severity.WARNING,
                            new FileAndLine(xmlFile.getAbsolutePath(), 0),
                            "Warning when parsing: %1$s",
                            e.toString());
                }
                @Override
                public void fatalError(SAXParseException e) {
                    log.error(Severity.ERROR,
                            new FileAndLine(xmlFile.getAbsolutePath(), 0),
                            "Fatal error when parsing: %1$s",
                            xmlFile.getName(), e.toString());
                }
                @Override
                public void error(SAXParseException e) {
                    log.error(Severity.ERROR,
                            new FileAndLine(xmlFile.getAbsolutePath(), 0),
                            "Error when parsing: %1$s",
                            e.toString());
                }
            });

            Document doc = builder.parse(is);
            doc.setUserData(DATA_ORIGIN_FILE, xmlFile, null /*handler*/);
            findLineNumbers(doc, 1);

            if (merger.isInsertSourceMarkers()) {
                setSource(doc, xmlFile);
            }

            return doc;

        } catch (FileNotFoundException e) {
            log.error(Severity.ERROR,
                    new FileAndLine(xmlFile.getAbsolutePath(), 0),
                    "XML file not found");

        } catch (Exception e) {
            log.error(Severity.ERROR,
                    new FileAndLine(xmlFile.getAbsolutePath(), 0),
                    "Failed to parse XML file: %1$s",
                    e.toString());
        }

        return null;
View Full Code Here

     */
    @NonNull
    static FileAndLine xmlFileAndLine(@NonNull Node node) {
        String name = extractXmlFilename(node);
        int line = extractLineNumber(node); // 0 in case of error or unknown
        return new FileAndLine(name, line);
    }
View Full Code Here

                                 "4");                                            //$NON-NLS-1$
            tf.transform(new DOMSource(doc), new StreamResult(outFile));
            return true;
        } catch (TransformerException e) {
            log.error(Severity.ERROR,
                    new FileAndLine(outFile.getName(), 0),
                    "Failed to write XML file: %1$s",
                    e.toString());
            return false;
        }
    }
View Full Code Here

TOP

Related Classes of com.android.manifmerger.IMergerLog.FileAndLine

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