Android Open Source - tracks-android Context Xml Handler






From Project

Back to project page tracks-android.

License

The source code is released under:

Copyright (c) 2010 Adam Wolfe Gordon <awg@xvx.ca> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to...

If you think the Android project tracks-android 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 ca.xvx.tracks;
/*from   w w w .jav  a  2  s  .  c o  m*/
import android.util.Log;

import org.xml.sax.Attributes;
import org.xml.sax.helpers.DefaultHandler;

public class ContextXmlHandler extends DefaultHandler {
  private static final String TAG = "ContextXmlHandler";
  
  private int _id;
  private String _name;
  private boolean _hide;
  private int _position;

  private final StringBuffer _text;

  public ContextXmlHandler() {
    super();
    TodoContext.clear();
    _text = new StringBuffer();
  }
  
  @Override
  public void startElement(String uri, String localName, String qName, Attributes attributes) {
    if(qName.equals("context")) {
      _id = -1;
      _name = null;
      _hide = false;
      _position = -1;
    }
    _text.setLength(0);
  }

  @Override
  public void endElement(String uri, String localName, String qName) {
    if(qName.equals("context")) {
      try {
        new TodoContext(_id, _name, _position, _hide);
      } catch(DuplicateContextException e) {
        Log.w(TAG, "Tried to add the same context twice, id: " + String.valueOf(_id), e);
      }
    } else if(qName.equals("id")) {
      _id = Integer.valueOf(_text.toString());
    } else if(qName.equals("name")) {
      _name = _text.toString();
    } else if(qName.equals("hide")) {
      _hide = _text.toString().equals("hide") ? true : false;
    } else if(qName.equals("position")) {
      _position = Integer.valueOf(_text.toString());
    }
  }

  @Override
  public void characters(char[] ch, int start, int length) {
    _text.append(ch, start, length);
  }
}




Java Source Code List

ca.xvx.tracks.ContextEditorActivity.java
ca.xvx.tracks.ContextXmlHandler.java
ca.xvx.tracks.DuplicateContextException.java
ca.xvx.tracks.DuplicateProjectException.java
ca.xvx.tracks.DuplicateTaskException.java
ca.xvx.tracks.ProjectEditorActivity.java
ca.xvx.tracks.ProjectXmlHandler.java
ca.xvx.tracks.Project.java
ca.xvx.tracks.SettingsActivity.java
ca.xvx.tracks.TaskEditorActivity.java
ca.xvx.tracks.TaskListActivity.java
ca.xvx.tracks.TaskListAdapter.java
ca.xvx.tracks.TaskListItem.java
ca.xvx.tracks.TaskXmlHandler.java
ca.xvx.tracks.Task.java
ca.xvx.tracks.TodoContext.java
ca.xvx.tracks.TracksAction.java
ca.xvx.tracks.TracksCommunicator.java
ca.xvx.tracks.preferences.PreferenceConstants.java
ca.xvx.tracks.preferences.PreferenceUtils.java
ca.xvx.tracks.util.HttpConnection.java