List of usage examples for javax.xml.parsers ParserConfigurationException printStackTrace
public void printStackTrace()
From source file:com.bordercloud.sparql.Endpoint.java
private void init(String endpoint, Boolean readOnly, Boolean debug, String proxy_host, //todo Integer proxy_port//todo ) {//from w ww . ja va2 s . c o m try { URL url = new URL(endpoint); if (readOnly) { _endpoint = endpoint; } else { _endpoint = endpoint; _endpoint_root = url.getProtocol() + "://" + url.getHost() + url.getFile(); } } catch (MalformedURLException mue) { System.out.println("Ouch - a MalformedURLException happened."); mue.printStackTrace(); } // Init Sax class SAXParserFactory parserSPARQL = SAXParserFactory.newInstance(); _parser = null; try { _parser = parserSPARQL.newSAXParser(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } _debug = debug; _endpoint_write = ""; _readOnly = readOnly; _proxy_host = proxy_host; _proxy_port = proxy_port; if (_proxy_host != null && _proxy_port != 0) { //todo } else { //todo } // init parameter in the standard _nameParameterQueryRead = "query"; _nameParameterQueryWrite = "update"; //FIX for Wikidata if (endpoint == "https://query.wikidata.org/sparql") { _MethodHTTPRead = "GET"; } else { _MethodHTTPRead = "POST"; // by default } }
From source file:captureplugin.drivers.dreambox.connector.DreamboxConnector.java
/** * @param service//ww w .j a v a2 s.c o m * Service-ID * @return Data of specific service */ private TreeMap<String, String> getServiceDataBouquets(String service) { if (!mConfig.hasValidAddress()) { return null; } try { InputStream stream = openStreamForLocalUrl("/web/getservices?bRef=" + service); SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); DreamboxHandler handler = new DreamboxHandler(); saxParser.parse(stream, handler); return handler.getData(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:captureplugin.drivers.dreambox.connector.DreamboxConnector.java
/** * @param service/*from ww w .j ava 2s . co m*/ * Service-ID * @return Data of specific service */ private TreeMap<String, String> getServiceData(String service) { if (!mConfig.hasValidAddress()) { return null; } try { InputStream stream = openStreamForLocalUrl("/web/getservices?sRef=" + service); SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); DreamboxHandler handler = new DreamboxHandler(); saxParser.parse(stream, handler); return handler.getData(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return null; }
From source file:captureplugin.drivers.dreambox.connector.DreamboxConnector.java
/** * @return List of Timers// www . j a v a 2 s. c o m */ private ArrayList<HashMap<String, String>> getTimers() { if (!mConfig.hasValidAddress()) { return null; } try { InputStream stream = openStreamForLocalUrl("/web/timerlist"); SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); DreamboxTimerHandler handler = new DreamboxTimerHandler(); saxParser.parse(stream, handler); return handler.getTimers(); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } return null; }
From source file:es.rczone.tutoriales.gmaps.MainActivity.java
private void cargarKML(String ruta) { try {/* www. ja v a2s . c om*/ InputStream is_kml = getResources().getAssets().open(ruta); // create the factory SAXParserFactory factory = SAXParserFactory.newInstance(); // create a parser SAXParser parser; parser = factory.newSAXParser(); // create the reader (scanner) XMLReader xmlreader = parser.getXMLReader(); // instantiate our handler NavigationSaxHandler navSaxHandler = new NavigationSaxHandler(); // assign our handler xmlreader.setContentHandler(navSaxHandler); // get our data via the url class InputSource is = new InputSource(is_kml); // perform the synchronous parse xmlreader.parse(is); // get the results - should be a fully populated RSSFeed instance, or null on error NavigationDataSet ds = navSaxHandler.getParsedData(); Placemark place = ds.getPlacemarks().get(0); ArrayList<String> lista_coordenadas = place.getCoordinates(); LatLng locationToCamera = null; for (String coordenadas : lista_coordenadas) { locationToCamera = draw(coordenadas); } CameraPosition camPos = new CameraPosition.Builder().target(locationToCamera) //Centramos el mapa en Madrid .zoom(9) //Establecemos el zoom en 19 .build(); CameraUpdate camUpd3 = CameraUpdateFactory.newCameraPosition(camPos); map.animateCamera(camUpd3); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.meikai.common.web.servlet.FCKeditorConnectorServlet.java
/** * Manage the Get requests (GetFolders, GetFoldersAndFiles, CreateFolder).<br> * /*from ww w . j a va 2s .c o m*/ * The servlet accepts commands sent in the following format:<br> * connector?Command=CommandName&Type=ResourceType&CurrentFolder=FolderPath<br> * <br> * It execute the command and then return the results to the client in XML * format. * */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (debug) System.out.println("--- BEGIN DOGET (list files) ---"); response.setContentType("text/xml; charset=UTF-8"); response.setHeader("Cache-Control", "no-cache"); PrintWriter out = response.getWriter(); String commandStr = request.getParameter("Command"); String typeStr = request.getParameter("Type"); String currentFolderStr = request.getParameter("CurrentFolder"); // edit begin +++++++++++++++++ /* * User user = (User) HttpUtil.getAttribute(request.getSession(), * Symbols.SESSION_USER); String userId = ""; if (debug) * System.out.println("user is null : " + (user == null)); if (user == * null) { userId = HttpUtil.getCookieValue(request, * Symbols.COOKIE_FCKEDITOR); } else { userId = user.getId().toString(); } * if (debug) System.out.println("get user id from cookie and userId * value is : " + userId); */ /* * String currentPath=baseDir+typeStr+currentFolderStr; String * currentDirPath=getServletContext().getRealPath(currentPath); */ if (debug) System.out.println("? " + dateCreated); String currentPath = baseDir + typeStr + "/" + dateCreated.substring(0, 4) + "/" + dateCreated.substring(5) + currentFolderStr; if (debug) System.out.println("?Path : " + currentPath); // create user dir makeDirectory(getServletContext().getRealPath("/"), currentPath); // String currentPath = ""; String currentDirPath = getServletContext().getRealPath(currentPath); // edit end ++++++++++++++++ File currentDir = new File(currentDirPath); /* * if(!currentDir.exists()){ currentDir.mkdir(); } */ Document document = null; try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); document = builder.newDocument(); } catch (ParserConfigurationException pce) { pce.printStackTrace(); } Node root = CreateCommonXml(document, commandStr, typeStr, currentFolderStr, request.getContextPath() + currentPath); if (debug) System.out.println("Command = " + commandStr); if (commandStr.equals("GetFolders")) { getFolders(currentDir, root, document); } else if (commandStr.equals("GetFoldersAndFiles")) { getFolders(currentDir, root, document); getFiles(currentDir, root, document); } else if (commandStr.equals("CreateFolder")) { String newFolderStr = request.getParameter("NewFolderName"); File newFolder = new File(currentDir, newFolderStr); String retValue = "110"; if (newFolder.exists()) { retValue = "101"; } else { try { boolean dirCreated = newFolder.mkdir(); if (dirCreated) retValue = "0"; else retValue = "102"; } catch (SecurityException sex) { retValue = "103"; } } setCreateFolderResponse(retValue, root, document); } document.getDocumentElement().normalize(); try { TransformerFactory tFactory = TransformerFactory.newInstance(); Transformer transformer = tFactory.newTransformer(); DOMSource source = new DOMSource(document); StreamResult result = new StreamResult(out); transformer.transform(source, result); if (debug) { StreamResult dbgResult = new StreamResult(System.out); transformer.transform(source, dbgResult); System.out.println(""); System.out.println("--- END DOGET ---"); } } catch (Exception ex) { ex.printStackTrace(); } out.flush(); out.close(); }
From source file:org.coronastreet.gpxconverter.GarminForm.java
private void loadTCXTemplate() { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try {/*from ww w . j ava 2 s . 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:it.skymedia.idolTunnel.IdolOEMConnection.java
private Document getDocumentFrom(String xml) { DocumentBuilderFactory documentFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = null; Document document = null;/*from w ww .j a v a2 s . c o m*/ try { InputStream is = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)); builder = documentFactory.newDocumentBuilder(); document = builder.parse(is); } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return document; }
From source file:org.mumod.util.HttpManager.java
public Document getDocument(String url, String httpMethod, ArrayList<NameValuePair> params) throws IOException, MustardException, AuthException { Document dom = null;//from w ww . j a v a2 s . c om InputStream is = null; try { is = requestData(url, httpMethod, params); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); dom = builder.parse(is); } catch (ParserConfigurationException e) { e.printStackTrace(); throw new MustardException(980, "Parser exception: " + e.getMessage()); } catch (SAXException e) { e.printStackTrace(); throw new MustardException(981, "Parser exception: " + e.getMessage()); } finally { if (is != null) { try { is.close(); } catch (Exception e) { } } } return dom; }
From source file:de.xplib.xdbm.util.Config.java
/** * @param fileIn ...//from w w w. j av a 2 s .c o m */ private void parseConfig(final File fileIn) { try { DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = db.parse(fileIn); //NodeList nl = doc.getElementsByTagNameNS(CONFIG_NS, "language"); NodeList nl = doc.getElementsByTagName("language"); if (nl.getLength() > 0) { this.locale = new Locale(nl.item(0).getTextContent()); } nl = doc.getElementsByTagName("driver"); for (int i = 0, l = nl.getLength(); i < l; i++) { Element driver = (Element) nl.item(i); String jar = driver.getAttribute("jar"); String clazz = driver.getAttribute("class"); String[] uris = driver.getAttribute("uris").split("\\|\\|"); ArrayList ulist = new ArrayList(); for (int j = 0; j < uris.length; j++) { ulist.add(uris[j]); } this.dbDrivers.put(jar, clazz); this.dbUris.put(jar, ulist); } nl = doc.getElementsByTagName("connection"); for (int i = 0, l = nl.getLength(); i < l; i++) { Element driver = (Element) nl.item(i); String jar = driver.getAttribute("jar"); String clazz = driver.getAttribute("class"); String uri = driver.getAttribute("uri"); this.connections.add(new Connection(jar, clazz, uri)); } nl = doc.getElementsByTagName("plugin"); for (int i = 0, l = nl.getLength(); i < l; i++) { Element driver = (Element) nl.item(i); String jar = driver.getAttribute("jar"); String clazz = driver.getAttribute("class"); String id = driver.getAttribute("id"); String pos = driver.getAttribute("position"); this.plugins.put(id, new PluginFile(id, clazz, jar, pos)); } } catch (ParserConfigurationException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } }