|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jaxme.js.JavaSourceFactory
Factory for generating JavaSource objects.
Constructor Summary | |
JavaSourceFactory()
|
Method Summary | |
JavaSource |
getJavaSource(JavaQName pName)
Returns the generated class with the given name or null, if no such class has been generated. |
java.util.Iterator |
getJavaSources()
Returns an iterator to the generated classes. |
java.io.File |
getLocation(java.io.File pBaseDir,
JavaSource pJs)
Returns a location for storing the JavaSource class, relative to the given base directory. |
java.io.File |
getLocation(java.io.File pBaseDir,
java.lang.String pPackage)
Returns a location the given package, relative to the given base directory. |
Logger |
getLogger()
Returns the Logger . |
java.io.File |
getPackageDirectory(java.io.File pBaseDir,
java.lang.String pPackageName)
Given a package name and a base directory, returns the package directory. |
java.io.File |
getSourceFile(java.io.File pBaseDir,
JavaQName pQName)
Given a fully qualified name, returns the name of the corresponding Java file. |
TextFile |
getTextFile(java.lang.String pPackageName,
java.lang.String pFileName)
Returns the text file with the given name or null, if no such text file has been generated. |
java.util.Iterator |
getTextFiles()
Returns an iterator to the generated text files. |
boolean |
isOverwriteForced()
By default the JavaSourceFactory will only overwrite existing files, if they have different content. |
protected boolean |
isSameFile(JavaSource pJs,
java.io.File pFile)
Verifies whether the given Java source and the contents of the given file are identical. |
protected boolean |
isSameFile(java.lang.String pContents,
java.io.File pFile)
Verifies whether the given string and the contents of the given file are identical. |
protected boolean |
isSameFile(java.lang.String pContents1,
java.lang.String pContents2)
Verifies whether the given strings are identical. |
JavaSource |
newJavaSource(JavaQName pName)
Creates a new instance of JavaSource with the given name and default protection. |
JavaSource |
newJavaSource(JavaQName pName,
JavaSource.Protection pProtection)
Creates a new instance of JavaSource with the given name and protection. |
JavaSource |
newJavaSource(JavaQName pName,
java.lang.String pProtection)
Creates a new instance of JavaSource with the given name and protection. |
TextFile |
newTextFile(java.lang.String pPackageName,
java.lang.String pFileName)
Creates a new text file. |
void |
setLogger(Logger pLogger)
Sets the Logger to use. |
void |
setOverwriteForced(boolean pOverwriteForced)
By default the JavaSourceFactory will only overwrite existing files, if they have different content. |
void |
write(java.io.File pBaseDir)
Writes all JavaSource classes to the FileSystem, relative to the given base directory. |
void |
write(java.io.File pBaseDir,
JavaSource pJs)
Writes the given JavaSource class to the file system, relative to the given base directory. |
void |
write(java.io.File pBaseDir,
TextFile pFile)
Writes the given text file to the file system, relative to the given base directory. |
protected void |
writeFile(java.io.File pFile,
JavaSource pJs)
Actually creates a file with the given name. |
protected void |
writeFile(java.io.File pFile,
java.lang.String pContents)
Actually creates a file with the given name. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public JavaSourceFactory()
Method Detail |
public void setLogger(Logger pLogger)
Sets the Logger
to use.
public Logger getLogger()
Returns the Logger
.
public void setOverwriteForced(boolean pOverwriteForced)
By default the JavaSourceFactory will only overwrite existing files, if they have different content. If the overwriteForced property is set to true, existing files will always be overwritten.
isOverwriteForced()
public boolean isOverwriteForced()
By default the JavaSourceFactory will only overwrite existing files, if they have different content. If the overwriteForced property is set to true, existing files will always be overwritten.
setOverwriteForced(boolean)
public JavaSource newJavaSource(JavaQName pName)
Creates a new instance of JavaSource with the given name and default protection.
public JavaSource newJavaSource(JavaQName pName, JavaSource.Protection pProtection)
Creates a new instance of JavaSource with the given name and protection.
public JavaSource newJavaSource(JavaQName pName, java.lang.String pProtection)
Creates a new instance of JavaSource with the given
name and protection. Shortcut for
newJavaSource(pName, JavaSource.Protection.valueOf(pProtection))
.
public java.util.Iterator getJavaSources()
Returns an iterator to the generated classes.
public java.util.Iterator getTextFiles()
Returns an iterator to the generated text files.
public JavaSource getJavaSource(JavaQName pName)
Returns the generated class with the given name or null, if no such class has been generated.
public TextFile getTextFile(java.lang.String pPackageName, java.lang.String pFileName)
Returns the text file with the given name or null, if no such text file has been generated.
public java.io.File getPackageDirectory(java.io.File pBaseDir, java.lang.String pPackageName)
Given a package name and a base directory, returns the package directory.
pBaseDir
- The base directory, where to create sources;
may be null (current directory).
public java.io.File getSourceFile(java.io.File pBaseDir, JavaQName pQName)
Given a fully qualified name, returns the name of the corresponding Java file.
public java.io.File getLocation(java.io.File pBaseDir, java.lang.String pPackage)
Returns a location the given package, relative to the given
base directory. For example, if you have the base
directory c:\temp
and the package
com.mycompany.demo
, this would yield
new File("c:\temp\com\mycompany\demo").
pBaseDir
- The base directory or null for the current directory.pPackage
- The JavaSource being stored; null or the empty
string for the root package
public java.io.File getLocation(java.io.File pBaseDir, JavaSource pJs)
Returns a location for storing the JavaSource class, relative
to the given base directory. For example, if you have the base
directory c:\temp
and the class Sample
in package com.mycompany.demo
, this would yield
new File("c:\temp\com\mycompany\demo\Sample.java").
pBaseDir
- The base directory or null for the current directory.pJs
- The JavaSource being stored.protected boolean isSameFile(JavaSource pJs, java.io.File pFile) throws java.io.IOException
Verifies whether the given Java source and the contents of the given file are identical.
java.io.IOException
protected boolean isSameFile(java.lang.String pContents, java.io.File pFile) throws java.io.IOException
Verifies whether the given string and the contents of the given file are identical.
java.io.IOException
protected boolean isSameFile(java.lang.String pContents1, java.lang.String pContents2)
Verifies whether the given strings are identical.
protected void writeFile(java.io.File pFile, JavaSource pJs) throws java.io.IOException
Actually creates a file with the given name.
java.io.IOException
protected void writeFile(java.io.File pFile, java.lang.String pContents) throws java.io.IOException
Actually creates a file with the given name.
java.io.IOException
public void write(java.io.File pBaseDir, JavaSource pJs) throws java.io.IOException
Writes the given JavaSource class to the file system, relative to the given base directory.
pBaseDir
- The base directory or null for the current directory.pJs
- The JavaSource being stored.
java.io.IOException
JavaSource.write(Writer)
public void write(java.io.File pBaseDir, TextFile pFile) throws java.io.IOException
Writes the given text file to the file system, relative to the given base directory.
pBaseDir
- The base directory or null for the current directory.pFile
- The text file being stored.
java.io.IOException
JavaSource.write(Writer)
public void write(java.io.File pBaseDir) throws java.io.IOException
Writes all JavaSource classes to the FileSystem, relative to the given base directory.
pBaseDir
- The base directory or null for the current directory.
java.io.IOException
public TextFile newTextFile(java.lang.String pPackageName, java.lang.String pFileName)
Creates a new text file.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |