001: package com.nwalsh.xalan;
002:
003: import org.w3c.dom.*;
004:
005: /**
006: * <p>Utility class for the Verbatim extension (ignore this).</p>
007: *
008: * <p>$Id: Callout.java,v 1.4 2005-08-30 08:14:58 draganr Exp $</p>
009: *
010: * <p>Copyright (C) 2000 Norman Walsh.</p>
011: *
012: * <p>This class is just for book keeping in the Verbatim class.
013: * It stores information about the location of callouts.</p>
014: *
015: * <p>Only line/column based callouts are supported. This class
016: * implements the Comparable interface so that callouts can be sorted.
017: * Callouts are sorted so that they occur in left-to-right,
018: * top-to-bottom order based on line/column.</p>
019: *
020: * <p><b>Change Log:</b></p>
021: * <dl>
022: * <dt>1.0</dt>
023: * <dd><p>Initial release.</p></dd>
024: * </dl>
025: *
026: * @author Norman Walsh
027: * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
028: *
029: * @see Verbatim
030: *
031: * @version $Id: Callout.java,v 1.4 2005-08-30 08:14:58 draganr Exp $
032: * */
033: public class Callout implements Comparable {
034: /** The callout number. */
035: private int callout = 0;
036: /** The area Element item that generated this callout. */
037: private Element area = null;
038: /** The line on which this callout occurs. */
039: private int line = 0;
040: /** The column in which this callout appears. */
041: private int col = 0;
042: /** The type of callout. */
043: private int type = 0;
044: /** The other type of callout. */
045: private String otherType = null;
046:
047: public static final int CALS_PAIR = 1;
048: public static final int LINE_COLUMN = 2;
049: public static final int LINE_COLUMN_PAIR = 3;
050: public static final int LINE_RANGE = 4;
051: public static final int OTHER = 5;
052:
053: /** The constructor; initialize the private data structures. */
054: public Callout(int callout, Element area, int line, int col,
055: int type) {
056: this .callout = callout;
057: this .area = area;
058: this .line = line;
059: this .col = col;
060: this .type = type;
061: this .otherType = null;
062: }
063:
064: /** The constructor; initialize the private data structures. */
065: public Callout(int callout, Element area, int line, int col,
066: String otherType) {
067: this .callout = callout;
068: this .area = area;
069: this .line = line;
070: this .col = col;
071: this .type = Callout.OTHER;
072: this .otherType = otherType;
073: }
074:
075: /**
076: * <p>The compareTo method compares this Callout with another.</p>
077: *
078: * <p>Given two Callouts, A and B, A < B if:</p>
079: *
080: * <ol>
081: * <li>A.line < B.line, or</li>
082: * <li>A.line = B.line && A.col < B.col, or</li>
083: * <li>A.line = B.line && A.col = B.col && A.callout < B.callout</li>
084: * <li>Otherwise, they're equal.</li>
085: * </ol>
086: */
087: public int compareTo(Object o) {
088: Callout c = (Callout) o;
089:
090: if (line == c.getLine()) {
091: if (col > c.getColumn()) {
092: return 1;
093: } else if (col < c.getColumn()) {
094: return -1;
095: } else {
096: if (callout < c.getCallout()) {
097: return -1;
098: } else if (callout > c.getCallout()) {
099: return 1;
100: } else {
101: return 0;
102: }
103: }
104: } else {
105: if (line > c.getLine()) {
106: return 1;
107: } else {
108: return -1;
109: }
110: }
111: }
112:
113: /** Access the Callout's area. */
114: public Element getArea() {
115: return area;
116: }
117:
118: /** Access the Callout's line. */
119: public int getLine() {
120: return line;
121: }
122:
123: /** Access the Callout's column. */
124: public int getColumn() {
125: return col;
126: }
127:
128: /** Access the Callout's callout number. */
129: public int getCallout() {
130: return callout;
131: }
132:
133: /** Access the Callout's type. */
134: public int getType() {
135: return type;
136: }
137:
138: /** Access the Callout's otherType. */
139: public String getOtherType() {
140: return otherType;
141: }
142:
143: }
|