Example usage for org.xml.sax SAXException printStackTrace

List of usage examples for org.xml.sax SAXException printStackTrace

Introduction

In this page you can find the example usage for org.xml.sax SAXException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:abfab3d.io.input.STSReader.java

/**
 * Parse the manifest file//from   ww w .j  ava 2 s. co  m
 * @param src The manifest file
 * @return
 */
private STSManifest parseManifest(InputStream src) throws IOException {

    String field = null;
    String val = null;

    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();

        Document doc = builder.parse(src);

        NodeList model_list = doc.getElementsByTagName("model");

        if (model_list == null) {
            throw new IllegalArgumentException("File contains no model element");
        }

        Element model = (Element) model_list.item(0);

        if (model == null) {
            throw new IllegalArgumentException("File contains no model element");
        }

        field = "units";
        val = model.getAttribute(field);
        String units = val;

        if (units != null && units.length() != 0) {
            mf.setUnits(Double.parseDouble(units));
        }

        STSManifest ret_val = new STSManifest();
        int len;
        field = "parts";

        NodeList part_list = doc.getElementsByTagName("part");

        if (part_list == null) {
            throw new IllegalArgumentException("File contains no part elements");
        }

        len = part_list.getLength();

        ArrayList<STSPart> plist = new ArrayList<STSPart>();
        for (int i = 0; i < len; i++) {
            Element part = (Element) part_list.item(i);

            field = "file";
            val = part.getAttribute(field);
            String file = val;

            field = "material";
            val = part.getAttribute(field);
            String material = val;

            plist.add(new STSPart(file, material));
        }

        ret_val.setParts(plist);

        NodeList metadata_list = doc.getElementsByTagName("entry");

        NodeList material_list = doc.getElementsByTagName("material");

        if (material_list != null) {
            HashMap<String, String> map = new HashMap<String, String>();
            len = material_list.getLength();

            for (int i = 0; i < len; i++) {
                Element entry = (Element) material_list.item(i);
                String key = entry.getAttribute("id");
                String value = entry.getAttribute("urn");

                if (key != null && key.length() > 0 && value != null && value.length() > 0) {
                    map.put(key, value);
                }
            }
            ret_val.setMaterials(map);
        }

        if (metadata_list != null) {
            HashMap<String, String> map = new HashMap<String, String>();
            len = metadata_list.getLength();

            for (int i = 0; i < len; i++) {
                Element entry = (Element) metadata_list.item(i);
                String key = entry.getAttribute("key");
                String value = entry.getAttribute("value");

                if (key != null && key.length() > 0 && value != null && value.length() > 0) {
                    map.put(key, value);
                }
            }
            ret_val.setMetadata(map);
        }

        return ret_val;
    } catch (ParserConfigurationException pce) {
        pce.printStackTrace();
    } catch (SAXException saxe) {
        saxe.printStackTrace();
    } catch (Exception e) {
        printf("Cannot parse field: %s  val: %s\n", field, val);
        e.printStackTrace();
    }

    return null;
}

From source file:org.coronastreet.gpxconverter.Strava.java

