Package anvil.core

Examples of anvil.core.Array


  }
 

  public Any eval()
  {
    Array array = new Array();
    int n = childs();
    for(int i=0; i<n; i++) {
      Node node = getChild(i);
      if (node.typeOf() == Node.EXPR_MAPPING) {
        MappingNode mapnode = (MappingNode)node;
        array.append(mapnode.getKey(), mapnode.getValue());
      } else {
        array.append(node.eval());
      }
    }
    return array;
  }
View Full Code Here


        String subject, String content, Any attachments)
  {
    try {
      Vector vector = new Vector();
      if (attachments.isArray()) {
        Array array = attachments.toArray();
        for (int i=0; i<array.size(); i++) {
          vector.add(array.elementAt(i).toObject());
        }
      }
      MailUtils.sendMail(host, from, to, cc, subject, content, vector);
      return Any.TRUE;
    } catch (Exception e) {
View Full Code Here

  /// Returns an array containing all the properties from
  /// <code>application</code> configuration section.
  /// @synopsis array getProperties()
  public static final Any getProperties(Context context)
  {
    Array props = new Array();
    ApplicationPreferences app = context.address().getZone().getApplicationPreferences();
    if (app != null) {
      String[] names = app.getAdditionalPreferenceNames();
      final int n = names.length;
      for(int i=0; i<n; i++) {
        props.put(new AnyString(names[i]), Any.create(app.getPreference(names[i])));
      }
    }
    return props;
  }
View Full Code Here

  /// Returns an array of system properties from underlying JVM.
  /// @synopsis array getSystemProperties()
  public static final Any getSystemProperties()
  {
    Properties properties = System.getProperties();
    Array list = new Array(properties.size());
    list.append("anvil.version", Any.create(anvil.Version.getVersion()));
    list.append("anvil.build", Any.create(anvil.Version.getBuild()));
    list.append("anvil.fullversion", Any.create(anvil.Version.getFullVersion()));
    Enumeration e = properties.propertyNames();
    while(e.hasMoreElements()) {
      String name = (String)e.nextElement();
      list.append(name, Any.create(properties.getProperty(name)));
    }
    return Any.create(list);
  }
View Full Code Here

  {
    context.checkConnect(host, -1);
    try {
      InetAddress[] addrs = InetAddress.getAllByName(host);
      int n = addrs.length;
      Array list = new Array(n);
      for(int i=0; i<n; i++) {
        list.append(new AnyInetAddress(addrs[i]));
      }
      return list;
    } catch (UnknownHostException e) {
      throw context.exception(e);
    }
View Full Code Here

  /// @synopsis array getSessions()
  public Any m_getSessions()
  {
    Session[] sessions = _container.getSessions();
    int n = sessions.length;
    Array array = new Array(n+1);
    for(int i=0; i<n ;i++) {
      Session session = sessions[i];
      array.append(Any.create(session.getId()), new AnySession(session));
    }
    return array;
  }
View Full Code Here

            break;
          }
        }
      }
      Enumeration e = ((Scope)_type).getDeclarations();
      Array types = new Array();
      while(e.hasMoreElements()) {
        Type type = (Type)e.nextElement();
        if ((ofType == 0) || (type.getType() == ofType)) {
          types.put(new AnyString(type.getName()), new AnyType(type));
        }
      }
      return types;
    }
    return UNDEFINED;
View Full Code Here

  {
    if (_type instanceof CompilableFunction) {
      CompilableFunction function = (CompilableFunction)_type;
      int max = function.getParameterCount();
      int min = function.getMinimumParameterCount();
      Array list = new Array();
      Any value;
      int count = 0;
      boolean required;
      Doc doc;
      for(int i=0; i<max; i++) {
        switch(function.getParameterType(i)) {
        case CompilableFunction.PARAMETER_CONTEXT:
          break;
        case CompilableFunction.PARAMETER_ANY:
        case CompilableFunction.PARAMETER_STRING:
        case CompilableFunction.PARAMETER_OBJECT:
        case CompilableFunction.PARAMETER_DOUBLE:
        case CompilableFunction.PARAMETER_INT:
        case CompilableFunction.PARAMETER_LONG:
        case CompilableFunction.PARAMETER_BOOLEAN:
          required = (count < min);
          if (count >= min) {
            value = function.getParameterDefault(i);
            if (value == null) {
              value = UNDEFINED;
            }
          } else {
            value = UNDEFINED;
          }
          doc = function.getParameterDoc(i);
          list.append(new AnyString(function.getParameterName(i)),
            new AnyTuple(new Any[] {
              required ? Any.TRUE : Any.FALSE,
              value,
              Any.create((doc != null) ? doc.getText() : null),
              Any.create((doc != null) ? doc.getChildText(doc.T_TYPE, null) : null)
            }));
          count++;
          break;
         
        case CompilableFunction.PARAMETER_ARRAY:
        case CompilableFunction.PARAMETER_ANYLIST:
        case CompilableFunction.PARAMETER_LIST:
          doc = function.getParameterDoc(i);
          list.append(DOTDOT, new AnyTuple(new Any[] {
              new AnyString(function.getParameterName(i)),
              Any.create((doc != null) ? doc.getText() : null),
              Any.create((doc != null) ? doc.getChildText(doc.T_TYPE, null) : null)
            }));
          break;
View Full Code Here

      int end;
      int new_start;
      int length = name.length();
      Any key;
      Any any;
      Array array;

      key = new AnyString(name.substring(0, start).trim());
      any = base.get(key);
      if ((any == null) || !any.isArray()) {
        array = new Array();
        base.put(key, array);
      } else {
        array = any.toArray();
      }
      base = array;
     
      do {
        end = name.indexOf(']', start + 1);
        if (end == -1) {
          end = length;
        }
       
        new_start = name.indexOf('[', end+1);

        key = createKey(name.substring(start+1, end).trim());
        if (new_start > 0) {
          any = base.get(key);
          if ((any == null) || !any.isArray()) {
            array = new Array();
            base.put(key, array);
          } else {
            array = any.toArray();
          }
          base = array;
View Full Code Here

  ///    Returns an array of all the header names this request contains.
  ///  @synopsis array getHeaderNames()
  ///  @return header names
  public Any m_getHeaderNames()
  {
    Array array = new Array();
    Enumeration enu = _request.getHeaderNames();
    while (enu.hasMoreElements()) {
      array.append(Any.create((String)enu.nextElement()));
    }
    return array;
  }
View Full Code Here

TOP

Related Classes of anvil.core.Array

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.