org.prorefactor.refactor
Class PUB

java.lang.Object
  extended by org.prorefactor.refactor.PUB

public class PUB
extends java.lang.Object

The API for "Parse Unit Binary" files, which are a persistent store for syntax trees.


Nested Class Summary
 class PUB.SymbolRef
          A record of symbol type and name, for import/export tables.
 
Field Summary
static int AST
          loadTo(AST) - just loads the node types - you almost certainly need STRINGS as well.
static int END
          loadTo(END) - all binary file segments will be loaded.
static int EXPORTS
          loadTo(EXPORTS)
static int FILES
          loadTo(FILES) - the index of include files referenced by this parse unit.
static int HEADER
          loadTo(HEADER) Gets all the segments necessary for checking if the binary is up to date or not.
static int IMPORTS
          loadTo(IMPORTS)
static int LAYOUT_VERSION
          This is like a "schema version" for .pub files.
static int PUBFILE_TIMESTAMP
          loadTo(PUBFILE_TIMESTAMP) - just check if the binary exists and check that it is newer than the compile unit file.
static int SCHEMA
          loadTo(SCHEMA) - the schema tables and fields referenced by this parse unit.
static int STRINGS
          loadTo(STRINGS) - load the strings into the syntax tree.
 
Constructor Summary
PUB(java.lang.String fullPath)
          Create a PUB for a compile unit fully qualified path/name.
 
Method Summary
 ParseUnit build()
          Update the PUB.
 void build(TP01Support support)
          This is called by TreeParser01, and should not be called directly.
 void copySchemaFieldLowercaseNamesInto(java.util.Collection c, java.lang.String fromTableName)
          Copies the lower case names of all schema fields for one table into your collection.
 void copySchemaTableLowercaseNamesInto(java.util.Collection c)
          Copies the lower case names of all schema tables into your collection.
 java.lang.String getClassName()
           
 PUB.SymbolRef[] getExportTable()
          Get the array of exported symbols, in no particular order.
 PUB.SymbolRef[] getImportTable()
          Get the array of imported symbols, in no particular order.
 ParseUnit getParseUnit()
           
 java.lang.String getSuperClassName()
           
 long getTimestamp()
          Get the time stamp (File.lastModified()) of the PUB file.
 ProgramRootNode getTree()
          Return the JPNode syntax tree that was loaded with load()
 boolean isChecked()
          Has the PUB been checked to see if it's current? i.e.
 boolean isCurrent()
          Is the PUB current? You should have used isChecked() or loaded the PUB to HEADER before checking isCurrent().
 boolean load()
          Same as loadTo(PUB.END)
 boolean loadTo(int lastSegmentToLoad)
          Load the PUB file to the end of the specified segment.
static java.lang.String pubDirFileName(java.lang.String fullPath)
          Returns the path to the .pub file but without the .pub extension.
 void setParseUnit(ParseUnit pu)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LAYOUT_VERSION

public static final int LAYOUT_VERSION
This is like a "schema version" for .pub files.

See Also:
Constant Field Values

PUBFILE_TIMESTAMP

public static final int PUBFILE_TIMESTAMP
loadTo(PUBFILE_TIMESTAMP) - just check if the binary exists and check that it is newer than the compile unit file. Does not read anything from the binary.

See Also:
Constant Field Values

FILES

public static final int FILES
loadTo(FILES) - the index of include files referenced by this parse unit.

See Also:
Constant Field Values

HEADER

public static final int HEADER
loadTo(HEADER) Gets all the segments necessary for checking if the binary is up to date or not. Also for classes, gets class name and the name of the inherited class if any.

See Also:
Constant Field Values

SCHEMA

public static final int SCHEMA
loadTo(SCHEMA) - the schema tables and fields referenced by this parse unit.

See Also:
Constant Field Values

IMPORTS

public static final int IMPORTS
loadTo(IMPORTS)

See Also:
SymbolI.isImported(), Constant Field Values

EXPORTS

