rendsite.engine.node
Class Node_Directory

java.lang.Object
  extended by rendsite.engine.node.Node
      extended by rendsite.engine.node.Node_Directory

public class Node_Directory
extends Node

Crawler node for a Directory.

Author:
erich Version History
 10NOV09 - EPG - First package release.
 

Field Summary
 boolean copyOnly
           
 java.lang.String description
          Information about the file.
 boolean excluded
           
 boolean ignored
           
 java.lang.String type
           
 
Constructor Summary
Node_Directory(java.io.File file, FileContext fcontext)
          Create a directory node.
 
Method Summary
 void build()
          Make sure the directory exists in the destination.
 void clean()
          Clean the directory.
 void failCatalogWrite()
          Note that the catalog write failed.
 java.lang.String getCatalogName()
          Get the catalog name.
 java.lang.String getCatalogUrl(Node_Directory source, boolean encode)
          Get the URL to the catalog relative to this directory from the passes directory.
 java.lang.String getCatalogUrlAbsolute(boolean encoded)
          Get the absolute URL to the catalog.
 java.io.File getFile()
          Get a file representing this directory.
 java.util.List<Node_File> getFiles()
          Get the files in this directory.
 java.util.List<Node_MetaFile> getLocalMetaFiles()
          Get the local metafiles in this directory.
 java.util.List<Node_MetaFile> getMetaFiles()
          Get the metafiles in this directory.
 long getMostRecentModified()
          Get the most recent modified time for all files and subdirectories under this directory.
 java.lang.String getName()
          Get the rendered name.
 java.lang.String getPath()
          Get the absolute path to this directory.
 java.util.List<Node_Directory> getSubDirectories()
          Get the subdirectories in this directory.
 java.lang.String getURLAbsolute(boolean encode)
          Get the URL for this directory from the root.
 java.lang.String getURLRendering()
          Get the URL for this directory from the root for rendering purposes only.
 java.lang.String getURLtoRoot(boolean encode)
          Get the URL to the root from this directory.
static boolean isLocalMetafile(java.io.File theFile)
          Is this file a LOCAL METAFILE?
static boolean isMetafile(java.io.File theFile)
          Is this file a METAFILE?
 long lastModifiedCatalog()
          Get the last modified date for the catalog.
 void modifiedTime(long datetime)
          Potentially set the most recent modified time.
 java.io.OutputStream openCatalogForWrite()
          Open for the catalog file for writing.
 void setCatalogName(java.lang.String name)
          Set the catalog name.
 void setFiles(java.util.List<Node_File> newFileList)
          Set the files.
 void setSubDirectories(java.util.List<Node_Directory> newSubList)
          Set the sub directories.
 
Methods inherited from class rendsite.engine.node.Node
getType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

copyOnly

public boolean copyOnly

ignored

public boolean ignored

excluded

public boolean excluded

description

public java.lang.String description
Information about the file. If the 'description' is null, there is no other info about the file.


type

public java.lang.String type
Constructor Detail

Node_Directory

public Node_Directory(java.io.File file,
                      FileContext fcontext)
               throws java.lang.Throwable
Create a directory node.

Parameters:
file - the file representing the directory.
fcontext - the file context.
Throws:
java.lang.Throwable - either from bugs or because it can't process the contents of the directory.
Method Detail

modifiedTime

public void modifiedTime(long datetime)
Potentially set the most recent modified time. The most recent modified value for this directory will be the greatest of the passed value and the existing setting.

Parameters:
datetime - the proposed modified time in milliseconds from epoch.

getMostRecentModified

public long getMostRecentModified()
Get the most recent modified time for all files and subdirectories under this directory. This value is NOT reliable until the directory is completely processed.

Returns:
the most recent modified time in seconds from epoch.

getName

public java.lang.String getName()
Get the rendered name. It'll be nothing or overridden by a sub class.

Overrides:
getName in class Node
Returns:
the name. DO NOT USE THIS TO OPEN A FILE!

getSubDirectories

public java.util.List<Node_Directory> getSubDirectories()
                                                 throws java.lang.Throwable
Get the subdirectories in this directory.

Returns:
a list. It may be empty.
Throws:
java.lang.Throwable

getFiles

public java.util.List<Node_File> getFiles()
                                   throws java.lang.Throwable
Get the files in this directory.

Returns:
a list. It may be empty..
Throws:
java.lang.Throwable

getMetaFiles

public java.util.List<Node_MetaFile> getMetaFiles()
                                           throws java.lang.Throwable
Get the metafiles in this directory.

Returns:
a list. It may be empty.
Throws:
java.lang.Throwable

getLocalMetaFiles

public java.util.List<Node_MetaFile> getLocalMetaFiles()
                                                throws java.lang.Throwable
Get the local metafiles in this directory.

