Search in sources :

Example 6 with XMLReporter

use of javax.xml.stream.XMLReporter in project gephi by gephi.

the class LoadTask method readWorkspace.

private WorkspaceImpl readWorkspace(ProjectImpl project, String entryName, ZipFile zipFile) throws Exception {
    ZipEntry entry = zipFile.getEntry(entryName);
    if (entry != null) {
        InputStream is = null;
        try {
            is = zipFile.getInputStream(entry);
            InputStreamReader isReader = null;
            Xml10FilterReader filterReader = null;
            XMLStreamReader reader = null;
            try {
                XMLInputFactory inputFactory = XMLInputFactory.newInstance();
                if (inputFactory.isPropertySupported("javax.xml.stream.isValidating")) {
                    inputFactory.setProperty("javax.xml.stream.isValidating", Boolean.FALSE);
                }
                inputFactory.setXMLReporter(new XMLReporter() {

                    @Override
                    public void report(String message, String errorType, Object relatedInformation, Location location) throws XMLStreamException {
                    }
                });
                isReader = new InputStreamReader(is, "UTF-8");
                filterReader = new Xml10FilterReader(isReader);
                reader = inputFactory.createXMLStreamReader(filterReader);
                return GephiReader.readWorkspace(reader, project);
            } finally {
                if (reader != null) {
                    reader.close();
                }
                if (filterReader != null) {
                    filterReader.close();
                }
                if (isReader != null) {
                    isReader.close();
                }
            }
        } finally {
            if (is != null) {
                is.close();
            }
        }
    }
    return null;
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) XMLReporter(javax.xml.stream.XMLReporter) InputStreamReader(java.io.InputStreamReader) XMLStreamException(javax.xml.stream.XMLStreamException) DataInputStream(java.io.DataInputStream) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) ZipEntry(java.util.zip.ZipEntry) XMLInputFactory(javax.xml.stream.XMLInputFactory) Location(javax.xml.stream.Location)

Aggregations

Location (javax.xml.stream.Location)6 XMLReporter (javax.xml.stream.XMLReporter)6 XMLInputFactory (javax.xml.stream.XMLInputFactory)5 XMLStreamException (javax.xml.stream.XMLStreamException)5 BufferedInputStream (java.io.BufferedInputStream)3 DataInputStream (java.io.DataInputStream)3 InputStream (java.io.InputStream)3 InputStreamReader (java.io.InputStreamReader)3 ZipEntry (java.util.zip.ZipEntry)3 XMLStreamReader (javax.xml.stream.XMLStreamReader)3 BigInteger (java.math.BigInteger)1 Report (org.gephi.io.importer.api.Report)1 ProjectControllerImpl (org.gephi.project.impl.ProjectControllerImpl)1 ProjectImpl (org.gephi.project.impl.ProjectImpl)1 ProjectInformationImpl (org.gephi.project.impl.ProjectInformationImpl)1 ProjectsImpl (org.gephi.project.impl.ProjectsImpl)1 FileObject (org.openide.filesystems.FileObject)1