org.bibalex.daf.entities.phase
Class PhysicalDef

java.lang.Object
  extended by org.bibalex.daf.entities.phase.PhysicalDef

public class PhysicalDef
extends java.lang.Object

Represents the physical section of a phase.

Author:
Shehab.Kamal

Field Summary
 java.util.ArrayList<PhysicalElement> elements
          Holds the elements defined within this section
 java.lang.String mode
          The 'Mode' property of the element.
 
Constructor Summary
PhysicalDef()
          Creates a new instance of PhysicalDef.
PhysicalDef(org.w3c.dom.Node node)
          Creates a new instance of PhysicalDef.
PhysicalDef(java.lang.String nodeRep)
          Creates a new instance of PhysicalDef.
 
Method Summary
private  void createElementFromNode(org.w3c.dom.Node node)
          Creates the PhysicalDef element by supplying its XmlNode represenation.
 PhysicalElement[] getElements()
          Gets the elements defined within this section.
 int getFilesCount(java.lang.String source, FileHandler handler, java.lang.String jobName)
          Counts the numer of files within this PhysicalElement.
Folders and Files whose ToDestination attribute equals true are counted.
 FileElement[] getSubFiles()
          Gets the files defined within this PhaseDef.
 FolderElement[] getSubFolders()
          Gets the folders defined within this PhaseDef.
private  int manageRoot(FolderElement root, java.lang.String source, FileHandler handler, java.lang.String jobName)
          Counts the number of files in the folder recursively.
 FolderElement toFolderElement()
          Converts this instance into FoldeElement instance.
 java.lang.String toString()
          Returns the string representation of this object.
 java.lang.String toXmlString()
          Returns a String representing the PhysicalDef in xml format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mode

public java.lang.String mode
The 'Mode' property of the element.


elements

public java.util.ArrayList<PhysicalElement> elements
Holds the elements defined within this section

Constructor Detail

PhysicalDef

public PhysicalDef()
Creates a new instance of PhysicalDef.


PhysicalDef

public PhysicalDef(org.w3c.dom.Node node)
            throws PhaseDefinitionException
Creates a new instance of PhysicalDef.

Parameters:
node - The Xml node that representd the element.
Throws:
PhaseDefinitionException - If the given node couldn't be parsed.

PhysicalDef

public PhysicalDef(java.lang.String nodeRep)
            throws PhaseDefinitionException
Creates a new instance of PhysicalDef.

Parameters:
nodeRep - The Xml String representing this element.
Throws:
PhaseDefinitionException - If the given String couldn't be parsed.
Method Detail

createElementFromNode

private void createElementFromNode(org.w3c.dom.Node node)
                            throws PhaseDefinitionException
Creates the PhysicalDef element by supplying its XmlNode represenation.

Parameters:
node - The Xml Node representing this element.
Throws:
PhaseDefinitionException - If a child couldn't be added.

getElements

public PhysicalElement[] getElements()
Gets the elements defined within this section.

Returns:
An array of type PhysicalElement containing the elements or an empty array if there is no elements.

getSubFolders

public FolderElement[] getSubFolders()
Gets the folders defined within this PhaseDef.

Returns:
An array of type FolderElement containing the subfolders or an empty array if there is no subfolders.

getSubFiles

public FileElement[] getSubFiles()
Gets the files defined within this PhaseDef.

Returns:
An array of type FileElement containing the subfiles or an empty array if there is no subfiles.

toFolderElement

public FolderElement toFolderElement()
Converts this instance into FoldeElement instance.

Returns:
A FolderElement that represents this instance of PhaseDef.

toString

public java.lang.String toString()
Returns the string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
The string representation of this object.

toXmlString

public java.lang.String toXmlString()
Returns a String representing the PhysicalDef in xml format.

Returns:
A String representing the PhysicalDef in xml format.

getFilesCount

public int getFilesCount(java.lang.String source,
                         FileHandler handler,
                         java.lang.String jobName)
Counts the numer of files within this PhysicalElement.
Folders and Files whose ToDestination attribute equals true are counted.

Parameters:
source - The source folder that correspond to the physical definition.
handler - The FileHandler used to access the folder.
jobName - The name of the job. This is required in case of validating the name of the file.
Returns:
The number of files within the folder.

manageRoot

private int manageRoot(FolderElement root,
                       java.lang.String source,
                       FileHandler handler,
                       java.lang.String jobName)
Counts the number of files in the folder recursively.

Parameters:
root - The FolderElement to traverse.
source - The physical folder that corresponds to the parent of the given FolderElement.
handler - The FileHandler used to count the files.
jobName - The name of the of the job folder. It is used in case of validating files names.
Returns:
The number of files within the PhysicalDef.