Android Open Source - SecNote X M L Parser






From Project

Back to project page SecNote.

License

The source code is released under:

GNU General Public License

If you think the Android project SecNote listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.jdamico.secnote.commons;
/*w w w . j av a  2  s . c o m*/
import java.util.ArrayList;
import java.util.List;

import org.jdamico.secnote.dataobjects.NoteItemObj;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class XMLParser  extends DefaultHandler {
  
  List<NoteItemObj> list=null;
    
    // string builder acts as a buffer
    StringBuilder builder;
 
    NoteItemObj note =null;
     
     
     // Initialize the arraylist
     // @throws SAXException
      
    @Override
    public void startDocument() throws SAXException {
         
        /******* Create ArrayList To Store XmlValuesModel object ******/
      //System.out.println(">>>>> startDocument()");
        list = new ArrayList<NoteItemObj>();
    }
 
     
     // Initialize the temp XmlValuesModel object which will hold the parsed info
     // and the string builder that will store the read characters
     // @param uri
     // @param localName ( Parsed Node name will come in localName  )
     // @param qName
     // @param attributes
     // @throws SAXException
      
    @Override
    public void startElement(String uri, String localName, String qName,
            Attributes attributes) throws SAXException {
         
      //System.out.println(">>>>> startElement("+localName+", "+qName+")");
      
        /****  When New XML Node initiating to parse this function called *****/
         
        // Create StringBuilder object to store xml node value
        builder=new StringBuilder();
         
        if(qName.equals("secnote")){
             
        }
        else if(qName.equals("note")){
          
          //System.out.println(">>>>> startElement(note)");
          
            note = new NoteItemObj();
            note.setNoteTitle(attributes.getValue("title"));
            note.setNoteMd5(attributes.getValue("md5"));
            note.setNoteTimeStampStr(attributes.getValue("timestamp"));
        }
    }
     
     
     
     // Finished reading the login tag, add it to arraylist
     // @param uri
     // @param localName
     // @param qName
     // @throws SAXException
      
    @Override
    public void endElement(String uri, String localName, String qName)
            throws SAXException {
        
         
        if(qName.equals("note")){

            note.setNoteContent(builder.toString());
            list.add( note );
             
        }
    }
 
    
     // Read the value of each xml NODE
     // @param ch
     // @param start
     // @param length
     // @throws SAXException
      
    @Override
    public void characters(char[] ch, int start, int length) throws SAXException {
             
        /******  Read the characters and append them to the buffer  ******/
        String tempString=new String(ch, start, length);
         builder.append(tempString);
    }

    
    public List<NoteItemObj> getNoteLst(){
      return list;
    }
}




Java Source Code List

org.jdamico.secnote.SecNoteAboutActivity.java
org.jdamico.secnote.SecNoteAuthActivity.java
org.jdamico.secnote.SecNoteConfigActivity.java
org.jdamico.secnote.SecNoteDetailActivity.java
org.jdamico.secnote.SecNoteDetailFragment.java
org.jdamico.secnote.SecNoteEditorActivity.java
org.jdamico.secnote.SecNoteListActivity.java
org.jdamico.secnote.SecNoteListFragment.java
org.jdamico.secnote.SecNoteMainActivity.java
org.jdamico.secnote.commons.ActivityHelper.java
org.jdamico.secnote.commons.AppMessages.java
org.jdamico.secnote.commons.Constants.java
org.jdamico.secnote.commons.SecNoteException.java
org.jdamico.secnote.commons.StaticObj.java
org.jdamico.secnote.commons.Utils.java
org.jdamico.secnote.commons.XMLParser.java
org.jdamico.secnote.crypto.CryptoUtils.java
org.jdamico.secnote.dataobjects.ConfigObj.java
org.jdamico.secnote.dataobjects.CryptoAlgoObj.java
org.jdamico.secnote.dataobjects.NoteItemObj.java
org.jdamico.secnote.util.SystemUiHiderBase.java
org.jdamico.secnote.util.SystemUiHiderHoneycomb.java
org.jdamico.secnote.util.SystemUiHider.java