[
https://issues.apache.org/jira/browse/TIKA-1726?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14725769#comment-14725769
]
Yaniv Kunda commented on TIKA-1726:
-----------------------------------
Funny you proposed those two alternatives - exactly what I started with... But
compared to the methods in the Java platform it seems partly incorrect as these
mostly deal with files, located using paths, e.g. Files.createTempFile.
So for createTemporaryFile I think that createTemporaryPath is problematic in
the sense that an actual file is created, not just a path.
I suggested the add* variants to hint that the file is added to the list of
resources to close, as in addResource.
For getFile, getPath is actually pretty ok but I think both are problematic in
that they look like a getter - I wanted to signify its write-to-file
functionality.
How about save/store/persist?
Regarding deprecation, not a problem - I'll drop it and add a @see tag from the
old method to the new one (but not the other way round?).
In both questions, my suggestions are only suggestions, and my reservations are
only reservations - but if you can take a call and make any decision I'd be
happy to accept it and move this forward.
> Augment public methods that use a java.io.File with methods that use a
> java.nio.file.Path
> -----------------------------------------------------------------------------------------
>
> Key: TIKA-1726
> URL: https://issues.apache.org/jira/browse/TIKA-1726
> Project: Tika
> Issue Type: Improvement
> Components: batch, core, gui, parser, translation
> Reporter: Yaniv Kunda
> Priority: Minor
> Fix For: 1.11
>
>
> In light of Java 7 already EOL, it's high time we add support for the new
> java.nio.file.Path class introduced with it, which, together with support
> methods in java.nio.file.Files and others, provide a better file I/O
> framework than java.io.File.
> In just two cases, we have public methods in tika that only return a File
> object, and cannot be overloaded, so a different name for the new method must
> be created:
> - {{org.apache.tika.io.TemporaryResources#createTemporaryFile()}}
> _Suggestions:_
> -- addTemporaryFile
> -- addTempFile
> -- createTempFile
> - {{org.apache.tika.io.TikaInputStream#getFile()}}
> _Suggestions:_
> -- asFile
> -- toPath
> -- getPath
> In other cases, the methods accept a File as an argument, and should remain
> as tika users might be using them - so an overloaded method that accepts a
> Path instead should be added, deprecating the old method until an unknown
> tika major release.
> Here is the full list of other methods:
> _tika-app:_
> - {{org.apache.tika.gui.TikaGUI#openFile(File)}}
> _tika-batch:_
> - {{org.apache.tika.batch.fs.FSUtil#getOutputFile(File, String,
> HANDLE_EXISTING, String)}}
> - {{org.apache.tika.util.PropsUtil#getFile(String, File)}}
> - {{org.apache.tika.batch.fs.FSDirectoryCrawler}} constructors
> -
> {{org.apache.tika.batch.fs.FSDirectoryCrawler#handleFirstFileInDirectory(File)}}
> - {{org.apache.tika.batch.fs.FSFileResource}} constructor
> - {{org.apache.tika.batch.fs.FSListCrawler}} constructor
> - {{org.apache.tika.batch.fs.FSOutputStreamFactory}} constructor
> - {{org.apache.tika.batch.fs.FSUtil#checkThisIsAncestorOfOrSameAsThat(File,
> File)}}
> - {{org.apache.tika.batch.fs.FSUtil#checkThisIsAncestorOfThat(File, File)}}
> - {{org.apache.tika.batch.fs.strawman.StrawManTikaAppDriver}} constructor
> _tika-core:_
> - {{org.apache.tika.Tika#detect(File)}}
> - {{org.apache.tika.Tika#parse(File)}}
> - {{org.apache.tika.Tika#parseToString(File)}}
> - {{org.apache.tika.config.TikaConfig}} constructors
> - {{org.apache.tika.detect.NNExampleModelDetector}} constructor
> - {{org.apache.tika.detect.TrainedModelDetector#loadDefaultModels(File)}}
> - {{org.apache.tika.io.TemporaryResources#setTemporaryFileDirectory(File)}}
> - {{org.apache.tika.io.TikaInputStream#get(File)}}
> - {{org.apache.tika.io.TikaInputStream#get(File, Metadata)}}
> _tika-parsers:_
> - {{org.apache.tika.parser.ParsingReader}} constructor
> - {{org.apache.tika.parser.image.ImageMetadataExtractor#parseJpeg(File)}}
> - {{org.apache.tika.parser.image.ImageMetadataExtractor#parseWebP(File)}}
> - {{org.apache.tika.parser.mp4.DirectFileReadDataSource}} constructor
> _tika-translate:_
> -
> {{org.apache.tika.language.translate.ExternalTranslator#runAndGetOutput(String,
> String[], File)}}
> Due to lack of evidence, all public methods in public non-test classes (and
> not in tika-example) are deemed part of a public API - although there's no
> formal definition of such.
> If anyone knows of a public method which isn't accessed publicly and can be
> defined as package-private, or for another reason, please comment.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)