org.sandev.sandbuild
Class SandDecl

java.lang.Object
  extended byorg.sandev.sandbuild.SandDecl
All Implemented Interfaces:
java.lang.Comparable

public class SandDecl
extends java.lang.Object
implements java.lang.Comparable

The primary source information passed to a SandGenerator. When the generator receives a SandDecl, all the fields are ready for use, but initialization actually happens in stages:

  1. The SandProject initially loads the SandDecl, setting the declType and sourceFile fields. The SandProject keeps a record of the SandDecls it found each time, so it can track deletions on incremental builds. The SandProject marks any deleted declarations as STATUS_DELETED when it does this merge.
  2. After loading, the SandProject walks the declarations calling init for each one, which in turn sets the status and qualifiedName fields from the type and source information. See the init method for details.
  3. At runtime, the GenDriverDoclet sets the corresponding ClassDoc field by merging the classes retrieved from the RootDoc with the known SandDecls. This is done using the qualifiedName.


Field Summary
protected  com.sun.javadoc.ClassDoc cd
          The ClassDoc for this declaration.
protected  int declType
          What kind of SAND declaration this is.
protected  java.lang.String qualifiedName
          The fully qualified name of this declaration.
protected  java.io.File sourceFile
          The full source file for this declaration.
protected  int status
          The status of this declaration.
static int STATUS_CHANGED
          this declaration has changed since the last build
static int STATUS_DELETED
          this declaration has been deleted since the last build.
static int STATUS_NEW
          this declaration has been created after the last build
static int STATUS_UNCHANGED
          this declaration has NOT changed since the last build
static int TYPE_NODE
          This is a node declaration
static int TYPE_STRUCT
          This is a struct declartion
 
Constructor Summary
SandDecl()
          The default ctor does nothing.
 
Method Summary
 int compareTo(java.lang.Object other)
          The natural ordering of SandDecls is the natural ordering of their source files.
 com.sun.javadoc.ClassDoc getClassDoc()
          accessor for ClassDoc
 int getDeclType()
          accessor for declType
 java.lang.String getQualifiedName()
          accessor for qualifiedName
 java.io.File getSourceFile()
          accessor for sourceFile
 int getStatus()
          accessor for status
 java.lang.String getUnqualifiedName()
          Get the unqualified name of this declaration.
 boolean hasChanged()
          Returns true if this SAND declaration is NOT STATUS_UNCHANGED
 void init()
          Set the qualifiedName from our source, and update our status.
protected  java.lang.String qualifiedNameFromSource(java.lang.String srcFileName)
          Given a file specification, return the corresponding qualified class name.
 void setClassDoc(com.sun.javadoc.ClassDoc doc)
          mutator for ClassDoc
 void setDeclType(int val)
          mutator for declType
 void setQualifiedName(java.lang.String name)
          mutator for qualifiedName
 void setSourceFile(java.io.File src)
          mutator for sourceFile
 void setStatus(int val)
          mutator for status
static java.lang.String statusToString(int status)
          Return the current status as a string.
 void updateStatus()
          Figure out our change status from our source file and a known target file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_STRUCT

public static final int TYPE_STRUCT
This is a struct declartion

See Also:
Constant Field Values

TYPE_NODE

public static final int TYPE_NODE
This is a node declaration

See Also:
Constant Field Values

declType

protected int declType
What kind of SAND declaration this is. One of the TYPE_* values.


STATUS_UNCHANGED

public static final int STATUS_UNCHANGED
this declaration has NOT changed since the last build

See Also:
Constant Field Values

STATUS_CHANGED

public static final int STATUS_CHANGED
this declaration has changed since the last build

See Also:
Constant Field Values

STATUS_NEW

public static final int STATUS_NEW
this declaration has been created after the last build

See Also:
Constant Field Values

STATUS_DELETED

public static final int STATUS_DELETED
this declaration has been deleted since the last build.

See Also:
Constant Field Values

status

protected int status
The status of this declaration. One of the STATUS_* values.


cd

protected com.sun.javadoc.ClassDoc cd
The ClassDoc for this declaration. See javadoc tool for details.


sourceFile

protected java.io.File sourceFile
The full source file for this declaration. Note that the file will not exist if this is a deleted declaration.


qualifiedName

protected java.lang.String qualifiedName
The fully qualified name of this declaration. This is also available from the ClassDoc, and is used for comparison.

Constructor Detail

SandDecl

public SandDecl()
The default ctor does nothing. See the class comments for usage.

Method Detail

getDeclType

public int getDeclType()
accessor for declType


setDeclType

public void setDeclType(int val)
mutator for declType


statusToString

public static java.lang.String statusToString(int status)
Return the current status as a string. Useful for debugging.


getStatus

public int getStatus()
accessor for status


setStatus

public void setStatus(int val)
mutator for status


hasChanged

public boolean hasChanged()
Returns true if this SAND declaration is NOT STATUS_UNCHANGED


updateStatus

public void updateStatus()
                  throws SandBuildException
Figure out our change status from our source file and a known target file. Struct declarations are compared against their corresponding SandStructMessage source (so structs/MyDataStruct.java is compared to sandmessages/MyData.java). Node declarations are compared against their corresponding NodeBase (so MyProcNodeDecl.java is compared to MyProcNodeBase.java).

Throws:
SandBuildException

getClassDoc

public com.sun.javadoc.ClassDoc getClassDoc()
accessor for ClassDoc


setClassDoc

public void setClassDoc(com.sun.javadoc.ClassDoc doc)
mutator for ClassDoc


getSourceFile

public java.io.File getSourceFile()
accessor for sourceFile


setSourceFile

public void setSourceFile(java.io.File src)
mutator for sourceFile


getQualifiedName

public java.lang.String getQualifiedName()
accessor for qualifiedName


setQualifiedName

public void setQualifiedName(java.lang.String name)
mutator for qualifiedName


getUnqualifiedName

public java.lang.String getUnqualifiedName()
Get the unqualified name of this declaration. Useful for debug and log output.


compareTo

public int compareTo(java.lang.Object other)
The natural ordering of SandDecls is the natural ordering of their source files.

Specified by:
compareTo in interface java.lang.Comparable

init

public void init()
          throws SandBuildException
Set the qualifiedName from our source, and update our status. See the updateStatus method for details.

Throws:
SandBuildException

qualifiedNameFromSource

protected java.lang.String qualifiedNameFromSource(java.lang.String srcFileName)
                                            throws SandBuildException
Given a file specification, return the corresponding qualified class name. We can guess the qualified name using the source directory area, but if a struct is copied into that directory from somewhere else, and it has a different package declaration, then guessing doesn't work. The only safe way is to read the package declaration out of the file itself.

Throws:
SandBuildException