org.jtool.jxplatform.repository
Class JxCompilationUnit

java.lang.Object
  extended byorg.jtool.jxplatform.repository.JxCompilationUnit

public class JxCompilationUnit
extends java.lang.Object

Stores information of a compilation unit (Java source file).

Author:
Katsuhisa Maruyama

Constructor Summary
protected JxCompilationUnit(org.eclipse.jdt.core.ICompilationUnit cu, java.lang.String filename)
          Creates an object that will store information about a given compilation unit;
 
Method Summary
protected  void bind(Binder binder)
          Adds the binding information of this compilation unit to its XML document.
 void clear()
          Discard the DOM document object.
protected  void convert(Converter converter)
          Converts this compilation unit to an XML document.
protected  void delete()
          Discards information about the compilation unit and its DOM document object.
 java.lang.String getCharsetName()
          Returns a charset name of the original source file.
 org.eclipse.jdt.core.ICompilationUnit getCompilationUnit()
          Returns a native dirtyUcompilation unit stored in this object.
 org.w3c.dom.Element getCorrespondingElement(java.lang.String fqn)
          Returns a DOM element object corresponfing to the fully-qualified name of a class.
 org.w3c.dom.Document getDocument()
          Returns a DOM document object generated from the source code.
 java.lang.String getFilename()
          Returns the relative path name of the original source file.
 org.eclipse.core.resources.IFile getIFile()
          Returns a file resource for the stored compilation unit.
 java.lang.String getOriginalCode()
          Obtains the text of the original source code.
 java.lang.String getRecoveredCode()
          Obtains the text of source code recovered from an XML document.
 java.lang.String getText()
          Obtains the text of an XML document corresponding to a DOM document object.
 java.lang.String getText(java.lang.String dtdName)
          Obtains the text of an XML document corresponding to a DOM document object.
 boolean isDirty()
          Tests if the DOM document object is dirty.
protected  org.w3c.dom.Document parse(Converter converter)
          Parses input source code and generates its DOM document object.
protected  boolean restore()
          Restores informtaion about this compilation unit.
 void setLineNumber()
          Assigns line numbers to DOM elements.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JxCompilationUnit

protected JxCompilationUnit(org.eclipse.jdt.core.ICompilationUnit cu,
                            java.lang.String filename)
Creates an object that will store information about a given compilation unit;

Parameters:
cu - A compilation unit.
filename - A filename of a compilation unit.
Method Detail

delete

protected void delete()
Discards information about the compilation unit and its DOM document object.


clear

public void clear()
Discard the DOM document object.


restore

protected boolean restore()
Restores informtaion about this compilation unit.

Returns:
true if the original of this compilation unit exists, otherwise false.

parse

protected org.w3c.dom.Document parse(Converter converter)
                              throws JxException
Parses input source code and generates its DOM document object.

Parameters:
converter - A conveter.
Returns:
The generated DOM document object.
Throws:
JxException - if a fatal error occurs during the parsing.

convert

protected void convert(Converter converter)
                throws JxException
Converts this compilation unit to an XML document.

Parameters:
converter - A conveter.
Returns:
true if the conversion succeeds, otherwise false.
Throws:
JxException - if a fatal error occurs during the convertion.

bind

protected void bind(Binder binder)
             throws JxException
Adds the binding information of this compilation unit to its XML document.

Parameters:
binder - A binder.
Returns:
true if the conversion succeeds, otherwise false.
Throws:
JxException - if a fatal error occurs during the binding.

getCompilationUnit

public org.eclipse.jdt.core.ICompilationUnit getCompilationUnit()
Returns a native dirtyUcompilation unit stored in this object.

Returns:
An Eclipse jdt's ICompilationUnit.

getIFile

public org.eclipse.core.resources.IFile getIFile()
Returns a file resource for the stored compilation unit.

Returns:
The Eclipse's IFile resource.

getDocument

public org.w3c.dom.Document getDocument()
Returns a DOM document object generated from the source code.

Returns:
The DOM document object.

getFilename

public java.lang.String getFilename()
Returns the relative path name of the original source file.

Returns:
A relative path name string.

getCharsetName

public java.lang.String getCharsetName()
Returns a charset name of the original source file.

Returns:
The name of a file's charset.

isDirty

public boolean isDirty()
Tests if the DOM document object is dirty.

Returns:
true if the document is dirty, otherwise false.

getRecoveredCode

public java.lang.String getRecoveredCode()
Obtains the text of source code recovered from an XML document.

Returns:
The text of the source code.

getOriginalCode

public java.lang.String getOriginalCode()
Obtains the text of the original source code.

Returns:
The text of the source code.

getText

public java.lang.String getText()
Obtains the text of an XML document corresponding to a DOM document object.

Returns:
The text of an XML document.

getText

public java.lang.String getText(java.lang.String dtdName)
Obtains the text of an XML document corresponding to a DOM document object.

Parameters:
dtdName - The name of a used DTD.
Returns:
The text of an XML document.

setLineNumber

public void setLineNumber()
Assigns line numbers to DOM elements.


getCorrespondingElement

public org.w3c.dom.Element getCorrespondingElement(java.lang.String fqn)
Returns a DOM element object corresponfing to the fully-qualified name of a class.

Parameters:
fqn - The fully-qualified name of a class.
Returns:
The corresponding DOM element.