List of usage examples for org.xml.sax XMLReader parse
public void parse(String systemId) throws IOException, SAXException;
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 .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(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 w w w . j a v a2 s .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 va 2s. 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(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 . ja 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 w ww. ja v a 2 s .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(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 + "'"); }/* w ww . j ava 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(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:codeswarm.XMLQueueLoader.java
public void run() { XMLReader reader = null; try {/*ww w . j av a 2s. co m*/ reader = XMLReaderFactory.createXMLReader(); } catch (SAXException e) { logger.error("Couldn't find/create an XML SAX Reader", e); System.exit(1); } reader.setContentHandler(new DefaultHandler() { public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException { if (name.equals("event")) { String eventFilename = atts.getValue("filename"); String eventDatestr = atts.getValue("date"); long eventDate = Long.parseLong(eventDatestr); String eventWeightStr = atts.getValue("weight"); int eventWeight = 1; if (eventWeightStr != null) { eventWeight = Integer.parseInt(eventWeightStr); } //It's difficult for the user to tell that they're missing events, //so we should crash in this case if (isXMLSorted) { if (eventDate < maximumDateSeenSoFar) { logger.error( "Input not sorted, you must set IsInputSorted to false in your config file"); System.exit(1); } else maximumDateSeenSoFar = eventDate; } String eventAuthor = atts.getValue("author"); // int eventLinesAdded = atts.getValue( "linesadded" ); // int eventLinesRemoved = atts.getValue( "linesremoved" ); FileEvent evt = new FileEvent(eventDate, eventAuthor, "", eventFilename, eventWeight); try { queue.put(evt); fireEventAddedEvent(); } catch (InterruptedException e) { // TODO Auto-generated catch block logger.error("Interrupted while trying to put into eventsQueue", e); System.exit(1); } } } /* * (non-Javadoc) * @see org.xml.sax.helpers.DefaultHandler#endDocument() * * Notify any listeners that the Document has finished parsing. */ public void endDocument() { fireTaskDoneEvent(); } }); try { reader.parse(fullFilename); } catch (Exception e) { logger.error("Error parsing xml:", e); System.exit(1); } }
From source file:net.sf.vfsjfilechooser.accessories.bookmarks.BookmarksReader.java
public BookmarksReader(File bookmarksFile) { entries = new ArrayList<TitledURLEntry>(); Reader reader = null;//from w ww. j a v a 2s . co m try { XMLReader xmlReader = XMLReaderFactory.createXMLReader(); xmlReader.setContentHandler(new BookmarksHandler()); reader = new BufferedReader(new InputStreamReader(new FileInputStream(bookmarksFile), "UTF-8")); // read 1st 2 bytes to support multiple encryptions char[] code = new char[2]; reader.read(code, 0, 2); LOGGER.debug("code=" + String.valueOf(code) + "="); if ((code[0] == 'b') && (code[1] == '1')) { LOGGER.debug("in encrypted code section"); // read the encrypted file InputStream is = new FileInputStream(bookmarksFile); int the_length = (int) bookmarksFile.length() - 2; LOGGER.debug("raw_length=" + (the_length + 2)); if (the_length <= 0) the_length = 1; LOGGER.debug("fixed_length=" + the_length); byte[] code2 = new byte[2]; byte[] outhex = new byte[the_length]; try { is.read(code2); is.read(outhex); // is.read(outhex,2,the_length); is.close(); } catch (Exception e) { LOGGER.info("exception reading encrypted file" + e); } finally { IOUtils.closeQuietly(is); } byte[] out = Util.hexByteArrayToByteArray(outhex); // do the decryption byte[] raw = new byte[16]; raw[0] = (byte) 1; raw[2] = (byte) 23; raw[3] = (byte) 24; raw[4] = (byte) 2; raw[5] = (byte) 99; raw[6] = (byte) 200; raw[7] = (byte) 202; raw[8] = (byte) 209; raw[9] = (byte) 199; raw[10] = (byte) 181; raw[11] = (byte) 255; raw[12] = (byte) 33; raw[13] = (byte) 210; raw[14] = (byte) 214; raw[15] = (byte) 216; SecretKeySpec skeyspec = new SecretKeySpec(raw, "Blowfish"); Cipher cipher = Cipher.getInstance("Blowfish"); cipher.init(Cipher.DECRYPT_MODE, skeyspec); byte[] decrypted = cipher.doFinal(out); // convert decrypted into a bytestream and parse it ByteArrayInputStream bstream = new ByteArrayInputStream(decrypted); InputSource inputSource = new InputSource(bstream); xmlReader.parse(inputSource); LOGGER.debug("leaving encrypted code section"); } else { LOGGER.debug("in decrypted code section"); reader = new BufferedReader(new InputStreamReader(new FileInputStream(bookmarksFile), "UTF-8")); InputSource inputSource = new InputSource(reader); xmlReader.parse(inputSource); LOGGER.debug("leaving decrypted code section"); } } catch (SAXParseException e) { StringBuilder sb = new StringBuilder(); sb.append("Error parsing xml bookmarks file").append("\n").append(e.getLineNumber()).append(":") .append(e.getColumnNumber()).append("\n").append(e.getMessage()); throw new RuntimeException(sb.toString(), e); } catch (FileNotFoundException e) { throw new RuntimeException("Bookmarks file doesn't exist!", e); } catch (Exception e) { throw new RuntimeException(e); } finally { if (reader != null) { try { reader.close(); } catch (IOException ioe) { LOGGER.error("Unable to close bookmarks stream", ioe); } } } }
From source file:eionet.gdem.validation.ValidationService.java
/** /**//ww w .j a v a2 s.c om * Validate XML. If schema is null, then read the schema or DTD from the header of XML. If schema or DTD is defined, then ignore * the defined schema or DTD. * * @param srcStream XML file as InputStream to be validated. * @param schema XML Schema URL. * @return Validation result as HTML snippet. * @throws DCMException in case of unknnown system error. */ public String validateSchema(InputStream srcStream, String schema) throws DCMException { String result = ""; boolean isDTD = false; boolean isBlocker = false; if (Utils.isNullStr(schema)) { schema = null; } try { SAXParserFactory spfact = SAXParserFactory.newInstance(); SAXParser parser = spfact.newSAXParser(); XMLReader reader = parser.getXMLReader(); reader.setErrorHandler(errHandler); XmlconvCatalogResolver catalogResolver = new XmlconvCatalogResolver(); reader.setEntityResolver(catalogResolver); // make parser to validate reader.setFeature("http://xml.org/sax/features/validation", true); reader.setFeature("http://apache.org/xml/features/validation/schema", true); reader.setFeature("http://apache.org/xml/features/validation/schema-full-checking", true); reader.setFeature("http://xml.org/sax/features/namespaces", true); reader.setFeature("http://xml.org/sax/features/namespace-prefixes", true); reader.setFeature("http://apache.org/xml/features/continue-after-fatal-error", false); InputAnalyser inputAnalyser = new InputAnalyser(); inputAnalyser.parseXML(uriXml); String namespace = inputAnalyser.getSchemaNamespace(); // if schema is not in the parameter, then sniff it from the header of xml if (schema == null) { schema = inputAnalyser.getSchemaOrDTD(); isDTD = inputAnalyser.isDTD(); } else { // if the given schema ends with dtd, then don't do schema validation isDTD = schema.endsWith("dtd"); } // schema is already given as a parameter. Read the default namespace from XML file and set external schema. if (schema != null) { if (!isDTD) { if (Utils.isNullStr(namespace)) { // XML file does not have default namespace setNoNamespaceSchemaProperty(reader, schema); } else { setNamespaceSchemaProperty(reader, namespace, schema); } } else { // validate against DTD setLocalSchemaUrl(schema); LocalEntityResolver localResolver = new LocalEntityResolver(schema, getValidatedSchema()); reader.setEntityResolver(localResolver); } } else { return validationFeedback.formatFeedbackText( "Could not validate XML file. Unable to locate XML Schema reference.", QAFeedbackType.WARNING, isBlocker); } // if schema is not available, then do not parse the XML and throw error if (!Utils.resourceExists(getValidatedSchema())) { return validationFeedback.formatFeedbackText( "Failed to read schema document from the following URL: " + getValidatedSchema(), QAFeedbackType.ERROR, isBlocker); } Schema schemaObj = schemaManager.getSchema(getOriginalSchema()); if (schemaObj != null) { isBlocker = schemaObj.isBlocker(); } validationFeedback.setSchema(getOriginalSchema()); InputSource is = new InputSource(srcStream); reader.parse(is); } catch (SAXParseException se) { return validationFeedback.formatFeedbackText("Document is not well-formed. Column: " + se.getColumnNumber() + "; line:" + se.getLineNumber() + "; " + se.getMessage(), QAFeedbackType.ERROR, isBlocker); } catch (IOException ioe) { return validationFeedback.formatFeedbackText( "Due to an IOException, the parser could not check the document. " + ioe.getMessage(), QAFeedbackType.ERROR, isBlocker); } catch (Exception e) { Exception se = e; if (e instanceof SAXException) { se = ((SAXException) e).getException(); } if (se != null) { se.printStackTrace(System.err); } else { e.printStackTrace(System.err); } return validationFeedback.formatFeedbackText( "The parser could not check the document. " + e.getMessage(), QAFeedbackType.ERROR, isBlocker); } validationFeedback.setValidationErrors(getErrorList()); result = validationFeedback.formatFeedbackText(isBlocker); // validation post-processor QAResultPostProcessor postProcessor = new QAResultPostProcessor(); result = postProcessor.processQAResult(result, schema); warningMessage = postProcessor.getWarningMessage(schema); return result; }
From source file:com.xmobileapp.rockplayer.LastFmEventImporter.java
/********************************* * // ww w .j a va 2 s .co m * Get Artist Events * @throws SAXException * @throws ParserConfigurationException * *********************************/ public void getArtistEvents() throws SAXException, ParserConfigurationException { /* * Initialize Artist Cursor */ artistCursor = ((RockPlayer) context).contentResolver.query(MediaStore.Audio.Artists.EXTERNAL_CONTENT_URI, ((RockPlayer) context).ARTIST_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 artistNameFiltered = null; String artistConcertFileName = null; SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); SAXParser saxParser = saxParserFactory.newSAXParser(); XMLReader xmlReader = saxParser.getXMLReader(); XMLArtistEventHandler xmlHandler = new XMLArtistEventHandler(); xmlHandler.myLocation = this.myLocation; xmlReader.setContentHandler(xmlHandler); /* * Set Distance Limit */ xmlHandler.MAX_DISTANCE = this.concertRadius; /* * Loop through the artists */ artistCursor.moveToFirst(); for (int i = 0; i < artistCursor.getCount(); i++) { /* * Get artist name */ artistName = artistCursor.getString(artistCursor.getColumnIndex(MediaStore.Audio.Artists.ARTIST)); if (artistName.equals("<unknown>")) { artistCursor.moveToNext(); continue; } artistNameFiltered = filterString(artistName); artistConcertFileName = ((RockPlayer) context).FILEX_CONCERT_PATH + validateFileName(artistName); /* * UI feedback */ Bundle data = new Bundle(); data.putString("info", artistName); Message msg = new Message(); msg.setData(data); ((RockPlayer) context).analyseConcertInfoHandler.sendMessage(msg); /* * If we dont have yet or info is too old, update the concert info of this artist */ if (hasConcertInfo(artistName) == false || concertInfoNeedsUpdate(artistName) == true) { Log.i("INET", "Getting concert info from LastFM"); if (hasConcertInfo(artistName) == false) Log.i("INET", "Because there is no concert info yet"); if (concertInfoNeedsUpdate(artistName) == true) Log.i("INET", "Because Info is too old"); File artistConcertFile = new File(artistConcertFileName); if (!artistConcertFile.exists()) { try { artistConcertFile.createNewFile(); } catch (IOException e) { e.printStackTrace(); } } URL lastFmApiRequest; try { lastFmApiRequest = new URL( this.LAST_FM_API_URL + "&artist=" + URLEncoder.encode(artistNameFiltered)); BufferedInputStream bufferedURLStream = new BufferedInputStream(lastFmApiRequest.openStream()); BufferedOutputStream bufferedFileWriter = new BufferedOutputStream( new FileOutputStream(artistConcertFile)); byte[] buf = new byte[1024]; int len; while ((len = bufferedURLStream.read(buf)) >= 0) bufferedFileWriter.write(buf, 0, len); bufferedURLStream.close(); bufferedFileWriter.close(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } /* * get event list from cached XML files */ File artistConcertFile = new File(artistConcertFileName); if (artistConcertFile.exists() && artistConcertFile.length() > 0) { try { BufferedReader xmlFileReader = new BufferedReader( new InputStreamReader(new FileInputStream(artistConcertFile))); xmlHandler.resetList(); xmlHandler.artist = artistName; xmlReader.parse(new InputSource(xmlFileReader)); insertListInListByDate(xmlHandler.artistEventList); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (SAXException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } artistCursor.moveToNext(); } /* * Debug */ ArtistEvent artistEventDebug = null; if (!artistEventList.isEmpty()) { artistEventList.getFirst(); ListIterator<ArtistEvent> listIterator = artistEventList.listIterator(0); for (artistEventDebug = listIterator.next(); listIterator .hasNext() == true; artistEventDebug = listIterator.next()) { if (artistEventDebug != null) Log.i("DBG", artistEventDebug.date + " " + artistEventDebug.city); // Log.i("DBG", artistEventDebug.date+" "+artistEventDebug.city+" "+artistEventDebug.artist); else Log.i("DBG", "NULL"); } } /* * Update Adapter */ eventLinkedListAdapter = new EventLinkedListAdapter(context, R.layout.eventlist_item, artistEventList); if (eventLinkedListAdapter == null) Log.i("NULL", "NULL"); ((RockPlayer) context).updateEventListHandler.sendEmptyMessage(0); /* * Give feedback to the user */ Bundle data = new Bundle(); Message msg = new Message(); data.putString("info", "Done!"); msg.setData(data); ((RockPlayer) context).analyseConcertInfoHandler.sendMessage(msg); }