com.sun.jdo.api.persistence.enhancer.util
Class ClassFileSource

java.lang.Object
  extended by com.sun.jdo.api.persistence.enhancer.util.Assertion
      extended by com.sun.jdo.api.persistence.enhancer.util.Support
          extended by com.sun.jdo.api.persistence.enhancer.util.ClassFileSource

public class ClassFileSource
extends Support

ClassFileSource provides a mechanism for associating a class with the source of that class. The source is currently either an ordinary .class file or a zip file 1 or more class files.


Field Summary
 
Fields inherited from class com.sun.jdo.api.persistence.enhancer.util.Support
timer
 
Constructor Summary
ClassFileSource(String className, File classFile)
          Constructor
ClassFileSource(String className, InputStream byteCodeStream)
          Constructor
ClassFileSource(String className, ZipFile zipFile)
          Constructor
 
Method Summary
 DataInputStream classFileContents()
          Get a DataInputStream containing the class file.
 File computeDestination(File destDir)
          Compute the destination file for the class.
 String containingFilePath()
          Get the path of the File containing the class
 String expectedClassName()
          The expected name of the class contained in the class file.
 ClassFileSource friendSource(String className)
          Build a "friend" source file specification for the class of the given name.
 DataOutputStream getOutputStream(File dest)
          Get a DataOutputStream to which a class file should be written.
 boolean isStreamed()
          Does this class originate in a zip file?
 boolean isZipped()
          Does this class originate in a zip file?
 long modificationDate()
          Get the modification date of the class file.
 ClassFileSource nextSource(String className)
          Attempt to find the next possible source of the class
 boolean sameAs(ClassFileSource other)
          Does the other class file source refer to the same source location?
 void setExpectedClassName(String name)
          Set the name of the class contained in the class file.
 void setModificationDate(long date)
          Set the cached modification date of the class file.
 
Methods inherited from class com.sun.jdo.api.persistence.enhancer.util.Support
getI18N, getI18N, getI18N, getI18N, getI18N, getI18N
 
Methods inherited from class com.sun.jdo.api.persistence.enhancer.util.Assertion
affirm, affirm, affirm, affirm
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassFileSource

public ClassFileSource(String className,
                       File classFile)
Constructor

Parameters:
className - The expected name of the class
classFile - The file containing the class. This file should exist and be readable.

ClassFileSource

public ClassFileSource(String className,
                       ZipFile zipFile)
Constructor

Parameters:
className - The expected name of the class
zipFile - The zip file containing the class. This file should exist and be readable.

ClassFileSource

public ClassFileSource(String className,
                       InputStream byteCodeStream)
Constructor

Parameters:
className - The expected name of the class
byteCodeStream - containing the class file.
Method Detail

sameAs

public boolean sameAs(ClassFileSource other)
Does the other class file source refer to the same source location?


isZipped

public boolean isZipped()
Does this class originate in a zip file?


isStreamed

public boolean isStreamed()
Does this class originate in a zip file?


expectedClassName

public String expectedClassName()
The expected name of the class contained in the class file. Returns null if the class name can not be intuited from the file name.


setExpectedClassName

public void setExpectedClassName(String name)
Set the name of the class contained in the class file.


containingFilePath

public String containingFilePath()
Get the path of the File containing the class


nextSource

public ClassFileSource nextSource(String className)
Attempt to find the next possible source of the class


friendSource

public ClassFileSource friendSource(String className)
Build a "friend" source file specification for the class of the given name. That is, the new class file source should be in the same zip file if zipped or else the same directory. Restriction: containingFilePath() must be non-null.


classFileContents

public DataInputStream classFileContents()
                                  throws IOException,
                                         FileNotFoundException
Get a DataInputStream containing the class file. Restriction: containingFilePath() must be non-null.

Throws:
IOException
FileNotFoundException

modificationDate

public long modificationDate()
                      throws FileNotFoundException
Get the modification date of the class file. The date format is that used by java.util.Date. Restriction: containingFilePath() must be non-null.

Throws:
FileNotFoundException

setModificationDate

public void setModificationDate(long date)
Set the cached modification date of the class file. This doesn't actually update the file.


computeDestination

public File computeDestination(File destDir)
                        throws IOException,
                               FileNotFoundException
Compute the destination file for the class. If destDir is non-null, use that as a destination location Restriction: if containingFilePath() is null, null is returned.

Throws:
IOException
FileNotFoundException

getOutputStream

public DataOutputStream getOutputStream(File dest)
                                 throws IOException,
                                        FileNotFoundException
Get a DataOutputStream to which a class file should be written. The caller must close the output stream when complete.

Throws:
IOException
FileNotFoundException


Copyright © 2012. All Rights Reserved.