public static final int EXPORTS
loadTo(EXPORTS)

See Also:
SymbolI.isExported(), Constant Field Values

AST

public static final int AST
loadTo(AST) - just loads the node types - you almost certainly need STRINGS as well.

See Also:
Constant Field Values

STRINGS

public static final int STRINGS
loadTo(STRINGS) - load the strings into the syntax tree.

See Also:
Constant Field Values

END

public static final int END
loadTo(END) - all binary file segments will be loaded.

See Also:
Constant Field Values
Constructor Detail

PUB

public PUB(java.lang.String fullPath)
Create a PUB for a compile unit fully qualified path/name. RefactorSession must be configured for the project (schema loaded, project name set, etc) before working with PUB files.

Parameters:
fullPath - The full path to the compile unit's source file.
Method Detail

build

public ParseUnit build()
                throws java.io.IOException,
                       RefactorException
Update the PUB. You would normally call load() first, to check whether a fresh build is really necessary. Once a build() has been done, then all of the values for the PUB are available - it is not necessary for you to call load() or loadTo(). This takes care of creating the ParseUnit (if not already set) and running treeParser01.

Throws:
RefactorException
java.io.IOException

build

public void build(TP01Support support)
           throws java.io.IOException,
                  RefactorException
This is called by TreeParser01, and should not be called directly.

Throws:
java.io.IOException
RefactorException

copySchemaTableLowercaseNamesInto

public void copySchemaTableLowercaseNamesInto(java.util.Collection c)
Copies the lower case names of all schema tables into your collection. The names are of the format "database.table". You might use a sorted set or a hash set, depending on what you need it for. To get the mixed-case names, use the "org.prorefactor.core.schema" package to look up the table objects.

Parameters:
c -

copySchemaFieldLowercaseNamesInto

public void copySchemaFieldLowercaseNamesInto(java.util.Collection c,
                                              java.lang.String fromTableName)
Copies the lower case names of all schema fields for one table into your collection. The names are of the format "field" - i.e. no db or table name prefix. You might use a sorted set or a hash set, depending on what you need it for. To get the mixed-case names, use the "org.prorefactor.core.schema" package to look up the field objects.

Parameters:
fromTableName - Your table name. Case insenstitive. Must be of the format "database.table".

getClassName

public java.lang.String getClassName()

getExportTable

public PUB.SymbolRef[] getExportTable()
Get the array of exported symbols, in no particular order. Currently just for DEF NEW [GLOBAL] SHARED symbols.


getImportTable

public PUB.SymbolRef[] getImportTable()
Get the array of imported symbols, in no particular order. Currently just for DEF SHARED symbols.


getParseUnit

public ParseUnit getParseUnit()

getSuperClassName

public java.lang.String getSuperClassName()

getTimestamp

public long getTimestamp()
Get the time stamp (File.lastModified()) of the PUB file. Returns zero if the PUB file does not exist.


getTree

public ProgramRootNode getTree()
Return the JPNode syntax tree that was loaded with load()


isChecked

public boolean isChecked()
Has the PUB been checked to see if it's current? i.e. Has it been loaded at least to HEADER?


isCurrent

public boolean isCurrent()
Is the PUB current? You should have used isChecked() or loaded the PUB to HEADER before checking isCurrent().

See Also:
isChecked()

load

public boolean load()
Same as loadTo(PUB.END)


loadTo

public boolean loadTo(int lastSegmentToLoad)
Load the PUB file to the end of the specified segment. For example, if you only need to read as far as the "imports" segment, then use loadTo(PUB.IMPORTS).

Returns:
false if the file is out of date and you need to call build() instead.

pubDirFileName

public static java.lang.String pubDirFileName(java.lang.String fullPath)
Returns the path to the .pub file but without the .pub extension. Useful for adding additional files like listing files into the pubs directory tree. The project for the RefactorSession must already be assigned.


setParseUnit

public void setParseUnit(ParseUnit pu)


Copyright © 2008 Joanju Software. All Rights Reserved.