com.sun.tools.javah
Class Gen

java.lang.Object
  extended by com.sun.tools.javah.Gen
Direct Known Subclasses:
JNI, LLNI

public abstract class Gen
extends java.lang.Object

An abstraction for generating support files required by native methods. Subclasses are for specific native interfaces. At the time of its original writing, this interface is rich enough to support JNI and the old 1.0-style native method interface.


Field Summary
protected  ClassDoc[] classes
           
protected  boolean force
           
private static boolean isWindows
           
protected  java.lang.String lineSep
           
protected  java.lang.String outDir
           
protected  java.lang.String outFile
           
(package private)  RootDoc root
           
 
Constructor Summary
Gen(RootDoc root)
           
 
Method Summary
protected  java.lang.String baseFileName(java.lang.String clazz)
           
protected  java.lang.String cppGuardBegin()
           
protected  java.lang.String cppGuardEnd()
           
protected  java.lang.String defineForStatic(ClassDoc c, FieldDoc f)
           
(package private)  FieldDoc[] getAllFields(ClassDoc subclazz)
          Including super classes' fields.
protected  java.lang.String getFileName(java.lang.String clazz)
           
protected  java.lang.String getFileSuffix()
           
protected abstract  java.lang.String getIncludes()
          Override this method to provide a list of #include statements required by the native interface.
protected  java.lang.String guardBegin(java.lang.String cname)
           
protected  java.lang.String guardEnd(java.lang.String cname)
           
 void run()
          After initializing state of an instance, use this method to start processing.
 void setClasses(ClassDoc[] classes)
           
 void setForce(boolean state)
           
 void setOutDir(java.lang.String outDir)
           
 void setOutFile(java.lang.String outFile)
           
protected  java.io.PrintWriter wrapWriter(java.io.OutputStream o)
          We explicitly need to write ASCII files because that is what C compilers understand.
protected abstract  void write(java.io.OutputStream o, ClassDoc clazz)
          Override this abstract method, generating content for the named class into the outputstream.
protected  void writeFileTop(java.io.OutputStream o)
           
private  void writeIfChanged(byte[] b, java.lang.String file)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lineSep

protected java.lang.String lineSep

root

RootDoc root

classes

protected ClassDoc[] classes

isWindows

private static final boolean isWindows

outDir

protected java.lang.String outDir

outFile

protected java.lang.String outFile

force

protected boolean force
Constructor Detail

Gen

public Gen(RootDoc root)
Method Detail

write

protected abstract void write(java.io.OutputStream o,
                              ClassDoc clazz)
                       throws java.lang.ClassNotFoundException
Override this abstract method, generating content for the named class into the outputstream.

Throws:
java.lang.ClassNotFoundException

getIncludes

protected abstract java.lang.String getIncludes()
Override this method to provide a list of #include statements required by the native interface.


setOutDir

public void setOutDir(java.lang.String outDir)

setOutFile

public void setOutFile(java.lang.String outFile)

setClasses

public void setClasses(ClassDoc[] classes)

setForce

public void setForce(boolean state)

wrapWriter

protected java.io.PrintWriter wrapWriter(java.io.OutputStream o)
We explicitly need to write ASCII files because that is what C compilers understand.


run

public void run()
         throws java.io.IOException,
                java.lang.ClassNotFoundException
After initializing state of an instance, use this method to start processing. Buffer size chosen as an approximation from a single sampling of: expr `du -sk` / `ls *.h | wc -l`

Throws:
java.io.IOException
java.lang.ClassNotFoundException

writeIfChanged

private void writeIfChanged(byte[] b,
                            java.lang.String file)
                     throws java.io.IOException
Throws:
java.io.IOException

defineForStatic

protected java.lang.String defineForStatic(ClassDoc c,
                                           FieldDoc f)

cppGuardBegin

protected java.lang.String cppGuardBegin()

cppGuardEnd

protected java.lang.String cppGuardEnd()

guardBegin

protected java.lang.String guardBegin(java.lang.String cname)

guardEnd

protected java.lang.String guardEnd(java.lang.String cname)

writeFileTop

protected void writeFileTop(java.io.OutputStream o)

baseFileName

protected java.lang.String baseFileName(java.lang.String clazz)

getFileName

protected java.lang.String getFileName(java.lang.String clazz)

getFileSuffix

protected java.lang.String getFileSuffix()

getAllFields

FieldDoc[] getAllFields(ClassDoc subclazz)
                  throws java.lang.ClassNotFoundException
Including super classes' fields.

Throws:
java.lang.ClassNotFoundException