Android Open Source - Swinedroid Overview X M L Handler






From Project

Back to project page Swinedroid.

License

The source code is released under:

GNU General Public License

If you think the Android project Swinedroid 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 com.legind.swinedroid.xml;
// ww  w  .ja  v  a 2  s  .  co  m
import java.io.IOException;

import org.achartengine.chartlib.AlertChart;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;

import com.legind.swinedroid.RequestService.Request;
import com.legind.web.WebTransport.WebTransportException;

public class OverviewXMLHandler extends XMLHandler{
  private boolean in_all_time = false;
  private boolean in_last_72 = false;
  private boolean in_last_24 = false;
  private boolean in_high = false;
  private boolean in_medium = false;
  private boolean in_low = false;
  private boolean in_graph_info = false;
  private boolean in_label = false;
  public OverviewXMLElement current_element = new OverviewXMLElement();
  public AlertChart alertChart;
  
  @Override
  public void startElement(String uri, String name, String qName, Attributes atts){
    super.startElement(uri, name, qName, atts);
    if(name.trim().equals("graph_info")){
      alertChart.addAlertMoment();
      in_graph_info = true;
    }
    if(name.trim().equals("label")){
      super.clearStringBuilder();
      in_label = true;
    }
    if(name.trim().equals("all_time")){
      in_all_time = true;
    }
    if(name.trim().equals("last_72")){
      in_last_72 = true;
    }
    if(name.trim().equals("last_24")){
      in_last_24 = true;
    }
    if(name.trim().equals("high")){
      super.clearStringBuilder();
      in_high = true;
    }
    if(name.trim().equals("medium")){
      super.clearStringBuilder();
      in_medium = true;
    }
    if(name.trim().equals("low")){
      super.clearStringBuilder();
      in_low = true;
    }
  }

  @Override
  public void endElement(String uri, String name, String qName){
    handleString();
    super.endElement(uri, name, qName);
    if(name.trim().equals("graph_info")){
      in_graph_info = false;
    }
    if(name.trim().equals("label")){
      in_label = false;
    }
    if(name.trim().equals("all_time")){
      in_all_time = false;
    }
    if(name.trim().equals("last_72")){
      in_last_72 = false;
    }
    if(name.trim().equals("last_24")){
      in_last_24 = false;
    }
    if(name.trim().equals("high")){
      in_high = false;
    }
    if(name.trim().equals("medium")){
      in_medium = false;
    }
    if(name.trim().equals("low")){
      in_low = false;
    }
  }

  public void handleString(){
    if(in_graph_info && in_high){
      alertChart.setLastMomentHighAlert(Integer.parseInt(super.getStringBuilder().toString()));
    }
    if(in_graph_info && in_medium){
      alertChart.setLastMomentMediumAlert(Integer.parseInt(super.getStringBuilder().toString()));
    }
    if(in_graph_info && in_low){
      alertChart.setLastMomentLowAlert(Integer.parseInt(super.getStringBuilder().toString()));
    }
    if(in_graph_info && in_label){
      alertChart.setLastMomentLabel(super.getStringBuilder().toString());
    }
    if(in_all_time && in_high)
      current_element.all_time_high = Integer.parseInt(super.getStringBuilder().toString());
    if(in_all_time && in_medium)
      current_element.all_time_medium = Integer.parseInt(super.getStringBuilder().toString());
    if(in_all_time && in_low)
      current_element.all_time_low = Integer.parseInt(super.getStringBuilder().toString());
    if(in_last_72 && in_high)
      current_element.last_72_high = Integer.parseInt(super.getStringBuilder().toString());
    if(in_last_72 && in_medium)
      current_element.last_72_medium = Integer.parseInt(super.getStringBuilder().toString());
    if(in_last_72 && in_low)
      current_element.last_72_low = Integer.parseInt(super.getStringBuilder().toString());
    if(in_last_24 && in_high)
      current_element.last_24_high = Integer.parseInt(super.getStringBuilder().toString());
    if(in_last_24 && in_medium)
      current_element.last_24_medium = Integer.parseInt(super.getStringBuilder().toString());
    if(in_last_24 && in_low)
      current_element.last_24_low = Integer.parseInt(super.getStringBuilder().toString());
  }
  
  @Override
  public void createElement(Request request, String call) throws IOException, SAXException, XMLHandlerException, WebTransportException{
    alertChart = new AlertChart();
    super.createElement(request, call);
  }
}




Java Source Code List

com.legind.Dialogs.ErrorMessageHandler.java
com.legind.Dialogs.MessageHandler.java
com.legind.sqlite.AlertDbAdapter.java
com.legind.sqlite.DbAdapter.java
com.legind.sqlite.ServerDbAdapter.java
com.legind.ssl.CertificateInspect.CertificateInspect.java
com.legind.ssl.SSLHandler.SSLHandler.java
com.legind.ssl.TrustManagerFactory.TrustManagerFactory.java
com.legind.swinedroid.AlertList.java
com.legind.swinedroid.AlertSearch.java
com.legind.swinedroid.AlertView.java
com.legind.swinedroid.ServerEdit.java
com.legind.swinedroid.ServerHashDialog.java
com.legind.swinedroid.ServerView.java
com.legind.swinedroid.Swinedroid.java
com.legind.swinedroid.NetworkRunnable.NetworkRunnableBindRequires.java
com.legind.swinedroid.NetworkRunnable.NetworkRunnableManager.java
com.legind.swinedroid.NetworkRunnable.NetworkRunnableRequires.java
com.legind.swinedroid.NetworkRunnable.NetworkRunnableUniqueRequires.java
com.legind.swinedroid.NetworkRunnable.NetworkRunnable.java
com.legind.swinedroid.RequestService.RequestElement.java
com.legind.swinedroid.RequestService.Request.java
com.legind.swinedroid.xml.AlertListXMLElement.java
com.legind.swinedroid.xml.AlertListXMLHandler.java
com.legind.swinedroid.xml.AlertXMLElement.java
com.legind.swinedroid.xml.AlertXMLHandler.java
com.legind.swinedroid.xml.OverviewXMLElement.java
com.legind.swinedroid.xml.OverviewXMLHandler.java
com.legind.swinedroid.xml.XMLHandlerException.java
com.legind.swinedroid.xml.XMLHandler.java
com.legind.web.WebTransport.WebTransportConnection.java
com.legind.web.WebTransport.WebTransportException.java
com.legind.web.WebTransport.WebTransport.java
org.achartengine.chartlib.AbstractChart.java
org.achartengine.chartlib.AlertChart.java