예제 #1
0
 public static String getMessage(IExceptionCode code) {
   if (code == null) code = BaseExceptions.UNKNOWN_EXCEPTION;
   try {
     Field field = code.getClass().getField(code.name());
     Desc descAnnotation = field.getAnnotation(Desc.class);
     if (descAnnotation == null) return code.name();
     else if (descAnnotation.value() == null || "".equals(descAnnotation.value().trim()))
       return code.name();
     else return descAnnotation.value();
   } catch (Throwable e) {
     return code.name();
   }
 }
예제 #2
0
파일: Misc4.java 프로젝트: jrh327/UMoria
  /* Add a comment to an object description.		-CJS- */
  public static void scribe_object() {
    IntPointer item_val = new IntPointer();
    int j;
    String out_val, tmp_str;

    if (Treasure.inven_ctr > 0 || Treasure.equip_ctr > 0) {
      if (Moria1.get_item(item_val, "Which one? ", 0, Constants.INVEN_ARRAY_SIZE, "", "")) {
        tmp_str = Desc.objdes(Treasure.inventory[item_val.value()], true);
        out_val = String.format("Inscribing %s", tmp_str);
        IO.msg_print(out_val);
        if (!Treasure.inventory[item_val.value()].inscrip.isEmpty()) {
          out_val =
              String.format(
                  "Replace %s New inscription:", Treasure.inventory[item_val.value()].inscrip);
        } else {
          out_val = "Inscription: ";
        }
        j = 78 - tmp_str.length();
        if (j > 12) {
          j = 12;
        }
        IO.prt(out_val, 0, 0);
        if (!(out_val = IO.get_string(0, out_val.length(), j)).equals("")) {
          inscribe(Treasure.inventory[item_val.value()], out_val);
        }
      }
    } else {
      IO.msg_print("You are not carrying anything to inscribe.");
    }
  }
