KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > java > source > engine > JavaFormatOptions


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.java.source.engine;
20
21 import java.lang.reflect.Field JavaDoc;
22
23 public final class JavaFormatOptions {
24     public static JavaFormatOptions getDefault() {
25         JavaFormatOptions defaultOptions = new JavaFormatOptions();
26         propertySheet.loadValues(defaultOptions);
27         return defaultOptions;
28     }
29     private static final PropertySheetInfo propertySheet =
30         PropertySheetInfo.find(JavaFormatOptions.class);
31     private final static Field JavaDoc[] fields = JavaFormatOptions.class.getFields();
32
33     public void save() {
34         try {
35             propertySheet.saveValues(this);
36         } catch (Exception JavaDoc e) {
37             throw new AssertionError JavaDoc("failed saving format options: " + e);
38         }
39     }
40
41     // default values follow JDK coding standard
42
public boolean blankLineAfterDeclarations = true;
43     public boolean blankLineBeforeInlineDeclarations;
44     public boolean blankLineBeforeDocComments = true;
45     public boolean blankLineBeforeAllComments;
46     public boolean blankLineBeforeMethods = true;
47     public boolean sameLineIfFit=false;
48     public boolean excessParensAroundConditionals;
49     public boolean forceCondExprWrap = true;
50     public int starThreshold = 2; // Number of times a package has a class from it used before
51
// an import package.* will be generated
52
public int useThreshold = 1; // Number of times a class has to be used to be imported
53
public boolean cuddleOpenBrace = true;/* when true, brace should be on same line as
54                              * if, while, etc */

55     public boolean cuddleCloseBrace;
56     public boolean indBracesHalfway;
57     public int caseInd=2; /* indentation level delta to be used for a
58                              * "case n:" */

59     public boolean cuddleElse = true;/* true if else should cuddle up to preceeding '}' */
60     public boolean methodNamesStartLine; /* if true, the names of methods
61                              * being defined get placed in column
62                              * 1 (ie. a newline is placed between
63                              * the type of the method and its
64                              * name) */

65     public boolean formatCol1Comments = true; /* If comments which start in column 1
66                              * are to be magically reformatted
67                              * (just like comments that begin in
68                              * later columns) */

69     public int continuationIndent=8;/* set to the indentation between the edge of
70                              * code and continuation lines */

71     public boolean lineupToParens=true; /* if true, continued code within parens will
72                              * be lined up to the open paren */

73     public int rightMargin = 80; /* maximum column number */
74     public int blockCommentMaxCol = rightMargin;
75     public boolean extraExpressionIndent=true;/* True if continuation lines from the
76                              * expression part of "if(e)",
77                              * "while(e)", "for(e;e;e)" should be
78                              * indented an extra tab stop so that
79                              * they don't conflict with the code
80                              * that follows */

81     public int indentSize=4; /* the size of one indentation level */
82     public boolean indBracesInner; /* indent {}s to line up with the contained block */
83     public boolean alignDecl;/* true if left edges of variable names in
84                              * declarations should be aligned */

85     public int unindentDisplace;/* comments not to the right of code
86                              * will be placed this many
87                              * indentation levels to the left of
88                              * code */

89     public int appendCommentCol = 32; /* Starting column for comments appended to a line */
90     public PickOne spaceOperatorsBelow = new PickOne(13, /* put spaces around low priority operators */
91     new String JavaDoc[]{ "none", "=", "op=", "? :", "||", "&&", "|", "^", "&", "==, !=",
92                       "<, >, <=, >=", "<<, >>, >>>", "+, -", "*, /", "++i, --i", "i++, i--" });
93     public boolean cuddleElseIf=true;/* True iff else if pairs should be handled
94                              * specially */

95     public boolean indentParameters;
96     public PickOne blockCommentStyle = new PickOne(1,
97         new String JavaDoc[]{ "Compact /* */", "K&R", "Boxed /* */", "//" });
98     public PickOne smallCommentStyle = new PickOne(3,blockCommentStyle.keys);
99     public PickOne docCommentStyle = new PickOne(1,blockCommentStyle.keys);
100     public boolean moveAppendedComments;
101     public PickOne sort1 = new PickOne(0,
102         new String JavaDoc[] { "none", "variable/method/class",
103             "public/protected/private", "name" });
104     public PickOne redundantBraces = new PickOne(0,
105         new String JavaDoc[] { "Leave Alone", "Eliminate",
106             "Add" /*, " Add; except for else-if" */ });
107     public PickOne sort2 = new PickOne(0, sort1.keys);
108     public PickOne sort3 = new PickOne(0, sort1.keys);
109
110 }
111
Popular Tags