Android Open Source - allblue-all-in-one X M L Util






From Project

Back to project page allblue-all-in-one.

License

The source code is released under:

MIT License

If you think the Android project allblue-all-in-one 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.allblue.util;
/* w w w  .  j  a va 2  s  .c  om*/
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;
import javax.xml.xpath.XPathConstants;

import org.allblue.R;
import org.allblue.activity.GlobalActivity;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;

import android.app.Activity;

public final class XMLUtil {
  
  private static String run(String expression) {
    XPath xpath = XPathFactory.newInstance().newXPath();
    InputSource source = new InputSource(GlobalActivity.getGlobalContext().getResources().openRawResource(R.raw.account_api));
    
    try {
      Element node = (Element) xpath.evaluate(expression, source, XPathConstants.NODE);
      return node.getTextContent();
      
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    return null;
  }
  
  public static String getKey(String accountName) {
    String expression = "//accounts/account[@name='" + accountName + "']/authenticate/key";
    return run(expression);
  }
  
  public static String getValue(String accountName) {
    String expression = "//accounts/account[@name='" + accountName + "']/authenticate/value";
    return run(expression);
  }
  
  public static String getRequestToken(String accountName) {
    String expression = "//accounts/account[@name='" + accountName + "']/authenticate/request_token";
    return run(expression);
  }
  
  public static String getAccessToken(String accountName) {
    String expression = "//accounts/account[@name='" + accountName + "']/authenticate/access_token";
    return run(expression);
  }
  
  public static String getAuthorized(String accountName) {
    String expression = "//accounts/account[@name='" + accountName + "']/authenticate/authorized";
    return run(expression);
  }
  
  public static String getHomeline(String accountName) {
    String expression = "//accounts/account[@name='" + accountName + "']/api/home_timeline";
    return run(expression);
  }
  
  public static String getVerifyCredentials(String accountName) {
    String expression = "//accounts/account[@name='" + accountName + "']/api/verify_credentials";
    return run(expression);
  }
  
  public static String getUpdate(String accountName) {
    String expression = "//accounts/account[@name='" + accountName + "']/api/update";
    return run(expression);
  }
  
  public static String getUserProfile(String accountName) {
    String expression = "//accounts/account[@name='" + accountName + "']/api/user_profile";
    return run(expression);
  }
}




Java Source Code List

org.allblue.DashBoard.java
org.allblue.activity.GlobalActivity.java
org.allblue.activity.HomeActivity.java
org.allblue.activity.OAuthActivity.java
org.allblue.activity.SettingActivity.java
org.allblue.activity.SingleTabActivity.java
org.allblue.adapter.SettingAdapter.java
org.allblue.adapter.SingleTabCursorAdapter.java
org.allblue.database.DatabaseConfig.java
org.allblue.database.DatabaseHelper.java
org.allblue.metadata.AccountTypes.java
org.allblue.metadata.Account.java
org.allblue.metadata.SinaAccount.java
org.allblue.metadata.TweetItem.java
org.allblue.metadata.TwitterAccount.java
org.allblue.util.OAuthUtil.java
org.allblue.util.SharedOAuthToken.java
org.allblue.util.XMLUtil.java