예제 #3
0
    @SuppressWarnings("deprecation")
    @Override
    protected String doInBackground(String... arg0) {
      // TODO Auto-generated method stub

      SiteList.Log_reps.clear();

      SiteList.Exc_Name.clear();

      SiteList.Exces_Id.clear();

      SiteList.Log_Date.clear();

      SiteList.Log_Ints.clear();

      SiteList.Log_Sets.clear();

      SiteList.Vid_imgList.clear();

      SiteList.Vid_descriptionList.clear();

      SiteList.Vid_pathList.clear();

      SiteList.Vid_titleList.clear();

      SiteList.Dir_imageList.clear();

      SiteList.Dir_descriptionList.clear();

      SiteList.Error.clear();

      if (Methodcall.equalsIgnoreCase("submit")) {

        Date dt = new Date();
        fromUser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        myFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String dat = "";
        dat = myFormat.format(new Date());

        System.out.println("dat   " + dat);

        System.out.println(
            "comlete string is              "
                + "     "
                + AllLink.putLogs
                + "{"
                + "\"userid\""
                + ":"
                + "\""
                + customDialogClass.pref.getString(AllLink.UserId, "")
                + "\""
                + ","
                + "\"auth\""
                + ":"
                + "\""
                + customDialogClass.pref.getString(AllLink.AuthKey, "")
                + "\""
                + " , "
                + "\"execid\""
                + ":"
                + "\""
                + Id
                + "\""
                + " , "
                + "\"logintensity\""
                + ":"
                + "\""
                + Ed3.getText().toString()
                + "\""
                + " , "
                + "\"logset\""
                + ":"
                + "\""
                + Ed1.getText().toString()
                + "\""
                + " , "
                + "\"logrep\""
                + ":"
                + "\""
                + Ed2.getText().toString()
                + "\""
                + " , "
                + "\"lognotes\""
                + ":"
                + "\""
                + Ed4.getText().toString()
                + "\""
                + " , "
                + "\"logdate\""
                + ":"
                + "\""
                + dat
                + "\""
                + "}");

        String encoded =
            URLEncoder.encode(
                "{"
                    + "\"userid\""
                    + ":"
                    + "\""
                    + customDialogClass.pref.getString(AllLink.UserId, "")
                    + "\""
                    + ","
                    + "\"auth\""
                    + ":"
                    + "\""
                    + customDialogClass.pref.getString(AllLink.AuthKey, "")
                    + "\""
                    + " , "
                    + "\"execid\""
                    + ":"
                    + "\""
                    + Id
                    + "\""
                    + " , "
                    + "\"logintensity\""
                    + ":"
                    + "\""
                    + Ed3.getText().toString()
                    + "\""
                    + " , "
                    + "\"logrep\""
                    + ":"
                    + "\""
                    + Ed1.getText().toString()
                    + "\""
                    + " , "
                    + "\"logset\""
                    + ":"
                    + "\""
                    + Ed2.getText().toString()
                    + "\""
                    + " , "
                    + "\"lognotes\""
                    + ":"
                    + "\""
                    + Ed4.getText().toString()
                    + "\""
                    + " , "
                    + "\"logdate\""
                    + ":"
                    + "\""
                    + dat
                    + "\""
                    + "}");

        jsonObject_Put = jsonParser.getJSONFromUrl(AllLink.putLogs + encoded);

        System.out.println("jsonObject_Put    " + jsonObject_Put);

        try {
          if (jsonObject_Put != null) {
            System.out.println("status of put is  inside1   ");
            if (jsonObject_Put.getString("status").equals("success")) {
              System.out.println("status of put is   inside2  ");
              if (jsonObject_Put.getString("message") != null) {

                System.out.println("status of put is   inside3  ");
                done_is = true;
                MessageDisplay_Submit = jsonObject_Put.getString("message");

                System.out.println("status of put is     " + MessageDisplay);
              }
            } else {
              System.out.println("status of put is   inside4  ");
              MessageDisplay_Submit = jsonObject_Put.getString("error");
            }
          }

        } catch (JSONException e) {

          // TODO Auto-generated catch block
          e.printStackTrace();
          try {
            System.out.println("status of put is   inside5  ");
            MessageDisplay = jsonObject_Put.getString("error");
          } catch (JSONException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
          }
        }

        Methodcall = "show";
      }

      /* here "show" tells which action to be performed */

      if (Methodcall.equalsIgnoreCase("show")) {

        System.out.println("inside show");

        System.out.println(
            "comlete string is              "
                + "     "
                + AllLink.CheckExcercise
                + "{"
                + "\"userid\""
                + ":"
                + "\""
                + customDialogClass.pref.getString(AllLink.UserId, "")
                + "\""
                + ","
                + "\"auth\""
                + ":"
                + "\""
                + customDialogClass.pref.getString(AllLink.AuthKey, "")
                + "\""
                + " , "
                + "\"execid\""
                + " : "
                + ""
                + "\""
                + Id
                + "\""
                + "}");

        String encoded =
            URLEncoder.encode(
                "{"
                    + "\"userid\""
                    + ":"
                    + "\""
                    + customDialogClass.pref.getString(AllLink.UserId, "")
                    + "\""
                    + ","
                    + "\"auth\""
                    + ":"
                    + "\""
                    + customDialogClass.pref.getString(AllLink.AuthKey, "")
                    + "\""
                    + " , "
                    + "\"execid\""
                    + ":"
                    + "\""
                    + Id
                    + "\""
                    + "}");

        jsonObject = jsonParser.getJSONFromUrl(AllLink.CheckExcercise + encoded);

        if (jsonObject != null) {
          try {

            Status = jsonObject.getString("status");

            if (Status.equalsIgnoreCase("success")) {

              MessageDisplay = jsonObject.getString("msg");

            } else {
              MessageDisplay = "Error";
            }
          } catch (JSONException e1) {
            // TODO Auto-generated catch block

            e1.printStackTrace();
          }
        }

        encoded =
            URLEncoder.encode(
                "{"
                    + "\"userid\""
                    + ":"
                    + "\""
                    + customDialogClass.pref.getString(AllLink.UserId, "")
                    + "\""
                    + ","
                    + "\"auth\""
                    + ":"
                    + "\""
                    + customDialogClass.pref.getString(AllLink.AuthKey, "")
                    + "\""
                    + " , "
                    + ""
                    + "\"execid\""
                    + ":"
                    + "\""
                    + Id
                    + "\""
                    + "}");

        System.out.println(
            "complete link is     "
                + AllLink.getLogs
                + "{"
                + "\"userid\""
                + ":"
                + "\""
                + customDialogClass.pref.getString(AllLink.UserId, "")
                + "\""
                + ","
                + "\"auth\""
                + ":"
                + "\""
                + customDialogClass.pref.getString(AllLink.AuthKey, "")
                + "\""
                + " , "
                + ""
                + "\"execid\""
                + ":"
                + "\""
                + Id
                + "\""
                + "}");

        jsonObject2 = jsonParser.getJSONFromUrl(AllLink.getLogs + encoded);

        System.out.println("jsonObject2     " + jsonObject2);
        if (jsonObject2 != null) {

          try {

            StatusLog = jsonObject2.getString("status");

            System.out.println("StatusLog     " + StatusLog);

            if (StatusLog.equalsIgnoreCase("success")) {

              try {
                MesageList = jsonObject2.getJSONArray("data");

                if (MesageList.length() > 0) {
                  for (int i = 0; i < MesageList.length(); i++) {

                    JSONObject c = MesageList.getJSONObject(i);
                    //

                    /* log_reps */

                    if ((c.getString("log_reps")).length() > 0) {
                      SiteList.Log_reps.add(c.getString("log_reps"));
                    } else {
                      SiteList.Log_reps.add("");
                    }

                    /* excercise Name */

                    if ((c.getString("execname")).length() > 0) {

                      SiteList.Exc_Name.add(c.getString("execname"));
                    } else {
                      SiteList.Exc_Name.add("");
                    }

                    /* Log Date */

                    if ((c.getString("log_date")).length() > 0) {

                      SiteList.Log_Date.add(c.getString("log_date"));
                    } else {

                      SiteList.Log_Date.add("");
                    }

                    /* log_intensity */

                    if ((c.getString("log_intensity")).length() > 0) {

                      SiteList.Log_Ints.add(c.getString("log_intensity"));
                    } else {
                      SiteList.Log_Ints.add("");
                    }

                    /* -----------    execid  --------------  */

                    if ((c.getString("execid")).length() > 0) {

                      SiteList.Exces_Id.add(c.getString("execid"));
                    } else {
                      SiteList.Exces_Id.add("");
                    }

                    /* -----------    execid  --------------  */

                    if ((c.getString("log_sets")).length() > 0) {

                      SiteList.Log_Sets.add(c.getString("log_sets"));
                    } else {
                      SiteList.Log_Sets.add("");
                    }
                  }

                } else {
                  SiteList.Error.add(jsonObject2.getString("error") + " " + " data exist");
                }
              } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }

            } else {

              System.out.println("status log is    " + StatusLog);

              oneValue[0] = MessageDisplay;
            }
          } catch (JSONException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
          }
        }
        System.out.println("Status Status    " + Status);

        //						if(Status.equalsIgnoreCase("success"))
        //						{
        try {
          String query =
              URLEncoder.encode(
                  "{"
                      + "\"execid\""
                      + ":"
                      + "\""
                      + Id
                      + "\""
                      + ","
                      + "\"auth\""
                      + ":"
                      + "\""
                      + customDialogClass.pref.getString(AllLink.AuthKey, "")
                      + "\""
                      + "}",
                  "utf-8");

          String url = AllLink.Excercise + query;

          jsonObject3 = jsonParser.getJSONFromUrl(url);

          Videos = jsonObject3.getJSONArray(VideoParentTag);

          Desc = jsonObject3.getJSONArray(DirectionTag);

          //							System.out.println("contacts length is    " +contacts);

          //		String Exc_name        = jsonObject3.getString("exc_name");
          //		String Exc_description = jsonObject3.getString("exc_description");

          // looping through All Contacts

          for (int i = 0; i < Desc.length(); i++) {

            System.out.println("i   " + i);
            JSONObject c = Desc.getJSONObject(i);

            if (c.getString(Dir_image) != null) {
              SiteList.Dir_imageList.add(c.getString(Dir_image));
            } else {

              SiteList.Dir_imageList.add("");
            }
            if (c.getString(Dir_description) != null) {
              SiteList.Dir_descriptionList.add(c.getString(Dir_description));
            } else {

              SiteList.Dir_descriptionList.add("");
            }
          }

          for (int i = 0; i < Videos.length(); i++) {

            System.out.println("i   " + i);
            JSONObject c = Videos.getJSONObject(i);

            if (c.getString(Vid_img) != null) {
              SiteList.Vid_imgList.add(c.getString(Vid_img));
            } else {

              SiteList.Vid_imgList.add("");
            }

            if (c.getString(Vid_description) != null) {
              SiteList.Vid_descriptionList.add(c.getString(Vid_description));
            } else {

              SiteList.Vid_descriptionList.add("");
            }

            if (c.getString(Vid_path) != null) {

              SiteList.Vid_pathList.add(c.getString(Vid_path));
            } else {

              SiteList.Vid_pathList.add("");
            }

            if (c.getString(Vid_title) != null) {
              SiteList.Vid_titleList.add(c.getString(Vid_title));
            } else {

              SiteList.Vid_titleList.add("");
            }
          }

          System.out.println("Dir_imageList is         " + SiteList.Dir_imageList);
          System.out.println("Dir_descriptionList is   " + SiteList.Dir_descriptionList);
          System.out.println("Vid_imgList is           " + SiteList.Vid_imgList);
          System.out.println("Vid_descriptionList is   " + SiteList.Vid_descriptionList);

        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        //						}
        //						else {
        //
        //
        //							System.out.println("error in fetching " +
        //									"exercise data");
        //						}
      }

      return null;
    }