private void loadOutFile() {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    try {/*from  w  w  w .j  a  v a2s . c o  m*/
        DocumentBuilder db = dbf.newDocumentBuilder();
        log("Loading TCX template file.");
        outDoc = db
                .parse(this.getClass().getResourceAsStream("/org/coronastreet/gpxconverter/tcxtemplate.xml"));
    } catch (ParserConfigurationException pce) {
        pce.printStackTrace();
    } catch (SAXException se) {
        se.printStackTrace();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}

From source file:org.coronastreet.gpxconverter.Converter.java

private void loadInFile(String file) {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

    try {// w  ww .ja  va2  s .com
        DocumentBuilder db = dbf.newDocumentBuilder();
        inDoc = db.parse(file);

    } catch (ParserConfigurationException pce) {
        pce.printStackTrace();
    } catch (SAXException se) {
        se.printStackTrace();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }

}

From source file:org.coronastreet.gpxconverter.Converter.java

private void loadOutFile() {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

    try {//w ww  .java 2 s . c  o  m
        DocumentBuilder db = dbf.newDocumentBuilder();
        log("Loading TCX template file.\n");
        outDoc = db
                .parse(this.getClass().getResourceAsStream("/org/coronastreet/gpxconverter/tcxtemplate.xml"));
    } catch (ParserConfigurationException pce) {
        pce.printStackTrace();
    } catch (SAXException se) {
        se.printStackTrace();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }

}

From source file:com.example.apis.ifashion.YahooWeather.java

private Document convertStringToDocument(Context context, String src) {
    Document dest = null;//from w  ww  .  jav  a2  s.com

    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder parser;

    try {
        parser = dbFactory.newDocumentBuilder();
        dest = parser.parse(new ByteArrayInputStream(src.getBytes()));
    } catch (ParserConfigurationException e1) {
        e1.printStackTrace();
        Toast.makeText(context, e1.toString(), Toast.LENGTH_LONG).show();
    } catch (SAXException e) {
        e.printStackTrace();
        Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show();
    } catch (IOException e) {
        e.printStackTrace();
        Toast.makeText(context, e.toString(), Toast.LENGTH_LONG).show();
    }

    return dest;
}

From source file:com.bordercloud.sparql.Endpoint.java

private HashMap<String, HashMap> getResult() {
    //parse the message
    _handler = new ParserSPARQLResultHandler();

    try {/* w w  w  .  j av  a 2s.com*/
        _parser.parse(new InputSource(new StringReader(_response)), _handler);
    } catch (SAXException e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    } catch (IOException e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }

    if (_handler != null) {
        return ((ParserSPARQLResultHandler) _handler).getResult();//new HashMap<String, HashMap>();
    } else {
        return null;
    }
}

From source file:eu.planets_project.pp.plato.action.project.XmlAction.java

/**
 * Imports the uploaded XML-Files and stores the templates in the database.
 *//*from   ww w  .j a  v  a2 s . co m*/
@RaiseEvent("projectListChanged")
public String uploadTemplates() {

    try {
        projectImport.storeTemplatesInLibrary(file);

        fragmentRoot = null;
        templateRoot = null;

    } catch (SAXException e) {
        e.printStackTrace();
        FacesMessages.instance().add(FacesMessage.SEVERITY_ERROR,
                "Error importing templates. " + e.getMessage());
        return null;
    } catch (IOException e) {
        FacesMessages.instance().add(FacesMessage.SEVERITY_ERROR,
                "Error importing templates. " + e.getMessage());
        e.printStackTrace();
        return null;
    }

    FacesMessages.instance().add(FacesMessage.SEVERITY_INFO, "Templates successfully imported");

    return null;
}

From source file:org.coronastreet.gpxconverter.GarminForm.java

private void loadTCXTemplate() {
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    try {// w  w w  .ja  va2s.  c  om
        DocumentBuilder db = dbf.newDocumentBuilder();
        log("Loading TCX template file.");
        outDoc = db
                .parse(this.getClass().getResourceAsStream("/org/coronastreet/gpxconverter/tcxtemplate.xml"));
    } catch (ParserConfigurationException pce) {
        pce.printStackTrace();
    } catch (SAXException se) {
        se.printStackTrace();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}

From source file:ws.argo.Responder.Responder.java

public void run() throws IOException, ClassNotFoundException {

    ArrayList<ProbeHandlerPluginIntf> handlers = new ArrayList<ProbeHandlerPluginIntf>();

    // load up the handler classes specified in the configuration parameters
    // I hope the hander classes are in a jar file on the classpath
    handlers = loadHandlerPlugins(cliValues.config.appHandlerConfigs);

    @SuppressWarnings("resource")
    MulticastSocket socket = new MulticastSocket(cliValues.config.multicastPort);
    address = InetAddress.getByName(cliValues.config.multicastAddress);
    LOGGER.info("Starting Responder on " + address.toString() + ":" + cliValues.config.multicastPort);
    socket.joinGroup(address);//from   w w  w.  j av a2  s  . co m

    DatagramPacket packet;
    ResponsePayloadBean response = null;

    LOGGER.info(
            "Responder started on " + cliValues.config.multicastAddress + ":" + cliValues.config.multicastPort);

    httpClient = HttpClients.createDefault();

    LOGGER.fine("Starting Responder loop - infinite until process terminated");
    // infinite loop until the responder is terminated
    while (true) {

        byte[] buf = new byte[1024];
        packet = new DatagramPacket(buf, buf.length);
        LOGGER.fine("Waiting to recieve packet...");
        socket.receive(packet);

        LOGGER.fine("Received packet");
        LOGGER.fine("Packet contents:");
        // Get the string
        String probeStr = new String(packet.getData(), 0, packet.getLength());
        LOGGER.fine("Probe: \n" + probeStr);

        try {
            ProbePayloadBean payload = parseProbePayload(probeStr);

            LOGGER.info("Received probe id: " + payload.probeID);

            // Only handle probes that we haven't handled before
            // The Probe Generator needs to send a stream of identical UDP packets
            // to compensate for UDP reliability issues.  Therefore, the Responder
            // will likely get more than 1 identical probe.  We should ignore duplicates.
            if (!handledProbes.contains(payload.probeID)) {
                for (ProbeHandlerPluginIntf handler : handlers) {
                    response = handler.probeEvent(payload);
                    sendResponse(payload.respondToURL, payload.respondToPayloadType, response);
                }
                handledProbes.add(payload.probeID);
            } else {
                LOGGER.info("Discarding duplicate probe with id: " + payload.probeID);
            }

        } catch (SAXException e) {
            // TODO Auto-generated catch block

            e.printStackTrace();
        }

    }

}

From source file:net.jcreate.xkins.XkinsLoader.java

/**
 * Carga el Skin desde la definicin si la tiene aparte.
 *//*  w  w  w .  jav a2 s  . co m*/
public Skin loadDefinition(Skin skin) throws XkinsException {
    if (skin.getDefinition() == null) {
        return null;
    }
    log.info(":" + skin.getSkinDefinition());
    try {
        log.info("Loading Definition from file " + skin.getSkinDefinition() + "...");
        addDefinitionFilesTimeStamp(getSkinFile(skin.getSkinDefinition()));
        InputStream in = getSkinStream(skin.getSkinDefinition());
        Digester digester = new Digester();
        URL url = this.getClass().getResource(this.dtd);
        if (url != null) {
            digester.register(this.registration, url.toString());
            //digester.setValidating(true);
        }
        digester.push(skin);
        this.skinDigester(digester, "");
        try {
            // Parse the input stream to initialize our database
            digester.parse(in);
            in.close();
        } catch (SAXException e) {
            e.printStackTrace();
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (Exception e) {
                    log.error("Error Loading skin Definition.", e);
                }
            }
        }
        XkinsLoadEvent xle = new XkinsLoadEvent(this);
        xle.setXkins(skin.getXkins());
        skin.getXkins().sendEvent(xle);
        return skin;
    } catch (Throwable thr) {
        log.error("Error Loading Definition.", thr);
        throw new XkinsException(thr.getMessage());
    }
}