Android Open Source - markj Jw String I D






From Project

Back to project page markj.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project markj 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.markjmind.mobile.api.android.controller;
/*from w  ww.ja va  2 s  .  c  o  m*/
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Hashtable;

import android.app.Activity;
import android.app.Application;

/**
 * start : 2012.08.21<br>
 * id? id???? ???? ?????? ???? ?????.<br>
 * 
 * @author ???
 * @version 2013.11.17
 *
 */
public class JwStringID {
  private ArrayList<String> ids = new ArrayList<String>();
  private Hashtable<String, Integer> idMap = new Hashtable<String, Integer>();
  private boolean isInit=false;
  
  public void init(Application app){
    Class cls = getRClass("id", app);
    Object obj;
    try {
      obj = cls.newInstance();
      
      Field[] field = cls.getDeclaredFields();
      for(int i=0; i<field.length;i++){
        String fieldName = field[i].getName();
        int value = field[i].getInt(obj);
        idMap.put(fieldName, value);
        ids.add(fieldName);
      }
      isInit = true;
    } catch (IllegalAccessException e) {
      throw new JwMapperException("?? ID? ???? ????.", e);
    } catch (InstantiationException e) {
      throw new JwMapperException("R.layout??? ??????? ????? ????.", e);
    }
  }
  
  
  //????? ????????? ????.
  public int get(String key){
    int id=idMap.get(key);
    return id;
  }
  
  //key ??????? ?????? ?????? ??? ?? ????? ????.
  public ArrayList<String> containKeys(String key){
    ArrayList<String> result = new ArrayList<String>();
    
    for(int i=0;i<ids.size();i++){
      if((ids.get(i)).indexOf(key)>=0){
        result.add(ids.get(i));
      }
    }
    if(result.size()==0)
      return null;
    return result;
  }
  
  //key ?????? ???? ?????? ??? ?? ????? ????.
  public ArrayList<String> startContainKeys(String key){
    ArrayList<String> result = new ArrayList<String>();
    
    for(int i=0;i<ids.size();i++){
      if(((String)ids.get(i)).indexOf(key)==0){
        result.add(ids.get(i));
      }
    }
    if(result.size()==0)
      return null;
    return result;
  }
  
  public static int getLayoutID(String idName, Application app) throws JwMapperException{
    Class cls = getRClass("layout",app);
    Field field;
    try {
      field = cls.getDeclaredField(idName);
      int value = field.getInt(null);
      return value;
    } catch (SecurityException e) {
      throw new JwMapperException("[R.layout."+idName+"] SecurityException",e);
    } catch (NoSuchFieldException e) {
      throw new JwMapperException("[R.layout."+idName+"] ??? ???? ????.",e);
    } catch (IllegalArgumentException e) {
      throw new JwMapperException("[R.layout."+idName+"] IllegalArgumentException",e);
    } catch (IllegalAccessException e) {
      throw new JwMapperException("[R.layout."+idName+"] ??????? ?? ?????.",e);
    }
  }
  
  public static int getID(String idName, Application app) throws JwMapperException{
    Class cls = getRClass("id",app);
    Field field;
    try {
      field = cls.getDeclaredField(idName);
      int value = field.getInt(null);
      return value;
    } catch (SecurityException e) {
      throw new JwMapperException("[R.id."+idName+"] SecurityException",e);
    } catch (NoSuchFieldException e) {
      throw new JwMapperException("[R.id."+idName+"] ??? ???? ????.",e);
    } catch (IllegalArgumentException e) {
      throw new JwMapperException("[R.id."+idName+"] ????? Field? ?????????.",e);
    } catch (IllegalAccessException e) {
      throw new JwMapperException("[R.id."+idName+"] ??????? ?? ?????.",e);
    }
  }
  
  public static Class getRClass(String innerClassName, Application app) throws JwMapperException{
    String fullName = app.getPackageName()+".R$"+innerClassName;
    try {
      return Class.forName(fullName);
    } catch (ClassNotFoundException e) {
      throw new JwMapperException("-"+ fullName+"- [R."+innerClassName+"] ?????? ???? ????.",e);
    }
  }
}




Java Source Code List