Returns:
a list. It may be empty.
Throws:
java.lang.Throwable

getFile

public java.io.File getFile()
Get a file representing this directory. It might be null, if it hasn't been fixed yet.

Returns:
the file.

setFiles

public void setFiles(java.util.List<Node_File> newFileList)
              throws java.lang.Throwable
Set the files. Only the engine should ever do this.

Parameters:
newFileList - the files to set.
Throws:
java.lang.Throwable

setSubDirectories

public void setSubDirectories(java.util.List<Node_Directory> newSubList)
                       throws java.lang.Throwable
Set the sub directories. Only the engine should ever do this.

Parameters:
newSubList - the files to set as the subs.
Throws:
java.lang.Throwable

getCatalogName

public java.lang.String getCatalogName()
Get the catalog name. Only the context or engine should ever use this method!!! Everyone else should call PropertiesContext.GET_CATALOG_NAME. I realize I can create an intermediate interface or class, but that's just too much for now. This is buffoonery protection and would be a whole lot more elegant in another language.

Returns:
The name or null if it hasn't been set.

setCatalogName

public void setCatalogName(java.lang.String name)
Set the catalog name. Only the context or engine should ever use this method!!! Only the context or engine should ever use this method!!! Everyone else should call PropertiesContext.GET_CATALOG_NAME. This is buffoonery protection and would be a whole lot more elegant in another language.

Parameters:
name - the name

build

public void build()
           throws java.lang.Throwable
Make sure the directory exists in the destination.

Throws:
java.lang.Throwable

getPath

public java.lang.String getPath()
Get the absolute path to this directory. NEVER, EVER use this to open a file! This is a "unique name" for the directory. All other uses are UNRELIABLE!

Returns:
the path.

lastModifiedCatalog

public long lastModifiedCatalog()
                         throws things.common.ThingsException
Get the last modified date for the catalog.

Returns:
the last modified date as milliseconds from epoch, 0 if the catalog does not exist on the fs, and NOW if the catalogName has not been set.
Throws:
things.common.ThingsException

getCatalogUrlAbsolute

public java.lang.String getCatalogUrlAbsolute(boolean encoded)
                                       throws java.lang.Throwable
Get the absolute URL to the catalog.

Parameters:
encoded - encode it for html?
Returns:
the URL
Throws:
java.lang.Throwable

getCatalogUrl

public java.lang.String getCatalogUrl(Node_Directory source,
                                      boolean encode)
                               throws java.lang.Throwable
Get the URL to the catalog relative to this directory from the passes directory.

Parameters:
source - from where this will point.
encode - encode the URL properly. Set to false for it to be display worthy.
Returns:
the URL
Throws:
java.lang.Throwable

getURLAbsolute

public java.lang.String getURLAbsolute(boolean encode)
                                throws java.lang.Throwable
Get the URL for this directory from the root.

Parameters:
encode - encode the URL properly. Set to false for it to be display worthy.
Returns:
the URL
Throws:
java.lang.Throwable - if there is a problem forming the URL or a bug.

getURLRendering

public java.lang.String getURLRendering()
Get the URL for this directory from the root for rendering purposes only. Any problem will yield some form of error test. It'll will never throw an exception.

Returns:
the URL

getURLtoRoot

public java.lang.String getURLtoRoot(boolean encode)
                              throws java.lang.Throwable
Get the URL to the root from this directory.

Parameters:
encode - encode the URL properly. Set to false for it to be display worthy.
Returns:
the URL to the root.
Throws:
java.lang.Throwable

openCatalogForWrite

public java.io.OutputStream openCatalogForWrite()
                                         throws things.common.ThingsException
Open for the catalog file for writing. The stream will not be buffered. You should close it when you are done. It will mark the file as having been updated for other processing.

Returns:
an output stream for writing.
Throws:
things.common.ThingsException

failCatalogWrite

public void failCatalogWrite()
                      throws java.lang.Throwable
Note that the catalog write failed. The last modified date will be set to 1 (one millisecond after epoch) and the filecontext will be notified.

Throws:
things.common.ThingsException - will only happen for bugs, which will be a panic.
java.lang.Throwable

isMetafile

public static boolean isMetafile(java.io.File theFile)
Is this file a METAFILE?

Parameters:
theFile - the file. If null, it'll always return false.
Returns:
true if it is, otherwise false.

isLocalMetafile

public static boolean isLocalMetafile(java.io.File theFile)
Is this file a LOCAL METAFILE?

Parameters:
theFile - the file. If null, it'll always return false.
Returns:
true if it is.

clean

public void clean()
           throws java.lang.Throwable
Clean the directory. It will wipe out anything in the output directory that cannot be matched to something in the Node_Directory.

Throws:
java.lang.Throwable - for a wide range of offenses.


rendsite.