Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions components/bio-formats/src/loci/formats/in/BrukerReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ public BrukerReader() {

// -- IFormatReader API methods --

/* @see loci.formats.IFormatReader#getRequiredDirectories(String[]) */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to start the comment with two asterisks so that Javadoc can pick it up?

(oh, no, sorry, just as a normal comment Javadoc will pick up the doc from the interface, I think, I was just wrongfooted by the Javadoc-style "see")

public int getRequiredDirectories(String[] files)
throws FormatException, IOException
{
return 1;
}

/* @see loci.formats.IFormatReader#isSingleFile(String) */
public boolean isSingleFile(String id) throws FormatException, IOException {
return false;
Expand Down
7 changes: 7 additions & 0 deletions components/bio-formats/src/loci/formats/in/L2DReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ public boolean isThisType(RandomAccessInputStream stream) throws IOException {
return check.indexOf(LICOR_MAGIC_STRING) >= 0;
}

/* @see loci.formats.IFormatReader#getRequiredDirectories(String[]) */
public int getRequiredDirectories(String[] files)
throws FormatException, IOException
{
return 1;
}

/* @see loci.formats.IFormatReader#isSingleFile(String) */
public boolean isSingleFile(String id) throws FormatException, IOException {
return false;
Expand Down
37 changes: 37 additions & 0 deletions components/bio-formats/src/loci/formats/in/MIASReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,43 @@ public MIASReader() {

// -- IFormatReader API methods --

/* @see loci.formats.IFormatReader#getRequiredDirectories(String[]) */
public int getRequiredDirectories(String[] files)
throws FormatException, IOException
{
StringBuffer commonParent = new StringBuffer();

int dirCount = 0;

String[] dirs = files[0].split(File.separatorChar == '/' ? "/" : "\\\\");
for (String dir : dirs) {
boolean canAppend = true;
for (String f : files) {
if (!f.startsWith(commonParent.toString() + dir)) {
canAppend = false;
break;
}
}

if (canAppend) {
commonParent.append(dir);
commonParent.append(File.separator);
dirCount++;
}
}

int maxDirCount = 0;
for (String f : files) {
int parentDirCount =
f.split(File.separatorChar == '/' ? "/" : "\\\\").length - 1;
if (parentDirCount > maxDirCount) {
maxDirCount = parentDirCount;
}
}

return (int) Math.max(3 - (maxDirCount - dirCount), 0);
}

/* @see loci.formats.IFormatReader#isSingleFile(String) */
public boolean isSingleFile(String id) throws FormatException, IOException {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ public OperettaReader() {

// -- IFormatReader API methods --

/* @see loci.formats.IFormatReader#getRequiredDirectories(String[]) */
public int getRequiredDirectories(String[] files)
throws FormatException, IOException
{
return 1;
}

/* @see loci.formats.IFormatReader#isSingleFile(String) */
public boolean isSingleFile(String id) throws FormatException, IOException {
return false;
Expand Down
7 changes: 7 additions & 0 deletions components/scifio/src/loci/formats/FormatReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,13 @@ public boolean isSingleFile(String id) throws FormatException, IOException {
return true;
}

/* @see IFormatReader#getRequiredDirectories(String[]) */
public int getRequiredDirectories(String[] files)
throws FormatException, IOException
{
return 0;
}

/* @see IFormatReader#getDatasetStructureDescription() */
public String getDatasetStructureDescription() {
return datasetDescription;
Expand Down
16 changes: 16 additions & 0 deletions components/scifio/src/loci/formats/IFormatReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,22 @@ Object openPlane(int no, int x, int y, int w, int h)
/** Returns true if this is a single-file format. */
boolean isSingleFile(String id) throws FormatException, IOException;

/**
* Returns the number of parent directories that are important when
* processing the given list of files. The number of directories is relative
* to the common parent. For example, given a list with these two files:
*
* /path/to/file/foo
* /path/to/file/that/is/related
*
* A return value of 0 indicates that "/path/to/file/" is irrelevant.
* A return value of 1 indicates that "/path/to/" is irrelevant.
* Return values less than 0 are invalid.
*
* All listed files are assumed to belong to datasets of the same format.
*/
int getRequiredDirectories(String[] files) throws FormatException, IOException;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I think of this as a static method -- does reader state matter at all?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A pre-setId method, so nearly static.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be called before or after setId; the current reader state makes no difference.


/** Returns a short description of the dataset structure. */
String getDatasetStructureDescription();

Expand Down
7 changes: 7 additions & 0 deletions components/scifio/src/loci/formats/ImageReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,13 @@ public boolean isSingleFile(String id) throws FormatException, IOException {
return getReader(id).isSingleFile(id);
}

/* @see IFormatReader#getRequiredDirectories(String[]) */
public int getRequiredDirectories(String[] files)
throws FormatException, IOException
{
return getReader(files[0]).getRequiredDirectories(files);
}

/* @see IFormatReader#getDatasetStructureDescription() */
public String getDatasetStructureDescription() {
return getReader().getDatasetStructureDescription();
Expand Down
6 changes: 6 additions & 0 deletions components/scifio/src/loci/formats/ReaderWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,12 @@ public boolean isSingleFile(String id) throws FormatException, IOException {
return reader.isSingleFile(id);
}

public int getRequiredDirectories(String[] files)
throws FormatException, IOException
{
return reader.getRequiredDirectories(files);
}

public String getDatasetStructureDescription() {
return reader.getDatasetStructureDescription();
}
Expand Down