Package org.jboss.jdeparser
Class FormatPreferences
java.lang.Object
org.jboss.jdeparser.FormatPreferences
Formatter preferences.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
A category of indentation.static enum
Option flags.static enum
The location or position of a space.static enum
The type of space to apply.static enum
Categories for wrapping rules.static enum
The wrapping mode. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final EnumSet
<FormatPreferences.Indentation> private static final EnumSet
<FormatPreferences.Indentation> private static final EnumIntMap
<FormatPreferences.Indentation> private static final EnumSet
<FormatPreferences.Opt> private static final EnumMap
<FormatPreferences.Space, FormatPreferences.SpaceType> private static final EnumMap
<FormatPreferences.Wrapping, FormatPreferences.WrappingMode> private final EnumIntMap
<FormatPreferences.Indentation> private int
private final EnumSet
<FormatPreferences.Opt> private static final String
private final EnumMap
<FormatPreferences.Space, FormatPreferences.SpaceType> private final EnumMap
<FormatPreferences.Wrapping, FormatPreferences.WrappingMode> -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new instance using default values.FormatPreferences
(File file) Construct a new instance using a properties file loaded from the given file name.FormatPreferences
(InputStream inputStream) Construct a new instance using a properties read from the given stream.FormatPreferences
(Reader reader) Construct a new instance using a properties read from the given stream.FormatPreferences
(ClassLoader classLoader) Construct a new instance using a properties file loaded from the given class loader.FormatPreferences
(Properties properties) Construct a new instance, mapping the given properties to the formatter configurations.FormatPreferences
(Filer filer) Construct a new instance using a properties file loaded from the given annotation processing filer.FormatPreferences
(Filer filer, String name) Construct a new instance using a properties file loaded from the given annotation processing filer. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addOption
(FormatPreferences.Opt... opts) Add option flags to these preferences.void
clearIndentAbsolute
(FormatPreferences.Indentation indentation) Clear absolute indentation for the given context.private <T> T
def
(T val, T def) private static InputStream
fnf
(InputStream stream) int
getIndent
(FormatPreferences.Indentation indentation) Get the configured indentation for the given context.int
Get the configured line length.Get the spacing type for a given space context.getWrapMode
(FormatPreferences.Wrapping wrapping) Get the wrapping mode for the given wrapping context.boolean
Determine whether the given option flag is set on these preferences.boolean
isIndentAbsolute
(FormatPreferences.Indentation indentation) Determine whether the indentation for the given context is absolute or relative.private static Properties
void
removeOption
(FormatPreferences.Opt... opts) Remove option flags from these preferences.void
setAllSpaceTypes
(FormatPreferences.SpaceType toType, FormatPreferences.Space... spaces) Set several space contexts to the same spacing type.int
setIndent
(FormatPreferences.Indentation indentation, int value) Set the configured indentation for the given context.void
setIndentAbsolute
(FormatPreferences.Indentation indentation) Set absolute indentation for the given context.setSpaceType
(FormatPreferences.Space space, FormatPreferences.SpaceType spaceType) Set the spacing type for the given space context.setWrapMode
(FormatPreferences.Wrapping wrapping, FormatPreferences.WrappingMode mode) Set the wrapping mode for the given wrapping context.private static void
private static String
-
Field Details
-
PROPERTIES_FILE_NAME
- See Also:
-
DEFAULT_INDENTS
-
DEFAULT_ABS_INDENTS
-
DEFAULT_SPACE_TYPES
private static final EnumMap<FormatPreferences.Space,FormatPreferences.SpaceType> DEFAULT_SPACE_TYPES -
DEFAULT_OPTS
-
DEFAULT_WRAPPING
private static final EnumMap<FormatPreferences.Wrapping,FormatPreferences.WrappingMode> DEFAULT_WRAPPING -
indents
-
absoluteIndents
-
spaceTypes
-
options
-
wrapping
-
lineLength
private int lineLength
-
-
Constructor Details
-
FormatPreferences
public FormatPreferences()Construct a new instance using default values. -
FormatPreferences
Construct a new instance, mapping the given properties to the formatter configurations.- Parameters:
properties
- the properties to map
-
FormatPreferences
Construct a new instance using a properties file loaded from the given class loader.- Parameters:
classLoader
- the class loader- Throws:
IOException
- if an error occurs while reading the properties
-
FormatPreferences
Construct a new instance using a properties file loaded from the given annotation processing filer.- Parameters:
filer
- the filer to read fromname
- the name of the properties file to read- Throws:
IOException
- if an error occurs while reading the properties
-
FormatPreferences
Construct a new instance using a properties file loaded from the given annotation processing filer.- Parameters:
filer
- the filer to read from- Throws:
IOException
- if an error occurs while reading the properties
-
FormatPreferences
Construct a new instance using a properties file loaded from the given file name.- Parameters:
file
- the name of the properties file to read- Throws:
IOException
- if an error occurs while reading the properties
-
FormatPreferences
Construct a new instance using a properties read from the given stream.- Parameters:
inputStream
- the stream to read properties from- Throws:
IOException
- if an error occurs while reading the properties
-
FormatPreferences
Construct a new instance using a properties read from the given stream.- Parameters:
reader
- the stream to read properties from- Throws:
IOException
- if an error occurs while reading the properties
-
-
Method Details
-
fnf
- Throws:
IOException
-
xf
-
split
-
load
- Throws:
IOException
-
def
private <T> T def(T val, T def) -
getLineLength
public int getLineLength()Get the configured line length.- Returns:
- the configured line length
-
getIndent
Get the configured indentation for the given context.- Parameters:
indentation
- the indentation context- Returns:
- the indentation
-
setIndent
Set the configured indentation for the given context.- Parameters:
indentation
- the indentation contextvalue
- the indentation- Returns:
- the previous indentation
-
isIndentAbsolute
Determine whether the indentation for the given context is absolute or relative.- Parameters:
indentation
- the indentation context- Returns:
true
if absolute,false
if relative
-
setIndentAbsolute
Set absolute indentation for the given context.- Parameters:
indentation
- the indentation context
-
clearIndentAbsolute
Clear absolute indentation for the given context.- Parameters:
indentation
- the indentation context
-
setSpaceType
public FormatPreferences.SpaceType setSpaceType(FormatPreferences.Space space, FormatPreferences.SpaceType spaceType) Set the spacing type for the given space context.- Parameters:
space
- the space contextspaceType
- the space type- Returns:
- the previous space type
-
setAllSpaceTypes
Set several space contexts to the same spacing type.- Parameters:
toType
- the type to set tospaces
- the space contexts
-
getSpaceType
Get the spacing type for a given space context.- Parameters:
space
- the space context- Returns:
- the spacing type
-
getWrapMode
Get the wrapping mode for the given wrapping context.- Parameters:
wrapping
- the wrapping context- Returns:
- the current wrapping mode
-
setWrapMode
public FormatPreferences.WrappingMode setWrapMode(FormatPreferences.Wrapping wrapping, FormatPreferences.WrappingMode mode) Set the wrapping mode for the given wrapping context.- Parameters:
wrapping
- the wrapping contextmode
- the wrapping mode- Returns:
- the previous wrapping mode
-
addOption
Add option flags to these preferences.- Parameters:
opts
- the flags to add
-
removeOption
Remove option flags from these preferences.- Parameters:
opts
- the flags to remove
-
hasOption
Determine whether the given option flag is set on these preferences.- Parameters:
opt
- the flag to check- Returns:
true
if the flag is present,false
if it is absent
-