Class FirstKeywordPeek
java.lang.Object
org.apache.sis.internal.storage.wkt.FirstKeywordPeek
Inspects the type of a text file based on the first keyword.
- Since:
- 0.8
- Version:
- 1.2
- Author:
- Martin Desruisseaux (Geomatys)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intReturn values for theisKeywordChar(int)method.protected static final charThe comment character to ignore.protected static final intReturn values for theisKeywordChar(int)method.protected final intLength of the longest keyword.protected static final intReturn values for theisKeywordChar(int)method. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ProbeResultforKeyword(char[] keyword, int length) Returns the value to be returned byfor the given keyword.invalid reference
#probeContent(StorageConnector)protected PathgetAuxiliaryPath(StorageConnector connector) If the data to read is not provided by the connector by rather by some auxiliary file relative to the connector, returns the path to that auxiliary file.protected intisKeywordChar(int c) Returnstrueif the given character is valid for a keyword.protected abstract booleanisPostKeyword(int c) Returnstrueif the given first non-white character after the keyword is one of the expected characters.final ProbeResultprobeContent(Path file) ReturnsProbeResult.SUPPORTEDif the content of given file begins with an expected keyword.final ProbeResultprobeContent(DataStoreProvider provider, StorageConnector connector) ReturnsProbeResult.SUPPORTEDif the given storage appears to begin with an expected keyword.
-
Field Details
-
REJECT
protected static final int REJECTReturn values for theisKeywordChar(int)method.- See Also:
-
ACCEPT
protected static final int ACCEPTReturn values for theisKeywordChar(int)method.- See Also:
-
IGNORE
protected static final int IGNOREReturn values for theisKeywordChar(int)method.- See Also:
-
COMMENT
protected static final char COMMENTThe comment character to ignore.- See Also:
-
maxLength
protected final int maxLengthLength of the longest keyword.
-
-
Constructor Details
-
FirstKeywordPeek
public FirstKeywordPeek(int maxLength) Creates a new provider.- Parameters:
maxLength- length of the longest keyword.
-
-
Method Details
-
getAuxiliaryPath
If the data to read is not provided by the connector by rather by some auxiliary file relative to the connector, returns the path to that auxiliary file. The default implementation returnsnull.- Parameters:
connector- the connector from which to derive the path to auxiliary file to test.- Returns:
- path to the auxiliary file to test, or
nullif it does not exist. - Throws:
DataStoreException- if an error occurred while determining the auxiliary file.- Since:
- 1.1
-
isKeywordChar
protected int isKeywordChar(int c) Returnstrueif the given character is valid for a keyword. -
probeContent
public final ProbeResult probeContent(DataStoreProvider provider, StorageConnector connector) throws DataStoreException ReturnsProbeResult.SUPPORTEDif the given storage appears to begin with an expected keyword. ReturningSUPPORTEDfrom this method does not guarantee that reading or writing will succeed, only that there appears to be a reasonable chance of success based on a brief inspection of the storage header.- Parameters:
provider- the data store provider which is performing the probe operation.connector- information about the storage (URL, stream, etc).- Returns:
ProbeResult.SUPPORTEDif the given storage seems to be readable.- Throws:
DataStoreException- if an I/O error occurred.
-
probeContent
ReturnsProbeResult.SUPPORTEDif the content of given file begins with an expected keyword. This method can be invoked as an alternative towhen the file to test is not the specified storage, but some auxiliary file.invalid reference
#probeContent(StorageConnector)- Parameters:
file- the file to partially read.- Returns:
ProbeResult.SUPPORTEDif the given file seems to be readable.- Throws:
DataStoreException- if an I/O error occurred.- Since:
- 1.1
- See Also:
-
isPostKeyword
protected abstract boolean isPostKeyword(int c) Returnstrueif the given first non-white character after the keyword is one of the expected characters.- Parameters:
c- the first non-white character after the keyword, or -1 if we reached the end of stream.- Returns:
trueif the given character is one of the expected post-keyword characters.
-
forKeyword
Returns the value to be returned byfor the given keyword.invalid reference
#probeContent(StorageConnector)- Parameters:
keyword- the first keyword found in the input. May benulliflengthis zero.length- number of valid characters inkeyword.- Returns:
ProbeResult.SUPPORTEDif the given storage seems to be readable.
-