01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.formatter.align;
11:
12: /**
13: * Exception used to backtrack and break available alignments
14: * When the exception is thrown, it is assumed that some alignment will be changed.
15: *
16: * @since 2.1
17: */
18: public class AlignmentException extends RuntimeException {
19:
20: public static final int LINE_TOO_LONG = 1;
21: public static final int ALIGN_TOO_SMALL = 2;
22: private static final long serialVersionUID = -3324134986466253314L; // backward compatible
23:
24: int reason;
25: int value;
26: public int relativeDepth;
27:
28: public AlignmentException(int reason, int relativeDepth) {
29: this (reason, 0, relativeDepth);
30: }
31:
32: public AlignmentException(int reason, int value, int relativeDepth) {
33: this .reason = reason;
34: this .value = value;
35: this .relativeDepth = relativeDepth;
36: }
37:
38: public String toString() {
39: StringBuffer buffer = new StringBuffer(10);
40: switch (this .reason) {
41: case LINE_TOO_LONG:
42: buffer.append("LINE_TOO_LONG"); //$NON-NLS-1$
43: break;
44: case ALIGN_TOO_SMALL:
45: buffer.append("ALIGN_TOO_SMALL"); //$NON-NLS-1$
46: break;
47: }
48: buffer.append("<relativeDepth: ") //$NON-NLS-1$
49: .append(this .relativeDepth).append(">\n"); //$NON-NLS-1$
50: return buffer.toString();
51: }
52: }
|