KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > formatter > align > AlignmentException


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.formatter.align;
12
13 /**
14  * Exception used to backtrack and break available alignments
15  * When the exception is thrown, it is assumed that some alignment will be changed.
16  *
17  * @since 2.1
18  */

19 public class AlignmentException extends RuntimeException JavaDoc {
20     
21     public static final int LINE_TOO_LONG = 1;
22     public static final int ALIGN_TOO_SMALL = 2;
23     private static final long serialVersionUID = -3324134986466253314L; // backward compatible
24

25     int reason;
26     int value;
27     public int relativeDepth;
28     
29     public AlignmentException(int reason, int relativeDepth) {
30         this(reason, 0, relativeDepth);
31     }
32
33     public AlignmentException(int reason, int value, int relativeDepth) {
34         this.reason = reason;
35         this.value = value;
36         this.relativeDepth = relativeDepth;
37     }
38     
39     public String JavaDoc toString(){
40         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(10);
41         switch(this.reason){
42             case LINE_TOO_LONG :
43                 buffer.append("LINE_TOO_LONG"); //$NON-NLS-1$
44
break;
45             case ALIGN_TOO_SMALL :
46                 buffer.append("ALIGN_TOO_SMALL"); //$NON-NLS-1$
47
break;
48         }
49         buffer
50             .append("<relativeDepth: ") //$NON-NLS-1$
51
.append(this.relativeDepth)
52             .append(">\n"); //$NON-NLS-1$
53
return buffer.toString();
54     }
55 }
56
Popular Tags