KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nwalsh > xalan > Callout


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  * <p>$Id: Callout.java,v 1.1 2001/04/02 13:03:45 nwalsh Exp $</p>
9  *
10  * <p>Copyright (C) 2000 Norman Walsh.</p>
11  *
12  * <p>This class is just for book keeping in the Verbatim class.
13  * It stores information about the location of callouts.</p>
14  *
15  * <p>Only line/column based callouts are supported. This class
16  * implements the Comparable interface so that callouts can be sorted.
17  * Callouts are sorted so that they occur in left-to-right,
18  * top-to-bottom order based on line/column.</p>
19  *
20  * <p><b>Change Log:</b></p>
21  * <dl>
22  * <dt>1.0</dt>
23  * <dd><p>Initial release.</p></dd>
24  * </dl>
25  *
26  * @author Norman Walsh
27  * <a HREF="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
28  *
29  * @see Verbatim
30  *
31  * @version $Id: Callout.java,v 1.1 2001/04/02 13:03:45 nwalsh Exp $
32  * */

33 public class Callout implements Comparable JavaDoc {
34   /** The callout number. */
35   private int callout = 0;
36   /** The area Element item that generated this callout. */
37   private Element area = null;
38   /** The line on which this callout occurs. */
39   private int line = 0;
40   /** The column in which this callout appears. */
41   private int col = 0;
42   /** The type of callout. */
43   private int type = 0;
44   /** The other type of callout. */
45   private String JavaDoc otherType = null;
46
47   public static final int CALS_PAIR = 1;
48   public static final int LINE_COLUMN = 2;
49   public static final int LINE_COLUMN_PAIR = 3;
50   public static final int LINE_RANGE = 4;
51   public static final int OTHER = 5;
52
53   /** The constructor; initialize the private data structures. */
54   public Callout(int callout, Element area, int line, int col, int type) {
55     this.callout = callout;
56     this.area = area;
57     this.line = line;
58     this.col = col;
59     this.type = type;
60     this.otherType = null;
61   }
62
63   /** The constructor; initialize the private data structures. */
64   public Callout(int callout, Element area, int line, int col, String JavaDoc otherType) {
65     this.callout = callout;
66     this.area = area;
67     this.line = line;
68     this.col = col;
69     this.type = Callout.OTHER;
70     this.otherType = otherType;
71   }
72
73   /**
74    * <p>The compareTo method compares this Callout with another.</p>
75    *
76    * <p>Given two Callouts, A and B, A < B if:</p>
77    *
78    * <ol>
79    * <li>A.line < B.line, or</li>
80    * <li>A.line = B.line && A.col < B.col, or</li>
81    * <li>A.line = B.line && A.col = B.col && A.callout < B.callout</li>
82    * <li>Otherwise, they're equal.</li>
83    * </ol>
84    */

85   public int compareTo (Object JavaDoc o) {
86     Callout c = (Callout) o;
87
88     if (line == c.getLine()) {
89       if (col > c.getColumn()) {
90     return 1;
91       } else if (col < c.getColumn()) {
92     return -1;
93       } else {
94     if (callout < c.getCallout()) {
95       return -1;
96     } else if (callout > c.getCallout()) {
97       return 1;
98     } else {
99       return 0;
100     }
101       }
102     } else {
103       if (line > c.getLine()) {
104     return 1;
105       } else {
106     return -1;
107       }
108     }
109   }
110
111   /** Access the Callout's area. */
112   public Element getArea() {
113     return area;
114   }
115
116   /** Access the Callout's line. */
117   public int getLine() {
118     return line;
119   }
120
121   /** Access the Callout's column. */
122   public int getColumn() {
123     return col;
124   }
125
126   /** Access the Callout's callout number. */
127   public int getCallout() {
128     return callout;
129   }
130
131   /** Access the Callout's type. */
132   public int getType() {
133     return type;
134   }
135
136   /** Access the Callout's otherType. */
137   public String JavaDoc getOtherType() {
138     return otherType;
139   }
140
141
142 }
143
144
Popular Tags