Enum CommentHandlers
- java.lang.Object
-
- java.lang.Enum<CommentHandlers>
-
- org.spongepowered.configurate.loader.CommentHandlers
-
- All Implemented Interfaces:
Serializable
,Comparable<CommentHandlers>
,CommentHandler
@Immutable public enum CommentHandlers extends Enum<CommentHandlers> implements CommentHandler
Defines a number of defaultCommentHandler
s.- Since:
- 4.0.0
-
-
Enum Constant Summary
Enum Constants Enum Constant Description DOUBLE_SLASH
CommentHandler
for comments prefixed by a//
escape.HASH
CommentHandler
for comments prefixed by the#
character.SLASH_BLOCK
CommentHandler
for comments delineated using/* *\
.XML_STYLE
CommentHandler
for comments delineated using<!-- -->
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static @Nullable String
extractComment(BufferedReader reader, Iterable<CommentHandler> allowedHeaderTypes)
Uses provided comment handlers to extract a comment from the reader.@Nullable String
extractHeader(BufferedReader reader)
Defines the handlers behaviour for reading comments.Stream<String>
toComment(Stream<String> lines)
Converts the specified lines into a comment.static CommentHandlers
valueOf(String name)
Returns the enum constant of this type with the specified name.static CommentHandlers[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
HASH
public static final CommentHandlers HASH
CommentHandler
for comments prefixed by the#
character.
-
DOUBLE_SLASH
public static final CommentHandlers DOUBLE_SLASH
CommentHandler
for comments prefixed by a//
escape.
-
SLASH_BLOCK
public static final CommentHandlers SLASH_BLOCK
CommentHandler
for comments delineated using/* *\
.
-
XML_STYLE
public static final CommentHandlers XML_STYLE
CommentHandler
for comments delineated using<!-- -->
.
-
-
Method Detail
-
values
public static CommentHandlers[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (CommentHandlers c : CommentHandlers.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static CommentHandlers valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
extractHeader
public @Nullable String extractHeader(BufferedReader reader) throws IOException
Description copied from interface:CommentHandler
Defines the handlers behaviour for reading comments.- Specified by:
extractHeader
in interfaceCommentHandler
- Parameters:
reader
- reader to get input from- Returns:
- an extracted comment, if any
- Throws:
IOException
- if any IO error occurs in the process
-
toComment
public Stream<String> toComment(Stream<String> lines)
Description copied from interface:CommentHandler
Converts the specified lines into a comment.- Specified by:
toComment
in interfaceCommentHandler
- Parameters:
lines
- lines to make a comment- Returns:
- transformed lines as a stream
-
extractComment
public static @Nullable String extractComment(BufferedReader reader, Iterable<CommentHandler> allowedHeaderTypes) throws IOException
Uses provided comment handlers to extract a comment from the reader.- Parameters:
reader
- to extract a comment fromallowedHeaderTypes
- handlers to try- Returns:
- extracted comment, or null if a comment could not be extracted
- Throws:
IOException
- if an IO error occurs- Since:
- 4.0.0
-
-