com.markjmind.mobile.api.android.controller.JwAsyncTask.java
com.markjmind.mobile.api.android.controller.JwMapperException.java
com.markjmind.mobile.api.android.controller.JwMemberMapper.java
com.markjmind.mobile.api.android.controller.JwStringID.java
com.markjmind.mobile.api.android.controller.JwViewController.java
com.markjmind.mobile.api.android.controller.JwViewerCache.java
com.markjmind.mobile.api.android.controller.JwViewer.java
com.markjmind.mobile.api.android.controller.Jwc.java
com.markjmind.mobile.api.android.controller.OnClickListenerReceiver.java
com.markjmind.mobile.api.android.controller.ViewerXmlMapper.java
com.markjmind.mobile.api.android.exception.JwErrorCode.java
com.markjmind.mobile.api.android.exception.JwException.java
com.markjmind.mobile.api.android.json.JSONMsgString.java
com.markjmind.mobile.api.android.json.JwJOSNTreeArray.java
com.markjmind.mobile.api.android.json.JwJSONReader.java
com.markjmind.mobile.api.android.ui.JwAnimation.java
com.markjmind.mobile.api.android.ui.JwGroup.java
com.markjmind.mobile.api.android.ui.JwMenu.java
com.markjmind.mobile.api.android.ui.JwOnGroupSelect.java
com.markjmind.mobile.api.android.ui.JwTabGroup.java
com.markjmind.mobile.api.android.ui.JwTouchGroupListener.java
com.markjmind.mobile.api.android.ui.JwTouchGroup.java
com.markjmind.mobile.api.android.ui.JwTouchMotionGroupLisener.java
com.markjmind.mobile.api.android.ui.JwTouchMotionGroup.java
com.markjmind.mobile.api.android.ui.drawgraph.GraphBoard.java
com.markjmind.mobile.api.android.ui.drawgraph.GraphSkin.java
com.markjmind.mobile.api.android.ui.drawgraph.HBackLineSkin.java
com.markjmind.mobile.api.android.ui.drawgraph.LineGraphSkin.java
com.markjmind.mobile.api.android.ui.drawgraph.PieGraph.java
com.markjmind.mobile.api.android.ui.drawgraph.RectGraphSkin.java
com.markjmind.mobile.api.android.ui.drawgraph.SimpleStyle.java
com.markjmind.mobile.api.android.ui.drawgraph.TextArraySkin.java
com.markjmind.mobile.api.android.ui.drawgraph.VBackLineSkin.java
com.markjmind.mobile.api.android.ui.graph.Arc.java
com.markjmind.mobile.api.android.ui.graph.BarElement.java
com.markjmind.mobile.api.android.ui.graph.BarLayout.java
com.markjmind.mobile.api.android.ui.graph.Bar.java
com.markjmind.mobile.api.android.ui.graph.IPieSkin.java
com.markjmind.mobile.api.android.ui.graph.LineLayout.java
com.markjmind.mobile.api.android.ui.graph.MeasureLayout.java
com.markjmind.mobile.api.android.ui.graph.PieArcRoundSkin.java
com.markjmind.mobile.api.android.ui.graph.PieLayout.java
com.markjmind.mobile.api.android.ui.graph.PiePercentSkin.java
com.markjmind.mobile.api.android.ui.view.JwBaseDropDown.java
com.markjmind.mobile.api.android.ui.view.JwDropDown.java
com.markjmind.mobile.api.android.ui.view.JwSlidingLayout.java
com.markjmind.mobile.api.android.ui.view.JwWheelView.java
com.markjmind.mobile.api.android.ui.view.StickerListener.java
com.markjmind.mobile.api.android.ui.view.StickerView.java
com.markjmind.mobile.api.android.ui.view.textview.JwTextViewAutoScale.java
com.markjmind.mobile.api.android.ui.view.textview.JwTextViewFonts.java
com.markjmind.mobile.api.android.ui.view.textview.JwTextViewWrapScale.java
com.markjmind.mobile.api.android.ui.wrapper.JwAlertDialog.java
com.markjmind.mobile.api.android.ui.wrapper.JwToast.java
com.markjmind.mobile.api.android.util.JwFile.java
com.markjmind.mobile.api.android.util.JwPreferenceList.java
com.markjmind.mobile.api.android.util.JwPreference.java
com.markjmind.mobile.api.android.util.JwSound.java
com.markjmind.mobile.api.android.util.JwTextUtils.java
com.markjmind.mobile.api.android.util.PhoneInfo.java
com.markjmind.mobile.api.android.util.WebConnection.java
com.markjmind.mobile.api.android.xml.JwDomHandler.java
com.markjmind.mobile.api.android.xml.JwDomLoader.java
com.markjmind.mobile.api.android.xml.JwEditElementHandler.java
com.markjmind.mobile.api.android.xml.JwXmlLoader.java
com.markjmind.mobile.api.android.xml.JwXmlResoure.java
com.markjmind.mobile.api.hub.ArrayJDhub.java
com.markjmind.mobile.api.hub.DBhub.java
com.markjmind.mobile.api.hub.JDhub.java
com.markjmind.mobile.api.hub.Loader.java
com.markjmind.mobile.api.hub.StoreList.java
com.markjmind.mobile.api.hub.Store.java