Package abstrasy

Examples of abstrasy.Node$VDelegable


    date = new Date();
    return null;
  }

  private static final Node getNumPairValue(Hash pairlist, Node k) throws Exception {
        Node res = null;
       
    if (pairlist.hasKey(k)) {
            res=pairlist.ref(k);
      if (!res.isNumber()) {
        throw new InterpreterException(StdErrors.Argument_type_mismatch);
      }
    }
       
    return res;
View Full Code Here


    return res;
  }

  private static final int getNumPairValueIfExists(int initialValue, Hash pairlist, Node k) throws Exception {
    int res = initialValue;
        Node tmp = getNumPairValue(pairlist, k);
    if (tmp != null) {
      res = (int) tmp.getNumber();
    }
    return res;
  }
View Full Code Here

      int ms = c.get(Calendar.MILLISECOND);
      int dd = c.get(Calendar.DAY_OF_MONTH);
      int mm = c.get(Calendar.MONTH);
      int yy = c.get(Calendar.YEAR);
            Hash hash=arg.getHash();
      h = getNumPairValueIfExists(h, hash, new Node(K_HOUR));
      m = getNumPairValueIfExists(m, hash, new Node(K_MINUTE));
      s = getNumPairValueIfExists(s, hash, new Node(K_SECOND));
      ms = getNumPairValueIfExists(ms,hash, new Node(K_MILLIS));
      dd = getNumPairValueIfExists(dd, hash, new Node(K_DAY));
      mm = getNumPairValueIfExists(mm, hash, new Node(K_MONTH)) - 1;
      yy = getNumPairValueIfExists(yy, hash, new Node(K_YEAR));
      c.set(Calendar.MILLISECOND, ms);
      c.set(yy, mm, dd, h, m, s);
      return c.getTime();
    }
    else if(arg.isDelegable()){
            // délégable...
           
            if(arg.isExternal()){
                // optimisation dans le cas d'un external...
                Object o=arg.getExternal();
                if(o instanceof External_Date)
                    return ((External_Date)o).date;
            }
     
            // pas d'optimisation possible... alors la forme générale...
      Node t=Node.VDelegable.evalMethod_or_null(arg, "to-date",null);
            if(t!=null)
                return nodeToDate(t);
           
            // sinon on essaye avec number...
            t=Node.VDelegable.evalMethod_or_null(arg, PCoder.getMethod(PCoder.PC_NUMBER),null);
View Full Code Here

  }

  public Node external_mutator_set(Node startAt) throws Exception {
    startAt.isGoodArgsLength(true, 2);
        SELF.require_SELF_mutable();
        Node anode = startAt.getSubNode(1, Node.TYPE_HASH|Node.TYPE_NUMBER|Node.VTYPE_DELEGABLE);
    if (anode.isNumber()) {
      date.setTime((long) anode.getNumber());
    }
    else if (anode.getQType()==Node.TYPE_HASH) {
      Calendar c = Calendar.getInstance();
      int h = c.get(Calendar.HOUR_OF_DAY);
      int m = c.get(Calendar.MINUTE);
      int s = c.get(Calendar.SECOND);
      int ms = c.get(Calendar.MILLISECOND);
      int dd = c.get(Calendar.DAY_OF_MONTH);
      int mm = c.get(Calendar.MONTH);
      int yy = c.get(Calendar.YEAR);
            Hash hash=anode.getHash();
      h = getNumPairValueIfExists(h, hash, new Node(K_HOUR));
      m = getNumPairValueIfExists(m, hash, new Node(K_MINUTE));
      s = getNumPairValueIfExists(s, hash, new Node(K_SECOND));
      ms = getNumPairValueIfExists(ms, hash, new Node(K_MILLIS));
      dd = getNumPairValueIfExists(dd, hash, new Node(K_DAY));
      mm = getNumPairValueIfExists(mm, hash, new Node(K_MONTH)) - 1;
      yy = getNumPairValueIfExists(yy, hash, new Node(K_YEAR));
      c.set(Calendar.MILLISECOND, ms);
      c.set(yy, mm, dd, h, m, s);
      date = c.getTime();
    }
    else {
      // clonage de l'objet externe
      Object obj = anode.getExternalInstanceOf(External_Date.class);
     
      External_Date parent = (External_Date) obj;
      date.setTime(parent.date.getTime());
      date_default_format = parent.date_default_format;
      time_default_format = parent.time_default_format;
View Full Code Here

    return null;
  }

    public Node external_is_equ(Node startAt) throws Exception {
    startAt.isGoodArgsCnt(2);
        Node anode = startAt.getSubNode(1, Node.TYPE_HASH|Node.TYPE_NUMBER|Node.VTYPE_DELEGABLE);
    Date d = nodeToDate(anode);
        return new Node(date.equals(d) ? Node.TRUE:Node.FALSE);
  }
View Full Code Here

        return new Node(date.equals(d) ? Node.TRUE:Node.FALSE);
  }
   
    public Node external_compare(Node startAt) throws Exception {
        startAt.isGoodArgsCnt(2);
        Node anode = startAt.getSubNode(1, Node.TYPE_HASH | Node.TYPE_NUMBER | Node.VTYPE_DELEGABLE);
        Date d = nodeToDate(anode);
        return new Node(date.compareTo(d));
    }
