Package org.jboss.jdeparser
Class FormatPreferences
- java.lang.Object
-
- org.jboss.jdeparser.FormatPreferences
-
public final class FormatPreferences extends java.lang.ObjectFormatter preferences.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFormatPreferences.IndentationA category of indentation.static classFormatPreferences.OptOption flags.static classFormatPreferences.SpaceThe location or position of a space.static classFormatPreferences.SpaceTypeThe type of space to apply.static classFormatPreferences.WrappingCategories for wrapping rules.static classFormatPreferences.WrappingModeThe wrapping mode.
-
Field Summary
Fields Modifier and Type Field Description private java.util.EnumSet<FormatPreferences.Indentation>absoluteIndentsprivate static java.util.EnumSet<FormatPreferences.Indentation>DEFAULT_ABS_INDENTSprivate static EnumIntMap<FormatPreferences.Indentation>DEFAULT_INDENTSprivate static java.util.EnumSet<FormatPreferences.Opt>DEFAULT_OPTSprivate static java.util.EnumMap<FormatPreferences.Space,FormatPreferences.SpaceType>DEFAULT_SPACE_TYPESprivate static java.util.EnumMap<FormatPreferences.Wrapping,FormatPreferences.WrappingMode>DEFAULT_WRAPPINGprivate EnumIntMap<FormatPreferences.Indentation>indentsprivate intlineLengthprivate java.util.EnumSet<FormatPreferences.Opt>optionsprivate static java.lang.StringPROPERTIES_FILE_NAMEprivate java.util.EnumMap<FormatPreferences.Space,FormatPreferences.SpaceType>spaceTypesprivate java.util.EnumMap<FormatPreferences.Wrapping,FormatPreferences.WrappingMode>wrapping
-
Constructor Summary
Constructors Constructor Description FormatPreferences()Construct a new instance using default values.FormatPreferences(java.io.File file)Construct a new instance using a properties file loaded from the given file name.FormatPreferences(java.io.InputStream inputStream)Construct a new instance using a properties read from the given stream.FormatPreferences(java.io.Reader reader)Construct a new instance using a properties read from the given stream.FormatPreferences(java.lang.ClassLoader classLoader)Construct a new instance using a properties file loaded from the given class loader.FormatPreferences(java.util.Properties properties)Construct a new instance, mapping the given properties to the formatter configurations.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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddOption(FormatPreferences.Opt... opts)Add option flags to these preferences.voidclearIndentAbsolute(FormatPreferences.Indentation indentation)Clear absolute indentation for the given context.private <T> Tdef(T val, T def)private static java.io.InputStreamfnf(java.io.InputStream stream)intgetIndent(FormatPreferences.Indentation indentation)Get the configured indentation for the given context.intgetLineLength()Get the configured line length.FormatPreferences.SpaceTypegetSpaceType(FormatPreferences.Space space)Get the spacing type for a given space context.FormatPreferences.WrappingModegetWrapMode(FormatPreferences.Wrapping wrapping)Get the wrapping mode for the given wrapping context.booleanhasOption(FormatPreferences.Opt opt)Determine whether the given option flag is set on these preferences.booleanisIndentAbsolute(FormatPreferences.Indentation indentation)Determine whether the indentation for the given context is absolute or relative.private static java.util.Propertiesload(java.io.Reader reader)voidremoveOption(FormatPreferences.Opt... opts)Remove option flags from these preferences.voidsetAllSpaceTypes(FormatPreferences.SpaceType toType, FormatPreferences.Space... spaces)Set several space contexts to the same spacing type.intsetIndent(FormatPreferences.Indentation indentation, int value)Set the configured indentation for the given context.voidsetIndentAbsolute(FormatPreferences.Indentation indentation)Set absolute indentation for the given context.FormatPreferences.SpaceTypesetSpaceType(FormatPreferences.Space space, FormatPreferences.SpaceType spaceType)Set the spacing type for the given space context.FormatPreferences.WrappingModesetWrapMode(FormatPreferences.Wrapping wrapping, FormatPreferences.WrappingMode mode)Set the wrapping mode for the given wrapping context.private static voidsplit(java.util.ArrayList<java.lang.String> dest, char delim, java.lang.String s)private static java.lang.Stringxf(java.lang.String name)
-
-
-
Field Detail
-
PROPERTIES_FILE_NAME
private static final java.lang.String PROPERTIES_FILE_NAME
- See Also:
- Constant Field Values
-
DEFAULT_INDENTS
private static final EnumIntMap<FormatPreferences.Indentation> DEFAULT_INDENTS
-
DEFAULT_ABS_INDENTS
private static final java.util.EnumSet<FormatPreferences.Indentation> DEFAULT_ABS_INDENTS
-
DEFAULT_SPACE_TYPES
private static final java.util.EnumMap<FormatPreferences.Space,FormatPreferences.SpaceType> DEFAULT_SPACE_TYPES
-
DEFAULT_OPTS
private static final java.util.EnumSet<FormatPreferences.Opt> DEFAULT_OPTS
-
DEFAULT_WRAPPING
private static final java.util.EnumMap<FormatPreferences.Wrapping,FormatPreferences.WrappingMode> DEFAULT_WRAPPING
-
indents
private final EnumIntMap<FormatPreferences.Indentation> indents
-
absoluteIndents
private final java.util.EnumSet<FormatPreferences.Indentation> absoluteIndents
-
spaceTypes
private final java.util.EnumMap<FormatPreferences.Space,FormatPreferences.SpaceType> spaceTypes
-
options
private final java.util.EnumSet<FormatPreferences.Opt> options
-
wrapping
private final java.util.EnumMap<FormatPreferences.Wrapping,FormatPreferences.WrappingMode> wrapping
-
lineLength
private int lineLength
-
-
Constructor Detail
-
FormatPreferences
public FormatPreferences()
Construct a new instance using default values.
-
FormatPreferences
public FormatPreferences(java.util.Properties properties)
Construct a new instance, mapping the given properties to the formatter configurations.- Parameters:
properties- the properties to map
-
FormatPreferences
public FormatPreferences(java.lang.ClassLoader classLoader) throws java.io.IOExceptionConstruct a new instance using a properties file loaded from the given class loader.- Parameters:
classLoader- the class loader- Throws:
java.io.IOException- if an error occurs while reading the properties
-
FormatPreferences
public FormatPreferences(javax.annotation.processing.Filer filer, java.lang.String name) throws java.io.IOExceptionConstruct 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:
java.io.IOException- if an error occurs while reading the properties
-
FormatPreferences
public FormatPreferences(javax.annotation.processing.Filer filer) throws java.io.IOExceptionConstruct a new instance using a properties file loaded from the given annotation processing filer.- Parameters:
filer- the filer to read from- Throws:
java.io.IOException- if an error occurs while reading the properties
-
FormatPreferences
public FormatPreferences(java.io.File file) throws java.io.IOExceptionConstruct a new instance using a properties file loaded from the given file name.- Parameters:
file- the name of the properties file to read- Throws:
java.io.IOException- if an error occurs while reading the properties
-
FormatPreferences
public FormatPreferences(java.io.InputStream inputStream) throws java.io.IOExceptionConstruct a new instance using a properties read from the given stream.- Parameters:
inputStream- the stream to read properties from- Throws:
java.io.IOException- if an error occurs while reading the properties
-
FormatPreferences
public FormatPreferences(java.io.Reader reader) throws java.io.IOExceptionConstruct a new instance using a properties read from the given stream.- Parameters:
reader- the stream to read properties from- Throws:
java.io.IOException- if an error occurs while reading the properties
-
-
Method Detail
-
fnf
private static java.io.InputStream fnf(java.io.InputStream stream) throws java.io.IOException- Throws:
java.io.IOException
-
xf
private static java.lang.String xf(java.lang.String name)
-
split
private static void split(java.util.ArrayList<java.lang.String> dest, char delim, java.lang.String s)
-
load
private static java.util.Properties load(java.io.Reader reader) throws java.io.IOException- Throws:
java.io.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
public int getIndent(FormatPreferences.Indentation indentation)
Get the configured indentation for the given context.- Parameters:
indentation- the indentation context- Returns:
- the indentation
-
setIndent
public int setIndent(FormatPreferences.Indentation indentation, int value)
Set the configured indentation for the given context.- Parameters:
indentation- the indentation contextvalue- the indentation- Returns:
- the previous indentation
-
isIndentAbsolute
public boolean isIndentAbsolute(FormatPreferences.Indentation indentation)
Determine whether the indentation for the given context is absolute or relative.- Parameters:
indentation- the indentation context- Returns:
trueif absolute,falseif relative
-
setIndentAbsolute
public void setIndentAbsolute(FormatPreferences.Indentation indentation)
Set absolute indentation for the given context.- Parameters:
indentation- the indentation context
-
clearIndentAbsolute
public void clearIndentAbsolute(FormatPreferences.Indentation indentation)
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
public void setAllSpaceTypes(FormatPreferences.SpaceType toType, FormatPreferences.Space... spaces)
Set several space contexts to the same spacing type.- Parameters:
toType- the type to set tospaces- the space contexts
-
getSpaceType
public FormatPreferences.SpaceType getSpaceType(FormatPreferences.Space space)
Get the spacing type for a given space context.- Parameters:
space- the space context- Returns:
- the spacing type
-
getWrapMode
public FormatPreferences.WrappingMode getWrapMode(FormatPreferences.Wrapping wrapping)
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
public void addOption(FormatPreferences.Opt... opts)
Add option flags to these preferences.- Parameters:
opts- the flags to add
-
removeOption
public void removeOption(FormatPreferences.Opt... opts)
Remove option flags from these preferences.- Parameters:
opts- the flags to remove
-
hasOption
public boolean hasOption(FormatPreferences.Opt opt)
Determine whether the given option flag is set on these preferences.- Parameters:
opt- the flag to check- Returns:
trueif the flag is present,falseif it is absent
-
-