Class CharacterSeparatedImportMetadataSourceServiceImpl

    • Constructor Detail

      • CharacterSeparatedImportMetadataSourceServiceImpl

        public CharacterSeparatedImportMetadataSourceServiceImpl()
    • Method Detail

      • setSkipLines

        public void setSkipLines​(Integer skipLines)
        Set the number of lines to skip at the start of the file. This method is suitable, for example, to skip file headers.
        Parameters:
        skipLines - number of the line at the start of the file to skip.
      • getSkipLines

        public Integer getSkipLines()
        Returns:
        the number of the lines to skip
      • setSeparator

        public void setSeparator​(char separator)
        Method to inject the separator This must be the ASCII integer related to the char. In example, 9 for tab, 44 for comma
      • setQuoteCharacter

        public void setQuoteCharacter​(char quoteCharacter)
        Method to inject the escape character, usually ". This must be the ASCII integer related to the char. In example, 9 for tab, 44 for comma
      • setEscapeCharacter

        public void setEscapeCharacter​(char escapeCharacter)
        Method to inject the escape character, usually \. This must be the ASCII integer related to the char. In example, 9 for tab, 44 for comma
      • getImportSource

        public String getImportSource()
        Description copied from interface: MetadataSource
        The string that identifies this import implementation. Preferable a URI
        Returns:
        the identifying uri
      • setImportSource

        public void setImportSource​(String importSource)
        Method to set the name of the source
      • readData

        protected List<PlainMetadataSourceDto> readData​(InputStream inputStream)
                                                 throws FileSourceException
        The method process any kind of "character separated" files, like CSV, TSV, and so on. It return a List of PlainMetadataSourceDto. Using the superclass methods AbstractPlainMetadataSource.getRecord(s), any of this element will then be converted in an ImportRecord. Columns will be identified by their position, zero based notation. Separator character and escape character MUST be defined at class level. Number of lines to skip (headers) could also be defined in the field skipLines.
        Specified by:
        readData in class AbstractPlainMetadataSource
        Parameters:
        InputStream - The inputStream of the file
        Returns:
        A list of PlainMetadataSourceDto
        Throws:
        FileSourceException - if, for any reason, the file is not parsable