File: ConvertibleNodeSetExpr.java

package info (click to toggle)
libxt-java 0.19991105-5
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,908 kB
  • ctags: 2,762
  • sloc: java: 12,823; makefile: 52; xml: 46
file content (72 lines) | stat: -rw-r--r-- 2,339 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package com.jclark.xsl.expr;

import com.jclark.xsl.om.*;

abstract class ConvertibleNodeSetExpr extends ConvertibleExpr implements NodeSetExpr {

  ConvertibleStringExpr makeStringExpr() {
    return new ConvertibleStringExpr() {
      public String eval(Node node, ExprContext context) throws XSLException {
	return Converter.toString(ConvertibleNodeSetExpr.this.eval(node, context));
      }
    };
  }

  ConvertibleBooleanExpr makeBooleanExpr() {
    return new ConvertibleBooleanExpr() {
      public boolean eval(Node node, ExprContext context) throws XSLException {
	return Converter.toBoolean(ConvertibleNodeSetExpr.this.eval(node, context));
      }
    };
  }

  ConvertibleNodeSetExpr makeNodeSetExpr() {
    return this;
  }

  ConvertibleVariantExpr makeVariantExpr() {
    return new ConvertibleVariantExpr() {
      public Variant eval(Node node, ExprContext context) throws XSLException {
	return new NodeSetVariant(ConvertibleNodeSetExpr.this.eval(node, context));
      }
    };
  }

  /**
   * If is set, then all nodes in the result of eval(x, c)
   * are guaranteed to be in the subtree rooted at x.
   */

  static final int STAYS_IN_SUBTREE = 01;

  /**
   * If this is set, then all nodes in the result of eval(x, c) are
   * guaranteed to be at the same level of the tree. More precisely,
   * define the level of a node to be the number of ancestors it has,
   * and then define an expression to be single-level if and only if
   * there exists an integer n such that for any node x, for any node
   * y in the result of evaluating the expression with respect to x,
   * the difference between the level of x and the level of y is equal
   * to n.  For example, the children axis is single-level but the
   * descendants axis is not.
   */
  static final int SINGLE_LEVEL = 02;

  int getOptimizeFlags() {
    return 0;
  }
  
  /* Return an expression for this/expr */
  ConvertibleNodeSetExpr compose(ConvertibleNodeSetExpr expr) {
    int opt1 = this.getOptimizeFlags();
    int opt2 = expr.getOptimizeFlags();
    if ((opt1 & SINGLE_LEVEL) != 0
	&& (opt2 & STAYS_IN_SUBTREE) != 0)
      return new SequenceComposeExpr(this, expr);
    return new ComposeExpr(this, expr);
  }

  Pattern getChildrenNodePattern() {
    return null;
  }
}