home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 August / PCO0897.ISO / filesbbs / os2 / fp1os2.arj / OS2 / DATA / 49 / C / 0 / F_26836 / JScriptStringObject.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-05-15  |  6.0 KB  |  220 lines

  1. public class JScriptStringObject extends JSbxObject implements JSbxPropertyInterface {
  2.    public static final String NAME = "String";
  3.    private String aStr = "";
  4.    private static final int STRING_ID_ANCHOR = 1;
  5.    private static final int STRING_ID_BIG = 2;
  6.    private static final int STRING_ID_BLINK = 3;
  7.    private static final int STRING_ID_BOLD = 4;
  8.    private static final int STRING_ID_CHARAT = 5;
  9.    private static final int STRING_ID_FIXED = 6;
  10.    private static final int STRING_ID_FONTCOLOR = 7;
  11.    private static final int STRING_ID_FONTSIZE = 8;
  12.    private static final int STRING_ID_INDEXOF = 9;
  13.    private static final int STRING_ID_ITALICS = 10;
  14.    private static final int STRING_ID_LASTINDEXOF = 11;
  15.    private static final int STRING_ID_LINK = 12;
  16.    private static final int STRING_ID_SMALL = 13;
  17.    private static final int STRING_ID_STRIKE = 14;
  18.    private static final int STRING_ID_SUB = 15;
  19.    private static final int STRING_ID_SUBSTRING = 16;
  20.    private static final int STRING_ID_SUP = 17;
  21.    private static final int STRING_ID_TOLOWERCASE = 18;
  22.    private static final int STRING_ID_TOUPPERCASE = 19;
  23.    private static final int STRING_ID_LENGTH = 20;
  24.    private static final int STRING_ID_SPLIT = 21;
  25.    private static final int STRING_ID_COMPARETO = 22;
  26.  
  27.    public void SetString(String var1) {
  28.       this.aStr = var1;
  29.    }
  30.  
  31.    public String GetString() {
  32.       return this.aStr;
  33.    }
  34.  
  35.    public JScriptStringObject(JScriptConstructor var1) {
  36.       super(var1);
  37.  
  38.       try {
  39.          ((JSbxObject)this).Put(new JSbxObjectProperty("anchor", this, this, 1));
  40.          ((JSbxObject)this).Put(new JSbxObjectProperty("big", this, this, 2));
  41.          ((JSbxObject)this).Put(new JSbxObjectProperty("blink", this, this, 3));
  42.          ((JSbxObject)this).Put(new JSbxObjectProperty("bold", this, this, 4));
  43.          ((JSbxObject)this).Put(new JSbxObjectProperty("charAt", this, this, 5));
  44.          ((JSbxObject)this).Put(new JSbxObjectProperty("fixed", this, this, 6));
  45.          ((JSbxObject)this).Put(new JSbxObjectProperty("fontcolor", this, this, 7));
  46.          ((JSbxObject)this).Put(new JSbxObjectProperty("fontsize", this, this, 8));
  47.          ((JSbxObject)this).Put(new JSbxObjectProperty("indexOf", this, this, 9));
  48.          ((JSbxObject)this).Put(new JSbxObjectProperty("italics", this, this, 10));
  49.          ((JSbxObject)this).Put(new JSbxObjectProperty("lastIndexOf", this, this, 11));
  50.          ((JSbxObject)this).Put(new JSbxObjectProperty("link", this, this, 12));
  51.          ((JSbxObject)this).Put(new JSbxObjectProperty("small", this, this, 13));
  52.          ((JSbxObject)this).Put(new JSbxObjectProperty("strike", this, this, 14));
  53.          ((JSbxObject)this).Put(new JSbxObjectProperty("sub", this, this, 15));
  54.          ((JSbxObject)this).Put(new JSbxObjectProperty("substring", this, this, 16));
  55.          ((JSbxObject)this).Put(new JSbxObjectProperty("sup", this, this, 17));
  56.          ((JSbxObject)this).Put(new JSbxObjectProperty("toLowerCase", this, this, 18));
  57.          ((JSbxObject)this).Put(new JSbxObjectProperty("toUpperCase", this, this, 19));
  58.          ((JSbxObject)this).Put(new JSbxObjectProperty("length", this, this, 20));
  59.          ((JSbxObject)this).Put(new JSbxObjectProperty("split", this, this, 21));
  60.          ((JSbxObject)this).Put(new JSbxObjectProperty("compareTo", this, this, 22));
  61.       } catch (JSbxException var2) {
  62.       }
  63.    }
  64.  
  65.    public JSbxValue PropertyCallFunction(JSbxObjectProperty var1, JScriptCallParam var2) throws JSbxExceptionBase {
  66.       JSbxVector var3 = var2.GetParamVector();
  67.       int var4 = var3 != null ? var3.GetSize() : 0;
  68.       int var5 = var1.GetID();
  69.       JSbxValue var6 = null;
  70.       String var7 = "";
  71.       double var8 = (double)0.0F;
  72.       boolean var10 = false;
  73.       boolean var11 = false;
  74.       switch (var5) {
  75.          case 1:
  76.             var7 = "<A NAME=\"" + JScriptWindowObject.GetStringParam(var3, 0) + "\">" + this.aStr + "</A>";
  77.             break;
  78.          case 2:
  79.             var7 = "<BIG>" + this.aStr + "</BIG>";
  80.             break;
  81.          case 3:
  82.             var7 = "<BLINK>" + this.aStr + "</BLINK>";
  83.             break;
  84.          case 4:
  85.             var7 = "<B>" + this.aStr + "</B>";
  86.             break;
  87.          case 5:
  88.             try {
  89.                int var21 = (int)JScriptWindowObject.GetDoubleParam(var3, 0);
  90.                var7 = this.aStr.substring(var21, var21 + 1);
  91.             } catch (StringIndexOutOfBoundsException var19) {
  92.             }
  93.             break;
  94.          case 6:
  95.             var7 = "<TT>" + this.aStr + "</TT>";
  96.             break;
  97.          case 7:
  98.             var7 = "<FONT COLOR=\"" + JScriptWindowObject.GetStringParam(var3, 0) + "\">" + this.aStr + "</FONT>";
  99.             break;
  100.          case 8:
  101.             var7 = "<FONT SIZE=\"" + JScriptWindowObject.GetStringParam(var3, 0) + "\">" + this.aStr + "</FONT>";
  102.             break;
  103.          case 9:
  104.             if (var4 > 1) {
  105.                var8 = (double)this.aStr.indexOf(JScriptWindowObject.GetStringParam(var3, 0), (int)JScriptWindowObject.GetDoubleParam(var3, 1));
  106.             } else {
  107.                var8 = (double)this.aStr.indexOf(JScriptWindowObject.GetStringParam(var3, 0));
  108.             }
  109.  
  110.             var10 = true;
  111.             break;
  112.          case 10:
  113.             var7 = "<I>" + this.aStr + "</I>";
  114.             break;
  115.          case 11:
  116.             if (var4 > 1) {
  117.                var8 = (double)this.aStr.lastIndexOf(JScriptWindowObject.GetStringParam(var3, 0), (int)JScriptWindowObject.GetDoubleParam(var3, 1));
  118.             } else {
  119.                var8 = (double)this.aStr.lastIndexOf(JScriptWindowObject.GetStringParam(var3, 0));
  120.             }
  121.  
  122.             var10 = true;
  123.             break;
  124.          case 12:
  125.             var7 = "<A HREF=\"" + JScriptWindowObject.GetStringParam(var3, 0) + "\">" + this.aStr + "</A>";
  126.             break;
  127.          case 13:
  128.             var7 = "<SMALL>" + this.aStr + "</SMALL>";
  129.             break;
  130.          case 14:
  131.             var7 = "<STRIKE>" + this.aStr + "</STRIKE>";
  132.             break;
  133.          case 15:
  134.             var7 = "<SUB>" + this.aStr + "</SUB>";
  135.             break;
  136.          case 16:
  137.             int var12 = (int)JScriptWindowObject.GetDoubleParam(var3, 0);
  138.             var12 = JScriptTools.CheckStringIndex(this.aStr, var12);
  139.             if (var4 > 1) {
  140.                int var22 = (int)JScriptWindowObject.GetDoubleParam(var3, 1);
  141.                var22 = JScriptTools.CheckStringIndex(this.aStr, var22);
  142.                var7 = this.aStr.substring(var12, var22);
  143.             } else {
  144.                var7 = this.aStr.substring(var12);
  145.             }
  146.             break;
  147.          case 17:
  148.             var7 = "<SUP>" + this.aStr + "</SUP>";
  149.             break;
  150.          case 18:
  151.             var7 = this.aStr.toLowerCase();
  152.             break;
  153.          case 19:
  154.             var7 = this.aStr.toUpperCase();
  155.          case 20:
  156.          default:
  157.             break;
  158.          case 21:
  159.             String var13 = JScriptWindowObject.GetStringParam(var3, 0);
  160.             JScriptArrayObject var14 = (JScriptArrayObject)JScriptManager.CreateClassObject("Array");
  161.             int var15 = 0;
  162.             int var16 = 0;
  163.  
  164.             int var17;
  165.             for(var17 = 0; (var16 = this.aStr.indexOf(var13, var17)) >= 0; ++var15) {
  166.                JSbxValueProperty var18 = new JSbxValueProperty(String.valueOf(var15), (JSbxObject)null, new JSbxValue(this.aStr.substring(var17, var16)));
  167.                ((JSbxObject)var14).Put(var15, var18);
  168.                var17 = var16 + var13.length();
  169.             }
  170.  
  171.             JSbxValueProperty var25 = new JSbxValueProperty(String.valueOf(var15), (JSbxObject)null, new JSbxValue(this.aStr.substring(var17, this.aStr.length())));
  172.             ((JSbxObject)var14).Put(var15, var25);
  173.             var6 = new JSbxValue(var14);
  174.             var11 = true;
  175.             break;
  176.          case 22:
  177.             if (var4 > 0) {
  178.                var8 = (double)this.aStr.compareTo(JScriptWindowObject.GetStringParam(var3, 0));
  179.             } else {
  180.                var8 = (double)this.aStr.compareTo("");
  181.             }
  182.  
  183.             var10 = true;
  184.       }
  185.  
  186.       if (!var11) {
  187.          if (var10) {
  188.             var6 = new JSbxValue(var8);
  189.          } else {
  190.             var6 = new JSbxValue(var7);
  191.          }
  192.       }
  193.  
  194.       var2.GetRuntimeParam().SetReturnValue(var6);
  195.       return var6;
  196.    }
  197.  
  198.    public void PropertyGet(JSbxObjectProperty var1, JSbxValue var2) throws JSbxException {
  199.       int var3 = var1.GetID();
  200.       double var4 = (double)0.0F;
  201.       switch (var3) {
  202.          case 20:
  203.             var4 = (double)this.aStr.length();
  204.          default:
  205.             var2.Put(new JSbxValue(var4));
  206.       }
  207.    }
  208.  
  209.    public void PropertyPut(JSbxObjectProperty var1, JSbxValue var2) throws JSbxException {
  210.    }
  211.  
  212.    public String Property_GetJScript_typeofString(JSbxObjectProperty var1) {
  213.       return "stringobject";
  214.    }
  215.  
  216.    public String GetJScriptString(boolean var1) {
  217.       return this.aStr;
  218.    }
  219. }
  220.