Package com.ibm.jscript.types

Examples of com.ibm.jscript.types.FBSValue


          if(StringUtil.isNotEmpty(baseDocUrl)) {
            o.put("doc_url", FBSString.get(baseDocUrl));
          }
          String json = doc.getItemValueString("Json");
          if(StringUtil.isNotEmpty(json)) {
            FBSValue value = (FBSValue)JsonParser.fromJson(new JsonJavaScriptFactory(jsContext), json);
            o.put("items", value);
          }
          fixAPIObject(o,baseDocUrl,unid);
        }
      }
View Full Code Here


    // Load the full documentation URL
    fixDocUrl(item,baseDocUrl);
  }
 
  protected void fixSnippetUnid(ObjectObject o) throws Exception {
    FBSValue unid = o.get("unid");
    if(!unid.booleanValue()) {
      unid = FBSString.get(Node.encodeUnid(o.get("name").stringValue()));
      o.put("unid", unid);
    }
  }
View Full Code Here

      o.put("unid", unid);
    }
  }
 
  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
View Full Code Here

    }
    // Look if there are missing parameters in the URI
    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

      params = new ArrayObject();
      ((ObjectObject)o).put("queryParameters",params);
    }
  }
  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

      params = new ArrayObject();
      ((ObjectObject)o).put("headers",params);
    }
  }
  protected void fixDocUrl(ObjectObject o, String baseDocUrl) throws Exception {
    FBSValue params = o.get("doc_url");
    if(!params.isNull()) {
      String url = params.stringValue();
      if(!UrlUtil.isAbsoluteUrl(url) && StringUtil.isNotEmpty(baseDocUrl)) {
        o.put("doc_url", FBSString.get(PathUtil.concat(baseDocUrl, url, '/')));
      }
    }
  }
View Full Code Here

        o.put("doc_url", FBSString.get(PathUtil.concat(baseDocUrl, url, '/')));
      }
    }
  }
  private void extract(ArrayObject a, ObjectObject parent, String prop) throws Exception {
    FBSValue v = parent.get(prop);
    if(!v.isString()) {
      return;
    }
    String value = v.stringValue();
    int pos=0;
    do {
      int start = value.indexOf("{",pos);
      if(start>=0) {
        int end = value.indexOf("}",start);
        if(end>start+1) {
          FBSValue p = FBSUtility.wrap(value.substring(start+1,end).trim());
          if(!contains(a,p.stringValue())) {
            if(TRACE) {
              System.out.println(StringUtil.format("Missing uri property {0}",p));
            }
            addParam(a, p, FBSString.emptyString, FBSUtility.wrap("string"), FBSString.emptyString);
          }
View Full Code Here

    } while(true);
  }
  private boolean contains(ArrayObject a, String name) throws Exception {
    int count = a.getArrayLength();
    for(int i=0; i<count; i++) {
      FBSValue v = a.getArrayValue(i);
      if(v.isJSObject()) {
        FBSValue n = v.asObject().get("name");
        if(n.isString() && n.stringValue().equals(name)) {
          return true;
        }
      }
    }
    return false;
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();
    if(qstring) {
      ObjectObject qs = addParam(a, FBSString.get("query-string"), FBSString.emptyString, FBSUtility.wrap("string"), FBSUtility.wrap("Extra query string parameters, as they would appear in the URL (a=1&b=2...)"));
      qs.put("optional", FBSBoolean.TRUE);
    }
   
    // Now, add the pseudo entries for the POST/PUT content
    FBSValue v = item.get("http_method");
    if(v.isString()) {
      String m = v.stringValue();
      if(m.equalsIgnoreCase("post")||m.equalsIgnoreCase("put")) {
        ObjectObject ct = addParam(a, FBSString.get("post_content_type"), item.get("post_content_type"), FBSUtility.wrap("string"), FBSUtility.wrap("Content-Type header of the payload"));
        ct.put("optional", FBSBoolean.TRUE);
        ObjectObject bd = addParam(a, FBSString.get("post_content"), item.get("post_content"), FBSUtility.wrap("textarea"), FBSUtility.wrap("Text content sent to the service"));
        bd.put("optional", FBSBoolean.TRUE);
View Full Code Here

     */
    private Object[] toJavaArguments(final Method crystal, final FBSValueVector vec) throws InterpretException {
      Object[] result = new Object[vec.size()];
      Class<?>[] params = crystal.getParameterTypes();
      for (int i = 0; i < vec.size(); i++) {
        FBSValue val = vec.get(i);
        result[i] = val.toJavaObject(params[i]);
      }
      return result;
    }
View Full Code Here

TOP

Related Classes of com.ibm.jscript.types.FBSValue

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.