Package com.ibm.jscript.std

Examples of com.ibm.jscript.std.ArrayObject


    return o;
  }
 
  // Make sure the Json objects are what is expected
  protected void fixAPIObject(ObjectObject o, String baseDocUrl, String unid) throws Exception {
    ArrayObject items = (ArrayObject)o.get("items");

    ArrayObject result = items;
    if(StringUtil.isNotEmpty(unid)) {
      result = new ArrayObject();
      o.put("items", result);
    }
    int count = items.getArrayLength();
    for(int i=0; i<count; i++) {
      ObjectObject item = (ObjectObject)items.getArrayElement(i);
      // Fix the unid if it doesn't exist
      fixSnippetUnid(item);
      // And then filter it, or just fix it
      if(result!=items) {
        String oid = item.get("unid").stringValue();
        if(oid.equals(unid)) {
          fixItem(item,baseDocUrl);
          result.addArrayValue(item);
          return;
        }
      } else {
        fixItem(item,baseDocUrl);
      }
View Full Code Here


  }
 
  protected void fixUriParameters(ObjectObject o) throws Exception {
    FBSValue params = o.get("uriParameters");
    if(!(params instanceof ArrayObject)) {
      params = new ArrayObject();
      ((ObjectObject)o).put("uriParameters",params);
    }
    // Look if there are missing parameters in the URI
    extract((ArrayObject)params,o,"uri");
  }
View Full Code Here

    extract((ArrayObject)params,o,"uri");
  }
  protected void fixQueryParameters(ObjectObject o) throws Exception {
    FBSValue params = o.get("queryParameters");
    if(!(params instanceof ArrayObject)) {
      params = new ArrayObject();
      ((ObjectObject)o).put("queryParameters",params);
    }
  }
View Full Code Here

    }
  }
  protected void fixHeaders(ObjectObject o) throws Exception {
    FBSValue params = o.get("headers");
    if(!(params instanceof ArrayObject)) {
      params = new ArrayObject();
      ((ObjectObject)o).put("headers",params);
    }
  }
View Full Code Here

  }
 
 
  public Object loadParameters(Object o) throws Exception {
    ObjectObject item = (ObjectObject)o;
    ArrayObject a = new ArrayObject(jsContext);

    FBSValue a1 = (FBSValue)item.get("uriParameters");
    if(a1.isArray()) {
      for(int i=0; i<a1.getArrayLength(); i++) {
        a.addArrayValue(a1.getArrayValue(i));
      }
    }
   
    FBSValue a2 = (FBSValue)item.get("queryParameters");
    if(a2.isArray()) {
      for(int i=0; i<a2.getArrayLength(); i++) {
        a.addArrayValue(a2.getArrayValue(i));
      }
    }
   
    FBSValue a3 = (FBSValue)item.get("headers");
    if(a3.isArray()) {
      for(int i=0; i<a3.getArrayLength(); i++) {
        a.addArrayValue(a3.getArrayValue(i));
      }
    }

    // Add a pseudo query string parameter
    boolean qstring = item.get("queryString").booleanValue();
View Full Code Here

    private static Pattern paramsPattern = Pattern.compile("%\\{(.*?)\\}");
   
  public FBSDefaultObject extractParams(String[] ss) throws InterpretException {
    PlaygroundEnvironment env = PlaygroundEnvironment.getCurrentEnvironment();
   
    ArrayObject params = new ArrayObject(JavaScriptUtil.getJSContext());
    if(ss!=null) {
      for(int i=0; i<ss.length; i++) {
          Matcher paramsMatcher = paramsPattern.matcher(ss[i]);
          while(paramsMatcher.find()){
            String s = paramsMatcher.group(1);
            String[] all = StringUtil.splitString(s, '|', true);
          FBSDefaultObject o = new ObjectObject(JavaScriptUtil.getJSContext());
            for(int j=0; j<all.length; j++) {
              String[] p = StringUtil.splitString(all[j], '=', true);
              if(p.length==1) {
                o.put("name", FBSString.get(p[0]));
              } else if(p.length>1) {
                o.put(p[0],FBSString.get(p[1]));
              }
            }
            FBSString propName = (FBSString)o.get("name");
            if(propName!=null) {
              String v = env.getPropertyValueByName(propName.stringValue());
              if(StringUtil.isNotEmpty(v)) {
                o.put("value", FBSString.get(v));
              }
            }
            params.addArrayValue(o);
          }
      }
    }
    return params;
  }
View Full Code Here

TOP

Related Classes of com.ibm.jscript.std.ArrayObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.