View Full Code Here

        return new Node(date.compareTo(d));
    }

  public Node external_is_before(Node startAt) throws Exception {
        startAt.isGoodArgsCnt(2);
        Node anode = startAt.getSubNode(1, Node.TYPE_HASH|Node.TYPE_NUMBER|Node.VTYPE_DELEGABLE);
    Date d = nodeToDate(anode);
        Node res;
    if (date.before(d)) {
      res = new Node(Node.TRUE);
    }
    else {
      res = new Node(Node.FALSE);
    }
    return res;
  }
View Full Code Here

    return res;
  }

  public Node external_is_after(Node startAt) throws Exception {
        startAt.isGoodArgsCnt(2);
        Node anode = startAt.getSubNode(1, Node.TYPE_HASH|Node.TYPE_NUMBER|Node.VTYPE_DELEGABLE);
    Date d = nodeToDate(anode);
        Node res;
    if (date == d)
            Interpreter.Log("external_is_after : oups !!!");

    if (date.after(d))
      res = new Node(Node.TRUE);
    else
      res = new Node(Node.FALSE);
   
    return res;

  }
View Full Code Here

    public Node external_get_TK(Node startAt) throws Exception {
        startAt.isGoodArgsCnt(1);
        if (_TK_ == null) {
            Heap tkh = new Heap();
   
            tkh.put("HOUR", new Node(K_HOUR));
            tkh.put("MINUTE", new Node(K_MINUTE));
            tkh.put("SECOND", new Node(K_SECOND));
            tkh.put("MILLIS", new Node(K_MILLIS));
            tkh.put("DAY", new Node(K_DAY));
            tkh.put("MONTH", new Node(K_MONTH));
            tkh.put("YEAR", new Node(K_YEAR));

            tkh.put("DATE-SHORT-FORMAT", new Node(DATE_SHORT_FORMAT));
            tkh.put("DATE-LONG-FORMAT", new Node(DATE_LONG_FORMAT));
            tkh.put("TIME-SHORT-FORMAT", new Node(TIME_SHORT_FORMAT));
            tkh.put("TIME-DEFAULT-FORMAT", new Node(TIME_DEFAULT_FORMAT));
            tkh.put("TIME-LONG-FORMAT", new Node(TIME_LONG_FORMAT));
            tkh.put("TIME-STAMP-FORMAT", new Node(TIME_STAMP_FORMAT));
            tkh.put("DATE-STAMP-FORMAT", new Node(DATE_STAMP_FORMAT));
            tkh.put("DATETIME-STAMP-FORMAT", new Node(DATETIME_STAMP_FORMAT));
            tkh.put("MONTH-STAMP-FORMAT", new Node(MONTH_STAMP_FORMAT));
            tkh.put("YEAR-STAMP-FORMAT", new Node(YEAR_STAMP_FORMAT));
   
            tkh.put("RFC1123-STAMP-FORMAT", new Node(RFC1123_STAMP_FORMAT));
            tkh.put("RFC1036-STAMP-FORMAT", new Node(RFC1036_STAMP_FORMAT));
   
            tkh.put("ASCTIME-STAMP-FORMAT", new Node(ASCTIME_STAMP_FORMAT));
   
            _TK_ = new Node(tkh);
  }
        return _TK_;
  }
View Full Code Here

   
   
  public Node external_date_string(Node startAt) throws Exception {
        startAt.isGoodArgsCnt(1);
    SimpleDateFormat sdf = new SimpleDateFormat(this.date_default_format);
    return new Node(sdf.format(date));
  }
View Full Code Here

TOP

Related Classes of abstrasy.Node$VDelegable

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.