~ubuntu-branches/debian/wheezy/jing-trang/wheezy

« back to all changes in this revision

Viewing changes to mod/dtd-parse/src/main/com/thaiopensource/xml/dtd/parse/ParamStream.java

  • Committer: Bazaar Package Importer
  • Author(s): Samuel Thibault
  • Date: 2009-09-01 15:53:03 UTC
  • Revision ID: james.westby@ubuntu.com-20090901155303-2kweef05h5v9j3ni
Tags: upstream-20090818
ImportĀ upstreamĀ versionĀ 20090818

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package com.thaiopensource.xml.dtd.parse;
 
2
 
 
3
import java.util.Vector;
 
4
 
 
5
class ParamStream {
 
6
  int type;
 
7
  Entity entity;
 
8
  Particle group;
 
9
  String value;
 
10
 
 
11
  private int i = 0;
 
12
  private final Vector v;
 
13
  private final boolean showReferences;
 
14
 
 
15
  ParamStream(Vector v) {
 
16
    this.v = v;
 
17
    this.showReferences = false;
 
18
  }
 
19
 
 
20
  ParamStream(Vector v, boolean showReferences) {
 
21
    this.v = v;
 
22
    this.showReferences = showReferences;
 
23
  }
 
24
  
 
25
  boolean advance() {
 
26
    while (i < v.size()) {
 
27
      Param p = (Param)v.elementAt(i++);
 
28
      type = p.type;
 
29
      entity = p.entity;
 
30
      group = p.group;
 
31
      value = p.value;
 
32
      switch (type) {
 
33
      case Param.REFERENCE:
 
34
        if (showReferences && entity.semantic > 0) {
 
35
          int level = 0;
 
36
          for (;;) {
 
37
            p = (Param)v.elementAt(i++);
 
38
            if (p.type == Param.REFERENCE)
 
39
              level++;
 
40
            else if (p.type == Param.REFERENCE_END
 
41
                     && level-- == 0)
 
42
              break;
 
43
          }
 
44
          return true;
 
45
        }
 
46
        break;
 
47
      case Param.REFERENCE_END:
 
48
        break;
 
49
      default:
 
50
        return true;
 
51
      }
 
52
    }
 
53
    type = -1;
 
54
    return false;
 
55
  }
 
56
}
 
57