public final class FormatPreferences
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
FormatPreferences.Indentation
A category of indentation.
|
static class |
FormatPreferences.Opt
Option flags.
|
static class |
FormatPreferences.Space
The location or position of a space.
|
static class |
FormatPreferences.SpaceType
The type of space to apply.
|
static class |
FormatPreferences.Wrapping
Categories for wrapping rules.
|
static class |
FormatPreferences.WrappingMode
The wrapping mode.
|
Modifier and Type | Field and Description |
---|---|
private java.util.EnumSet<FormatPreferences.Indentation> |
absoluteIndents |
private static java.util.EnumSet<FormatPreferences.Indentation> |
DEFAULT_ABS_INDENTS |
private static EnumIntMap<FormatPreferences.Indentation> |
DEFAULT_INDENTS |
private static java.util.EnumSet<FormatPreferences.Opt> |
DEFAULT_OPTS |
private static java.util.EnumMap<FormatPreferences.Space,FormatPreferences.SpaceType> |
DEFAULT_SPACE_TYPES |
private static java.util.EnumMap<FormatPreferences.Wrapping,FormatPreferences.WrappingMode> |
DEFAULT_WRAPPING |
private EnumIntMap<FormatPreferences.Indentation> |
indents |
private int |
lineLength |
private java.util.EnumSet<FormatPreferences.Opt> |
options |
private static java.lang.String |
PROPERTIES_FILE_NAME |
private java.util.EnumMap<FormatPreferences.Space,FormatPreferences.SpaceType> |
spaceTypes |
private java.util.EnumMap<FormatPreferences.Wrapping,FormatPreferences.WrappingMode> |
wrapping |
Constructor and Description |
---|
FormatPreferences()
Construct a new instance using default values.
|
FormatPreferences(java.lang.ClassLoader classLoader)
Construct a new instance using a properties file loaded from the given class loader.
|
FormatPreferences(java.io.File file)
Construct a new instance using a properties file loaded from the given file name.
|
FormatPreferences(javax.annotation.processing.Filer filer)
Construct a new instance using a properties file loaded from the given annotation processing filer.
|
FormatPreferences(javax.annotation.processing.Filer filer,
java.lang.String name)
Construct a new instance using a properties file loaded from the given annotation processing filer.
|
FormatPreferences(java.io.InputStream inputStream)
Construct a new instance using a properties read from the given stream.
|
FormatPreferences(java.util.Properties properties)
Construct a new instance, mapping the given properties to the formatter configurations.
|
FormatPreferences(java.io.Reader reader)
Construct a new instance using a properties read from the given stream.
|
Modifier and Type | Method and Description |
---|---|
void |
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 java.io.InputStream |
fnf(java.io.InputStream stream) |
int |
getIndent(FormatPreferences.Indentation indentation)
Get the configured indentation for the given context.
|
int |
getLineLength()
Get the configured line length.
|
FormatPreferences.SpaceType |
getSpaceType(FormatPreferences.Space space)
Get the spacing type for a given space context.
|
FormatPreferences.WrappingMode |
getWrapMode(FormatPreferences.Wrapping wrapping)
Get the wrapping mode for the given wrapping context.
|
boolean |
hasOption(FormatPreferences.Opt opt)
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 java.util.Properties |
load(java.io.Reader reader) |
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.
|
FormatPreferences.SpaceType |
setSpaceType(FormatPreferences.Space space,
FormatPreferences.SpaceType spaceType)
Set the spacing type for the given space context.
|
FormatPreferences.WrappingMode |
setWrapMode(FormatPreferences.Wrapping wrapping,
FormatPreferences.WrappingMode mode)
Set the wrapping mode for the given wrapping context.
|
private static void |
split(java.util.ArrayList<java.lang.String> dest,
char delim,
java.lang.String s) |
private static java.lang.String |
xf(java.lang.String name) |
private static final java.lang.String PROPERTIES_FILE_NAME
private static final EnumIntMap<FormatPreferences.Indentation> DEFAULT_INDENTS
private static final java.util.EnumSet<FormatPreferences.Indentation> DEFAULT_ABS_INDENTS
private static final java.util.EnumMap<FormatPreferences.Space,FormatPreferences.SpaceType> DEFAULT_SPACE_TYPES
private static final java.util.EnumSet<FormatPreferences.Opt> DEFAULT_OPTS
private static final java.util.EnumMap<FormatPreferences.Wrapping,FormatPreferences.WrappingMode> DEFAULT_WRAPPING
private final EnumIntMap<FormatPreferences.Indentation> indents
private final java.util.EnumSet<FormatPreferences.Indentation> absoluteIndents
private final java.util.EnumMap<FormatPreferences.Space,FormatPreferences.SpaceType> spaceTypes
private final java.util.EnumSet<FormatPreferences.Opt> options
private final java.util.EnumMap<FormatPreferences.Wrapping,FormatPreferences.WrappingMode> wrapping
private int lineLength
public FormatPreferences()
public FormatPreferences(java.util.Properties properties)
properties
- the properties to mappublic FormatPreferences(java.lang.ClassLoader classLoader) throws java.io.IOException
classLoader
- the class loaderjava.io.IOException
- if an error occurs while reading the propertiespublic FormatPreferences(javax.annotation.processing.Filer filer, java.lang.String name) throws java.io.IOException
filer
- the filer to read fromname
- the name of the properties file to readjava.io.IOException
- if an error occurs while reading the propertiespublic FormatPreferences(javax.annotation.processing.Filer filer) throws java.io.IOException
filer
- the filer to read fromjava.io.IOException
- if an error occurs while reading the propertiespublic FormatPreferences(java.io.File file) throws java.io.IOException
file
- the name of the properties file to readjava.io.IOException
- if an error occurs while reading the propertiespublic FormatPreferences(java.io.InputStream inputStream) throws java.io.IOException
inputStream
- the stream to read properties fromjava.io.IOException
- if an error occurs while reading the propertiespublic FormatPreferences(java.io.Reader reader) throws java.io.IOException
reader
- the stream to read properties fromjava.io.IOException
- if an error occurs while reading the propertiesprivate static java.io.InputStream fnf(java.io.InputStream stream) throws java.io.IOException
java.io.IOException
private static java.lang.String xf(java.lang.String name)
private static void split(java.util.ArrayList<java.lang.String> dest, char delim, java.lang.String s)
private static java.util.Properties load(java.io.Reader reader) throws java.io.IOException
java.io.IOException
private <T> T def(T val, T def)
public int getLineLength()
public int getIndent(FormatPreferences.Indentation indentation)
indentation
- the indentation contextpublic int setIndent(FormatPreferences.Indentation indentation, int value)
indentation
- the indentation contextvalue
- the indentationpublic boolean isIndentAbsolute(FormatPreferences.Indentation indentation)
indentation
- the indentation contexttrue
if absolute, false
if relativepublic void setIndentAbsolute(FormatPreferences.Indentation indentation)
indentation
- the indentation contextpublic void clearIndentAbsolute(FormatPreferences.Indentation indentation)
indentation
- the indentation contextpublic FormatPreferences.SpaceType setSpaceType(FormatPreferences.Space space, FormatPreferences.SpaceType spaceType)
space
- the space contextspaceType
- the space typepublic void setAllSpaceTypes(FormatPreferences.SpaceType toType, FormatPreferences.Space... spaces)
toType
- the type to set tospaces
- the space contextspublic FormatPreferences.SpaceType getSpaceType(FormatPreferences.Space space)
space
- the space contextpublic FormatPreferences.WrappingMode getWrapMode(FormatPreferences.Wrapping wrapping)
wrapping
- the wrapping contextpublic FormatPreferences.WrappingMode setWrapMode(FormatPreferences.Wrapping wrapping, FormatPreferences.WrappingMode mode)
wrapping
- the wrapping contextmode
- the wrapping modepublic void addOption(FormatPreferences.Opt... opts)
opts
- the flags to addpublic void removeOption(FormatPreferences.Opt... opts)
opts
- the flags to removepublic boolean hasOption(FormatPreferences.Opt opt)
opt
- the flag to checktrue
if the flag is present, false
if it is absent