Package thredds.inventory.partition
Class DirectoryBuilder
- java.lang.Object
-
- thredds.inventory.partition.DirectoryBuilder
-
public class DirectoryBuilder extends Object
A Builder of DirectoryPartitions and DirectoryCollections. Each DirectoryBuilder is associated with one directory, and one ncx index. This may contain collections of files (MFiles in a DirectoryCollection), or subdirectories (MCollections in a DirectoryPartition).- Since:
- 11/10/13
-
-
Constructor Summary
Constructors Constructor Description DirectoryBuilder(String topCollectionName, String dirFilename, String suffix)
DirectoryBuilder(String topCollectionName, Path dir, BasicFileAttributes attr, String suffix)
Create a DirectoryBuilder for the named directory
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<DirectoryBuilder>
constructChildren(IndexReader indexReader, CollectionUpdateType forceCollection)
Find all children directories.List<DirectoryBuilder>
constructChildrenFromIndex(IndexReader indexReader, boolean substituteParentDir)
static MCollection
factory(FeatureCollectionConfig config, Path topDir, boolean isTop, IndexReader indexReader, String suffix, org.slf4j.Logger logger)
boolean
findIndex()
Find the index file, using its canonical nameList<DirectoryBuilder>
getChildren()
May be null if constructChildren() was not calledPath
getDir()
The directory that the partition coversPath
getIndex()
The ncx2 fileString
getPartitionName()
List<MFile>
readFilesFromIndex(IndexReader indexReader)
void
show(Formatter out)
-
-
-
Constructor Detail
-
DirectoryBuilder
public DirectoryBuilder(String topCollectionName, String dirFilename, String suffix) throws IOException
- Throws:
IOException
-
DirectoryBuilder
public DirectoryBuilder(String topCollectionName, Path dir, BasicFileAttributes attr, String suffix) throws IOException
Create a DirectoryBuilder for the named directory- Parameters:
topCollectionName
- from config, name of the collectiondir
- covers this directoryattr
- file attributes, may be null- Throws:
IOException
-
-
Method Detail
-
factory
public static MCollection factory(FeatureCollectionConfig config, Path topDir, boolean isTop, IndexReader indexReader, String suffix, org.slf4j.Logger logger) throws IOException
- Throws:
IOException
-
findIndex
public boolean findIndex() throws IOException
Find the index file, using its canonical name- Returns:
- true if found
- Throws:
IOException
-
constructChildren
public List<DirectoryBuilder> constructChildren(IndexReader indexReader, CollectionUpdateType forceCollection) throws IOException
Find all children directories. Does not recurse. We separate this from the constructor so it can be done on demand Public for debugging. Look for children by:- If index exists , use the children inside there./li>
- (or) scan the directory for children partitions
- Parameters:
indexReader
- this reads the index, and calls AddChild.addchild() for each child- Returns:
- children, may be empty but not null
- Throws:
IOException
-
constructChildrenFromIndex
public List<DirectoryBuilder> constructChildrenFromIndex(IndexReader indexReader, boolean substituteParentDir) throws IOException
- Throws:
IOException
-
readFilesFromIndex
public List<MFile> readFilesFromIndex(IndexReader indexReader) throws IOException
- Throws:
IOException
-
getDir
public Path getDir()
The directory that the partition covers- Returns:
- directory
-
getIndex
public Path getIndex()
The ncx2 file- Returns:
- ncx2 file path
-
getChildren
public List<DirectoryBuilder> getChildren()
May be null if constructChildren() was not called- Returns:
- children directories
-
getPartitionName
public String getPartitionName()
-
show
public void show(Formatter out)
-
-