Package org.ec4j.core.parser
Class EditorConfigParser
java.lang.Object
org.ec4j.core.parser.EditorConfigParser
- All Implemented Interfaces:
ParseContext
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final char[]private intprivate final StringBuilderprivate intprivate intprivate static final intprivate ErrorHandlerprivate intprivate EditorConfigHandlerprivate intprivate booleanprivate intprivate intprivate intprivate Readerprivate Resource -
Constructor Summary
ConstructorsConstructorDescriptionEditorConfigParser(int bufferSize) Use thebuilder()ordefault_()to create new instances. -
Method Summary
Modifier and TypeMethodDescriptionstatic EditorConfigParser.Builderbuilder()static EditorConfigParserdefault_()private Stringprivate StringendCapture(int index, boolean trimTrailing) private voidprivate booleanprivate booleanprivate booleanprivate booleanisNewLine(int c) private booleanprivate booleanprivate static booleanisWhiteSpace(int c) voidparse(Resource resource, EditorConfigHandler handler, ErrorHandler errorHandler) Reads the entire input from theresourceand transforms it into a sequence of parse events which are sent to the givenEditorConfigHandler.private static StringpreprocessPropertyName(String name) Return the lowercased property name.private voidread()private booleanreadChar(char ch) private voidprivate voidreadGlob()private voidreadLine()private voidprivate voidprivate voidprivate StringreadString(EditorConfigParser.StopReading stop, boolean trimTrailing) private voidprivate void
-
Field Details
-
DEFAULT_BUFFER_SIZE
private static final int DEFAULT_BUFFER_SIZE- See Also:
-
handler
-
errorHandler
-
reader
-
buffer
private final char[] buffer -
bufferOffset
private int bufferOffset -
index
private int index -
fill
private int fill -
line
private int line -
lineOffset
private int lineOffset -
last
private int last -
current
private int current -
captureBuffer
-
captureStart
private int captureStart -
inSection
private boolean inSection -
resource
-
-
Constructor Details
-
EditorConfigParser
EditorConfigParser(int bufferSize) Use thebuilder()ordefault_()to create new instances.- Parameters:
bufferSize-tolerant-
-
-
Method Details
-
builder
- Returns:
- a new
EditorConfigParser.Builder
-
default_
- Returns:
- a new
EditorConfigParserwithDEFAULT_BUFFER_SIZE
-
parse
public void parse(Resource resource, EditorConfigHandler handler, ErrorHandler errorHandler) throws IOException Reads the entire input from theresourceand transforms it into a sequence of parse events which are sent to the givenEditorConfigHandler.- Parameters:
resource- theResourceto parsehandler- the handler to send the parse events toerrorHandler- anErrorHandlerto notify on parse errors- Throws:
IOException- on I/O problems when reading out of the givenResourceParseException- only if the suppliedErrorHandlerchooses to react on someErrorEventby throwingParseExceptions for them
-
readLines
- Throws:
IOException
-
readLine
- Throws:
IOException
-
readComment
- Throws:
IOException
-
readSection
- Throws:
IOException
-
globNotClosed
private void globNotClosed() -
readGlob
- Throws:
IOException
-
readString
private String readString(EditorConfigParser.StopReading stop, boolean trimTrailing) throws IOException - Throws:
IOException
-
isStopReading
-
readProperty
- Throws:
IOException
-
readChar
- Throws:
IOException
-
skipWhiteSpace
- Throws:
IOException
-
read
- Throws:
IOException
-
startCapture
private void startCapture() -
endCapture
-
endCapture
-
getLocation
- Specified by:
getLocationin interfaceParseContext- Returns:
- the
Locationin the parsedResourcethe parser is currently on
-
isWhiteSpace
private boolean isWhiteSpace() -
isWhiteSpace
private static boolean isWhiteSpace(int c) -
isNewLine
private boolean isNewLine() -
isNewLine
private boolean isNewLine(int c) -
isEndOfText
private boolean isEndOfText() -
isColonSeparator
private boolean isColonSeparator() -
preprocessPropertyName
Return the lowercased property name.- Parameters:
name-- Returns:
- the lowercased property name.
-
getResource
- Specified by:
getResourcein interfaceParseContext- Returns:
- the resource being parsed
-
getErrorHandler
- Specified by:
getErrorHandlerin interfaceParseContext- Returns:
- the
ErrorHandlerto notify on parse errors and semantic errors
-