org.archive.crawler.writer
Class MirrorWriterProcessor.PathSegment

java.lang.Object
  extended by org.archive.crawler.writer.MirrorWriterProcessor.PathSegment
Direct Known Subclasses:
MirrorWriterProcessor.DirSegment, MirrorWriterProcessor.EndSegment
Enclosing class:
MirrorWriterProcessor

abstract class MirrorWriterProcessor.PathSegment
extends java.lang.Object

This class represents one segment (component) of a URI path. A segment between '/' characters is a directory segment. The segment after the last '/' is the end segment.


Nested Class Summary
(package private)  class MirrorWriterProcessor.PathSegment.CaseInsensitiveFilenameFilter
          This class implements a FilenameFilter that matches by name, ignoring case.
 
Field Summary
protected  CrawlURI curi
          The URI, for logging and error reporting.
protected static int EXISTS_CASE_INSENSITIVE_MATCH
          existsMaybeCaseSensitive return code for a file that exists, using a case-insensitive comparison.
protected static int EXISTS_EXACT_MATCH
          existsMaybeCaseSensitive return code for a file that exists.
protected static int EXISTS_NOT
          existsMaybeCaseSensitive return code for a file that does not exist.
protected  MirrorWriterProcessor.LumpyString mainPart
          The main part of this segment.
protected  int maxSegLen
          The maximum number of characters allowed in one file system path segment.
 
Constructor Summary
MirrorWriterProcessor.PathSegment(int maxSegLen, boolean caseSensitive, CrawlURI curi)
          Creates a new PathSegment.
 
Method Summary
(package private) abstract  void addToPath(MirrorWriterProcessor.URIToFileReturn currentPath)
          Adds this segment to a file path.
protected  int existsMaybeCaseSensitive(java.io.File fsf, java.lang.String segStr, java.io.File check)
          Checks if a file (including directories) exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXISTS_NOT

protected static final int EXISTS_NOT
existsMaybeCaseSensitive return code for a file that does not exist.

See Also:
Constant Field Values

EXISTS_EXACT_MATCH

protected static final int EXISTS_EXACT_MATCH
existsMaybeCaseSensitive return code for a file that exists. Furthermore, the comparison is case-sensitive.

See Also:
Constant Field Values

EXISTS_CASE_INSENSITIVE_MATCH

protected static final int EXISTS_CASE_INSENSITIVE_MATCH
existsMaybeCaseSensitive return code for a file that exists, using a case-insensitive comparison. Furthermore, the file would not exist if the comparison were case-sensitive.

See Also:
Constant Field Values

curi

protected CrawlURI curi
The URI, for logging and error reporting.


mainPart

protected MirrorWriterProcessor.LumpyString mainPart
The main part of this segment. For a directory segment, that's all there is. For an end segment, it's the part of the URI after the last '/' up to but not including the '.' before the suffix (if any).


maxSegLen

protected int maxSegLen
The maximum number of characters allowed in one file system path segment. A URI segment can potentially be much longer, but we'll trim it to this.

Constructor Detail

MirrorWriterProcessor.PathSegment

MirrorWriterProcessor.PathSegment(int maxSegLen,
                                  boolean caseSensitive,
                                  CrawlURI curi)
Creates a new PathSegment.

Parameters:
maxSegLen - the maximum number of characters allowed in one path segment
caseSensitive - if true, the file system is assumed to be case-sensitive; otherwise the file system is assumed to be case-insensitive
curi - the URI
Throws:
java.lang.IllegalArgumentException - if maxSegLen is too small
Method Detail

addToPath

abstract void addToPath(MirrorWriterProcessor.URIToFileReturn currentPath)
                 throws java.io.IOException
Adds this segment to a file path. This is the key method of this class. It extends the given path by one segment, named to obey all constraints. A new directory is created if necessary.

Parameters:
currentPath - the current path, to which this segment is added
Throws:
java.io.IOException - if a needed directory could not be created
java.io.IOException - if a needed directory is not writeable

existsMaybeCaseSensitive

protected int existsMaybeCaseSensitive(java.io.File fsf,
                                       java.lang.String segStr,
                                       java.io.File check)
Checks if a file (including directories) exists.

Parameters:
fsf - the directory containing the file to be checked
segStr - the simple file or directory name
check - the file or directory for which to check
Returns:
EXISTS_NOT if check does not exist, EXISTS_EXACT_MATCH if check exists with a name that matches (case-sensitive) segStr, and EXISTS_CASE_INSENSITIVE_MATCH if check exists with a name that matches segStr using a case-insensitive match but not using a case-sensitive match


Copyright © 2003-2011 Internet Archive. All Rights Reserved.