Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/nwalsh/xalan/Callout.java


1   package com.nwalsh.xalan;
2   
3   import org.w3c.dom.*;
4   
5   /**
6    * <p>Utility class for the Verbatim extension (ignore this).</p>
7    *
8    *
9    * <p>Copyright (C) 2000 Norman Walsh.</p>
10   *
11   * <p>This class is just for book keeping in the Verbatim class.
12   * It stores information about the location of callouts.</p>
13   *
14   * <p>Only line/column based callouts are supported. This class
15   * implements the Comparable interface so that callouts can be sorted.
16   * Callouts are sorted so that they occur in left-to-right,
17   * top-to-bottom order based on line/column.</p>
18   *
19   * <p><b>Change Log:</b></p>
20   * <dl>
21   * <dt>1.0</dt>
22   * <dd><p>Initial release.</p></dd>
23   * </dl>
24   *
25   * @author Norman Walsh
26   * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
27   *
28   * @see Verbatim
29   *
30   * */
31  public class Callout implements Comparable {
32    /** The callout number. */
33    private int callout = 0;
34    /** The area Element item that generated this callout. */
35    private Element area = null;
36    /** The line on which this callout occurs. */
37    private int line = 0;
38    /** The column in which this callout appears. */
39    private int col = 0;
40    /** The type of callout. */
41    private int type = 0;
42    /** The other type of callout. */
43    private String otherType = null;
44  
45    public static final int CALS_PAIR = 1;
46    public static final int LINE_COLUMN = 2;
47    public static final int LINE_COLUMN_PAIR = 3;
48    public static final int LINE_RANGE = 4;
49    public static final int OTHER = 5;
50  
51    /** The constructor; initialize the private data structures. */
52    public Callout(int callout, Element area, int line, int col, int type) {
53      this.callout = callout;
54      this.area = area;
55      this.line = line;
56      this.col = col;
57      this.type = type;
58      this.otherType = null;
59    }
60  
61    /** The constructor; initialize the private data structures. */
62    public Callout(int callout, Element area, int line, int col, String otherType) {
63      this.callout = callout;
64      this.area = area;
65      this.line = line;
66      this.col = col;
67      this.type = Callout.OTHER;
68      this.otherType = otherType;
69    }
70  
71    /**
72     * <p>The compareTo method compares this Callout with another.</p>
73     *
74     * <p>Given two Callouts, A and B, A < B if:</p>
75     *
76     * <ol>
77     * <li>A.line < B.line, or</li>
78     * <li>A.line = B.line && A.col < B.col, or</li>
79     * <li>A.line = B.line && A.col = B.col && A.callout < B.callout</li>
80     * <li>Otherwise, they're equal.</li>
81     * </ol>
82     */
83    public int compareTo (Object o) {
84      Callout c = (Callout) o;
85  
86      if (line == c.getLine()) {
87        if (col > c.getColumn()) {
88    return 1;
89        } else if (col < c.getColumn()) {
90    return -1;
91        } else {
92    if (callout < c.getCallout()) {
93      return -1;
94    } else if (callout > c.getCallout()) {
95      return 1;
96    } else {
97      return 0;
98    }
99        }
100     } else {
101       if (line > c.getLine()) {
102   return 1;
103       } else {
104   return -1;
105       }
106     }
107   }
108 
109   /** Access the Callout's area. */
110   public Element getArea() {
111     return area;
112   }
113 
114   /** Access the Callout's line. */
115   public int getLine() {
116     return line;
117   }
118 
119   /** Access the Callout's column. */
120   public int getColumn() {
121     return col;
122   }
123 
124   /** Access the Callout's callout number. */
125   public int getCallout() {
126     return callout;
127   }
128 
129   /** Access the Callout's type. */
130   public int getType() {
131     return type;
132   }
133 
134   /** Access the Callout's otherType. */
135   public String getOtherType() {
136     return otherType;
137   }
138 
139 
140 }
141