List of usage examples for org.xml.sax XMLReader setContentHandler
public void setContentHandler(ContentHandler handler);
From source file:nl.b3p.wms.capabilities.WMSCapabilitiesReader.java
public ServiceProvider getProvider(String location, B3PCredentials credentials, String remoteAddr) throws IOException, SAXException, Exception { ByteArrayOutputStream getCap = getCapabilities(location, credentials, remoteAddr); //String xml = getCapabilities(location, username, password); ByteArrayInputStream in = new ByteArrayInputStream(getCap.toByteArray()); //Nu kan het service provider object gemaakt en gevuld worden serviceProvider = new ServiceProvider(); XMLReader reader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader(); // niet zinvol met IgnoreEntityResolver hierna // reader.setFeature(VALIDATION_FEATURE, true); // reader.setFeature(SCHEMA_FEATURE, true); IgnoreEntityResolver r = new IgnoreEntityResolver(); reader.setEntityResolver(r);/* ww w . j a va2 s . co m*/ reader.setContentHandler(s); InputSource is = new InputSource(in); is.setEncoding(KBConfiguration.CHARSET); reader.parse(is); if (serviceProvider == null) { log.error("Host: " + location + " error: No service provider object could be created, unkown reason!"); throw new Exception( "Host: " + location + " error: No service provider object could be created, unkown reason!"); } return serviceProvider; }
From source file:jp.co.fttx.rakuphotomail.mail.store.WebDavStore.java
private DataSet processRequest(String url, String method, String messageBody, HashMap<String, String> headers, boolean needsParsing) throws MessagingException { DataSet dataset = new DataSet(); if (RakuPhotoMail.DEBUG && RakuPhotoMail.DEBUG_PROTOCOL_WEBDAV) { Log.v(RakuPhotoMail.LOG_TAG, "processRequest url = '" + url + "', method = '" + method + "', messageBody = '" + messageBody + "'"); }/*from w w w. j av a2 s . c o m*/ if (url == null || method == null) { return dataset; } getHttpClient(); try { StringEntity messageEntity = null; if (messageBody != null) { messageEntity = new StringEntity(messageBody); messageEntity.setContentType("text/xml"); } InputStream istream = sendRequest(url, method, messageEntity, headers, true); if (istream != null && needsParsing) { try { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); WebDavHandler myHandler = new WebDavHandler(); xr.setContentHandler(myHandler); xr.parse(new InputSource(istream)); dataset = myHandler.getDataSet(); } catch (SAXException se) { Log.e(RakuPhotoMail.LOG_TAG, "SAXException in processRequest() " + se + "\nTrace: " + processException(se)); throw new MessagingException("SAXException in processRequest() ", se); } catch (ParserConfigurationException pce) { Log.e(RakuPhotoMail.LOG_TAG, "ParserConfigurationException in processRequest() " + pce + "\nTrace: " + processException(pce)); throw new MessagingException("ParserConfigurationException in processRequest() ", pce); } istream.close(); } } catch (UnsupportedEncodingException uee) { Log.e(RakuPhotoMail.LOG_TAG, "UnsupportedEncodingException: " + uee + "\nTrace: " + processException(uee)); throw new MessagingException("UnsupportedEncodingException in processRequest() ", uee); } catch (IOException ioe) { Log.e(RakuPhotoMail.LOG_TAG, "IOException: " + ioe + "\nTrace: " + processException(ioe)); throw new MessagingException("IOException in processRequest() ", ioe); } return dataset; }
From source file:com.fsck.k9.mail.store.webdav.WebDavStore.java
private DataSet processRequest(String url, String method, String messageBody, Map<String, String> headers, boolean needsParsing) throws MessagingException { DataSet dataset = new DataSet(); if (K9MailLib.isDebug() && DEBUG_PROTOCOL_WEBDAV) { Log.v(LOG_TAG, "processRequest url = '" + url + "', method = '" + method + "', messageBody = '" + messageBody + "'"); }//from ww w. j a v a2s.co m if (url == null || method == null) { return dataset; } getHttpClient(); try { StringEntity messageEntity = null; if (messageBody != null) { messageEntity = new StringEntity(messageBody); messageEntity.setContentType("text/xml"); } InputStream istream = sendRequest(url, method, messageEntity, headers, true); if (istream != null && needsParsing) { try { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); WebDavHandler myHandler = new WebDavHandler(); xr.setContentHandler(myHandler); xr.parse(new InputSource(istream)); dataset = myHandler.getDataSet(); } catch (SAXException se) { Log.e(LOG_TAG, "SAXException in processRequest() " + se + "\nTrace: " + processException(se)); throw new MessagingException("SAXException in processRequest() ", se); } catch (ParserConfigurationException pce) { Log.e(LOG_TAG, "ParserConfigurationException in processRequest() " + pce + "\nTrace: " + processException(pce)); throw new MessagingException("ParserConfigurationException in processRequest() ", pce); } istream.close(); } } catch (UnsupportedEncodingException uee) { Log.e(LOG_TAG, "UnsupportedEncodingException: " + uee + "\nTrace: " + processException(uee)); throw new MessagingException("UnsupportedEncodingException in processRequest() ", uee); } catch (IOException ioe) { Log.e(LOG_TAG, "IOException: " + ioe + "\nTrace: " + processException(ioe)); throw new MessagingException("IOException in processRequest() ", ioe); } return dataset; }
From source file:br.pcfl.up.mail.store.WebDavStore.java
private DataSet processRequest(String url, String method, String messageBody, HashMap<String, String> headers, boolean needsParsing) throws MessagingException { DataSet dataset = new DataSet(); if (Up.DEBUG && Up.DEBUG_PROTOCOL_WEBDAV) { Log.v(Up.LOG_TAG, "processRequest url = '" + url + "', method = '" + method + "', messageBody = '" + messageBody + "'"); }/*www .ja v a 2s .c o m*/ if (url == null || method == null) { return dataset; } getHttpClient(); try { StringEntity messageEntity = null; if (messageBody != null) { messageEntity = new StringEntity(messageBody); messageEntity.setContentType("text/xml"); } InputStream istream = sendRequest(url, method, messageEntity, headers, true); if (istream != null && needsParsing) { try { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); WebDavHandler myHandler = new WebDavHandler(); xr.setContentHandler(myHandler); xr.parse(new InputSource(istream)); dataset = myHandler.getDataSet(); } catch (SAXException se) { Log.e(Up.LOG_TAG, "SAXException in processRequest() " + se + "\nTrace: " + processException(se)); throw new MessagingException("SAXException in processRequest() ", se); } catch (ParserConfigurationException pce) { Log.e(Up.LOG_TAG, "ParserConfigurationException in processRequest() " + pce + "\nTrace: " + processException(pce)); throw new MessagingException("ParserConfigurationException in processRequest() ", pce); } istream.close(); } } catch (UnsupportedEncodingException uee) { Log.e(Up.LOG_TAG, "UnsupportedEncodingException: " + uee + "\nTrace: " + processException(uee)); throw new MessagingException("UnsupportedEncodingException in processRequest() ", uee); } catch (IOException ioe) { Log.e(Up.LOG_TAG, "IOException: " + ioe + "\nTrace: " + processException(ioe)); throw new MessagingException("IOException in processRequest() ", ioe); } return dataset; }
From source file:cn.mailchat.mail.store.WebDavStore.java
private DataSet processRequest(String url, String method, String messageBody, HashMap<String, String> headers, boolean needsParsing) throws MessagingException { DataSet dataset = new DataSet(); if (MailChat.DEBUG && MailChat.DEBUG_PROTOCOL_WEBDAV) { Log.v(MailChat.LOG_TAG, "processRequest url = '" + url + "', method = '" + method + "', messageBody = '" + messageBody + "'"); }// w w w. j a v a 2s .c om if (url == null || method == null) { return dataset; } getHttpClient(); try { StringEntity messageEntity = null; if (messageBody != null) { messageEntity = new StringEntity(messageBody); messageEntity.setContentType("text/xml"); } InputStream istream = sendRequest(url, method, messageEntity, headers, true); if (istream != null && needsParsing) { try { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); WebDavHandler myHandler = new WebDavHandler(); xr.setContentHandler(myHandler); xr.parse(new InputSource(istream)); dataset = myHandler.getDataSet(); } catch (SAXException se) { Log.e(MailChat.LOG_TAG, "SAXException in processRequest() " + se + "\nTrace: " + processException(se)); throw new MessagingException("SAXException in processRequest() ", se); } catch (ParserConfigurationException pce) { Log.e(MailChat.LOG_TAG, "ParserConfigurationException in processRequest() " + pce + "\nTrace: " + processException(pce)); throw new MessagingException("ParserConfigurationException in processRequest() ", pce); } istream.close(); } } catch (UnsupportedEncodingException uee) { Log.e(MailChat.LOG_TAG, "UnsupportedEncodingException: " + uee + "\nTrace: " + processException(uee)); throw new MessagingException("UnsupportedEncodingException in processRequest() ", uee); } catch (IOException ioe) { Log.e(MailChat.LOG_TAG, "IOException: " + ioe + "\nTrace: " + processException(ioe)); throw new MessagingException("IOException in processRequest() ", ioe); } return dataset; }
From source file:com.top.Ertebat.mail.store.WebDavStore.java
private DataSet processRequest(String url, String method, String messageBody, HashMap<String, String> headers, boolean needsParsing) throws MessagingException { DataSet dataset = new DataSet(); if (Ertebat.DEBUG && Ertebat.DEBUG_PROTOCOL_WEBDAV) { Log.v(Ertebat.LOG_TAG, "processRequest url = '" + url + "', method = '" + method + "', messageBody = '" + messageBody + "'"); }/*from www . j a v a 2 s.c o m*/ if (url == null || method == null) { return dataset; } getHttpClient(); try { StringEntity messageEntity = null; if (messageBody != null) { messageEntity = new StringEntity(messageBody); messageEntity.setContentType("text/xml"); } InputStream istream = sendRequest(url, method, messageEntity, headers, true); if (istream != null && needsParsing) { try { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); WebDavHandler myHandler = new WebDavHandler(); xr.setContentHandler(myHandler); xr.parse(new InputSource(istream)); dataset = myHandler.getDataSet(); } catch (SAXException se) { Log.e(Ertebat.LOG_TAG, "SAXException in processRequest() " + se + "\nTrace: " + processException(se)); throw new MessagingException("SAXException in processRequest() ", se); } catch (ParserConfigurationException pce) { Log.e(Ertebat.LOG_TAG, "ParserConfigurationException in processRequest() " + pce + "\nTrace: " + processException(pce)); throw new MessagingException("ParserConfigurationException in processRequest() ", pce); } istream.close(); } } catch (UnsupportedEncodingException uee) { Log.e(Ertebat.LOG_TAG, "UnsupportedEncodingException: " + uee + "\nTrace: " + processException(uee)); throw new MessagingException("UnsupportedEncodingException in processRequest() ", uee); } catch (IOException ioe) { Log.e(Ertebat.LOG_TAG, "IOException: " + ioe + "\nTrace: " + processException(ioe)); throw new MessagingException("IOException in processRequest() ", ioe); } return dataset; }
From source file:com.bernard.beaconportal.activities.mail.store.WebDavStore.java
private DataSet processRequest(String url, String method, String messageBody, HashMap<String, String> headers, boolean needsParsing) throws MessagingException { DataSet dataset = new DataSet(); if (K9.DEBUG && K9.DEBUG_PROTOCOL_WEBDAV) { Log.v(K9.LOG_TAG, "processRequest url = '" + url + "', method = '" + method + "', messageBody = '" + messageBody + "'"); }//from ww w .j a v a2 s. com if (url == null || method == null) { return dataset; } getHttpClient(); try { StringEntity messageEntity = null; if (messageBody != null) { messageEntity = new StringEntity(messageBody); messageEntity.setContentType("text/xml"); } InputStream istream = sendRequest(url, method, messageEntity, headers, true); if (istream != null && needsParsing) { try { SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); WebDavHandler myHandler = new WebDavHandler(); xr.setContentHandler(myHandler); xr.parse(new InputSource(istream)); dataset = myHandler.getDataSet(); } catch (SAXException se) { Log.e(K9.LOG_TAG, "SAXException in processRequest() " + se + "\nTrace: " + processException(se)); throw new MessagingException("SAXException in processRequest() ", se); } catch (ParserConfigurationException pce) { Log.e(K9.LOG_TAG, "ParserConfigurationException in processRequest() " + pce + "\nTrace: " + processException(pce)); throw new MessagingException("ParserConfigurationException in processRequest() ", pce); } istream.close(); } } catch (UnsupportedEncodingException uee) { Log.e(K9.LOG_TAG, "UnsupportedEncodingException: " + uee + "\nTrace: " + processException(uee)); throw new MessagingException("UnsupportedEncodingException in processRequest() ", uee); } catch (IOException ioe) { Log.e(K9.LOG_TAG, "IOException: " + ioe + "\nTrace: " + processException(ioe)); throw new MessagingException("IOException in processRequest() ", ioe); } return dataset; }
From source file:com.xmobileapp.rockplayer.LastFmAlbumArtImporter.java
/********************************* * /*from w w w .j a v a2 s. c o m*/ * Get AlbumArt * @throws SAXException * @throws ParserConfigurationException * *********************************/ public void getAlbumArt() throws SAXException, ParserConfigurationException { /* * Initialize Album Cursor */ albumCursor = ((RockPlayer) context).contentResolver.query(MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI, ((RockPlayer) context).ALBUM_COLS, // we should minimize the number of columns null, // all albums null, // parameters to the previous parameter - which is null also null // sort order, SQLite-like ); /* * Declare & Initialize some vars */ String artistName = null; String albumName = null; SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); SAXParser saxParser = saxParserFactory.newSAXParser(); XMLReader xmlReader = saxParser.getXMLReader(); XMLAlbumArtHandler xmlHandler = new XMLAlbumArtHandler(); // XMLGoogleAlbumArtHandler xmlGoogleHandler = new XMLGoogleAlbumArtHandler(); /* * Give feedback to the user */ Bundle data = new Bundle(); Message msg = new Message(); data.putString("info", "Looking for missing art..."); msg.setData(data); ((RockPlayer) context).getAlbumArtHandler.sendMessage(msg); /* * Loop through the albums */ albumCursor.moveToFirst(); for (int i = 0; i < albumCursor.getCount(); i++) { System.gc(); /* * Get Album Details */ artistName = albumCursor.getString(albumCursor.getColumnIndex(MediaStore.Audio.Albums.ARTIST)); albumName = albumCursor.getString(albumCursor.getColumnIndex(MediaStore.Audio.Albums.ALBUM)); /* * If no Art is available fetch it */ if (getAlbumArtPath(artistName, albumName) == null) { Log.i("LastFM", "Album with no Art " + albumName); try { if ((artistName.equals("<unknown>") && albumName.equals("<unknown>"))) { Log.i("ALBUMART", "Unknown album"); albumCursor.moveToNext(); continue; } } catch (Exception e) { Log.i("ALBUMART", "Null album or artist"); albumCursor.moveToNext(); continue; } /* * Give feedback to the user */ data = new Bundle(); msg = new Message(); data.putString("info", albumName); msg.setData(data); ((RockPlayer) context).getAlbumArtHandler.sendMessage(msg); String albumArtURL = null; try { /* * Get album URL from Last.FM */ String artistNameFiltered = filterString(artistName); String albumNameFiltered = filterString(albumName); if (USE_GOOGLE_IMAGES) { // xmlReader.setContentHandler(xmlGoogleHandler); URL googleImagesRequest = new URL( this.GOOGLE_IMAGES_SEARCH_URL + URLEncoder.encode(artistNameFiltered) + "+" + URLEncoder.encode(albumNameFiltered)); // Log.i("GOOGLEIMAGES", googleImagesRequest.toString()); // DefaultHttpClientConnection httpCon = createGoogleImageConnection( // googleImagesRequest.toString()); /* * retreive URL */ BasicHttpParams params = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(params, 10000); DefaultHttpClient httpClient = new DefaultHttpClient(); // Get cookies from the login page (not the address same of the form post) HttpGet httpGet = new HttpGet(googleImagesRequest.toString()); HttpResponse response; try { /* * Get the page */ response = httpClient.execute(httpGet); HttpEntity entity = response.getEntity(); BufferedReader in = new BufferedReader(new InputStreamReader(entity.getContent())); /* * Parse 1st existing image on the result page */ String line; int idxStart = 0; int idxStop; do { line = in.readLine(); if (line != null) { // Log.i("GIMAGES", line); if (line.startsWith("<table")) { boolean found = false; int tries = 0; while (!found) { tries++; if (tries > 12) break; idxStart = line.indexOf("<a href=", idxStart); if (idxStart == -1) { line = in.readLine(); if (line == null) break; continue; } idxStart = line.indexOf("http://", idxStart); idxStop = line.indexOf("&imgrefurl=", idxStart); albumArtURL = line.substring(idxStart, idxStop); Log.i("GIMAGE", line.substring(idxStart, idxStop)); try { //URL albumArt = new URL(URLEncoder.encode(albumArtURL)); // URL albumArt = new URL(albumArtURL); // InputStream albumArtURLStream = albumArt.openStream(); // albumArtURLStream.close(); if (albumArtURL != null) { if (createAlbumArt(artistName, albumName, albumArtURL) == null) { albumArtURL = null; found = false; Log.i("GIMAGES", "createAlbumArt FAIL"); } else { found = true; Log.i("GIMAGES", "createAlbumArt WIN"); } } else { albumArtURL = null; found = false; Log.i("GIMAGES", "albumArt URL FAIL!"); } } catch (Exception e) { e.printStackTrace(); albumArtURL = null; found = false; } } break; } } } while (line != null); // xmlReader.parse(new InputSource(in)); entity.consumeContent(); // for(int j = 0; j < xmlGoogleHandler.MAX_IMAGES; j++){ // if(xmlGoogleHandler.albumArtUrl[j] != null){ // albumArtURL = xmlGoogleHandler.albumArtUrl[j]; // break; // } // } /* * No luck with the duck */ // if(albumArtURL == null){ // Log.i("GOOGLEIMAGES", "Absolutely no luck"); // // mark this as a problematic album... // // so we dont refetch it all the time // createSmallAlbumArt(artistName, albumName, false); // albumCursor.moveToNext(); // continue; // } else { // Log.i("GOOGLEIMAGES", albumArtURL); // } /* * Clear up the Handler */ // xmlGoogleHandler.clear(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } // // /* // * No Album Art available // * 1. try going by the album name // * 2. get some artist pic and thats it // */ // if(albumArtURL == null){ // Log.i("LASTFM", "Could not get album art immediately"); // Log.i("LASTFM", "Trying sole album search"); // // albumArtURL = getAlbumArtByAlbumName(albumName, artistName); // if(albumArtURL == null){ // Log.i("LASTFM", "Trying to get artist Art"); // albumArtURL = getArtistArt(artistName); // } // /* // * No luck with the duck // */ // if(albumArtURL == null){ // Log.i("LASTFM", "Absolutely no luck"); // // mark this as a problematic album... // // so we dont refetch it all the time // createSmallAlbumArt(artistName, albumName, false); // albumCursor.moveToNext(); // continue; // } // } } /* * If google images failed try last.fm */ if (albumArtURL == null) { xmlReader.setContentHandler(xmlHandler); URL lastFmApiRequest = new URL( this.LAST_FM_ALBUM_GETINFO_URL + "&artist=" + URLEncoder.encode(artistNameFiltered) + "&album=" + URLEncoder.encode(albumNameFiltered)); try { BufferedReader in = new BufferedReader( new InputStreamReader(lastFmApiRequest.openStream())); xmlReader.parse(new InputSource(in)); if (xmlHandler.xlargeAlbumArt != null) { albumArtURL = xmlHandler.xlargeAlbumArt; } else if (xmlHandler.largeAlbumArt != null) { albumArtURL = xmlHandler.largeAlbumArt; } else if (xmlHandler.mediumAlbumArt != null) { albumArtURL = xmlHandler.mediumAlbumArt; } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } /* * No Album Art available * 1. try going by the album name * 2. get some artist pic and thats it */ if (albumArtURL == null) { Log.i("LASTFM", "Could not get album art immediately"); Log.i("LASTFM", "Trying sole album search"); albumArtURL = getAlbumArtByAlbumName(albumName, artistName); if (albumArtURL == null) { Log.i("LASTFM", "Trying to get artist Art"); albumArtURL = getArtistArt(artistName); } /* * No luck with the duck */ if (albumArtURL == null) { Log.i("LASTFM", "Absolutely no luck"); // mark this as a problematic album... // so we dont refetch it all the time createSmallAlbumArt(artistName, albumName, false); albumCursor.moveToNext(); continue; } } /* only reaches here if not FAIL */ createAlbumArt(artistName, albumName, albumArtURL); } /* * reset xml handler */ xmlHandler.smallAlbumArt = null; xmlHandler.mediumAlbumArt = null; xmlHandler.largeAlbumArt = null; xmlHandler.xlargeAlbumArt = null; } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (NullPointerException e) { e.printStackTrace(); } } /* * Create small album art */ createSmallAlbumArt(artistName, albumName, true); /* * Give feedback to the user */ //Bundle data = new Bundle(); //Message msg = new Message(); //data.putString("info", "Creating Thumbnail"); //msg.setData(data); //((Filex) context).getAlbumArtHandler.sendMessage(msg); albumCursor.moveToNext(); } /* * Give feedback to the user */ data = new Bundle(); msg = new Message(); data.putString("info", "Done!"); msg.setData(data); ((RockPlayer) context).getAlbumArtHandler.sendMessage(msg); /* * Set the last import date on preferences */ // SharedPreferences settings = ((Filex) this.context).getSharedPreferences(((Filex) this.context).PREFS_NAME, 0); // Editor editor = settings.edit(); // editor.putLong("artImportDate", System.currentTimeMillis()); // editor.commit(); RockOnPreferenceManager settings = new RockOnPreferenceManager( ((RockPlayer) context).FILEX_PREFERENCES_PATH); settings.putLong("artImportDate", System.currentTimeMillis()); //settings. // long lastAlbumArtImportDate = settings.getLong("artImportDate", 0); }
From source file:android_network.hetnet.vpn_service.ActivitySettings.java
private void xmlImport(InputStream in) throws IOException, SAXException, ParserConfigurationException { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.unregisterOnSharedPreferenceChangeListener(this); prefs.edit().putBoolean("enabled", false).apply(); ServiceSinkhole.stop("import", this); XMLReader reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader(); XmlImportHandler handler = new XmlImportHandler(this); reader.setContentHandler(handler); reader.parse(new InputSource(in)); xmlImport(handler.application, prefs); xmlImport(handler.wifi, getSharedPreferences("wifi", Context.MODE_PRIVATE)); xmlImport(handler.mobile, getSharedPreferences("other", Context.MODE_PRIVATE)); xmlImport(handler.unused, getSharedPreferences("unused", Context.MODE_PRIVATE)); xmlImport(handler.screen_wifi, getSharedPreferences("screen_wifi", Context.MODE_PRIVATE)); xmlImport(handler.screen_other, getSharedPreferences("screen_other", Context.MODE_PRIVATE)); xmlImport(handler.roaming, getSharedPreferences("roaming", Context.MODE_PRIVATE)); xmlImport(handler.apply, getSharedPreferences("apply", Context.MODE_PRIVATE)); xmlImport(handler.notify, getSharedPreferences("notify", Context.MODE_PRIVATE)); // Upgrade imported settings Receiver.upgrade(true, this); // Refresh UI prefs.edit().putBoolean("imported", true).apply(); prefs.registerOnSharedPreferenceChangeListener(this); }
From source file:com.jiahuan.svgmapview.core.helper.map.SVGParser.java
static SVG parse(InputSource data, SVGHandler handler) throws SVGParseException { try {//from w ww . j a va 2s . c o m final Picture picture = new Picture(); handler.setPicture(picture); SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); XMLReader xr = sp.getXMLReader(); xr.setContentHandler(handler); xr.setFeature("http://xml.org/sax/features/validation", false); if (DISALLOW_DOCTYPE_DECL) { try { xr.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); } catch (SAXNotRecognizedException e) { DISALLOW_DOCTYPE_DECL = false; } } xr.parse(data); SVG result = new SVG(picture, handler.bounds); // Skip bounds if it was an empty pic if (!Float.isInfinite(handler.limits.top)) { result.setLimits(handler.limits); } return result; } catch (Exception e) { Log.e(TAG, "Failed to parse SVG.", e); throw new SVGParseException(e); } }