|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.ws.jaxme.js.IndentationEngineImpl org.apache.ws.jaxme.js.JavaSource
public class JavaSource
A class representing a Java source file.
Nested Class Summary | |
---|---|
static class |
JavaSource.Protection
Specifies a java objects protection (default, public, protected, or private). |
static class |
JavaSource.Type
Specifies the type of a java class (interface, or class). |
Field Summary | |
---|---|
static JavaSource.Type |
CLASS
Type of a JavaSource class. |
static JavaSource.Protection |
DEFAULT_PROTECTION
Default protection of a class, field or method |
static JavaSource.Type |
INTERFACE
Type of a JavaSource interface. |
static JavaSource.Protection |
PRIVATE
Protection of a class, field or method: private |
static JavaSource.Protection |
PROTECTED
Protection of a class, field or method: protected |
static JavaSource.Protection |
PUBLIC
Protection of a class, field or method: public |
Fields inherited from interface org.apache.ws.jaxme.js.IndentationEngine |
---|
NOTHING |
Method Summary | |
---|---|
void |
addExtends(java.lang.Class pExtends)
Sets the class or interface extended by this class or interface. |
void |
addExtends(JavaQName pExtends)
Sets the class or interface extended by this class or interface. |
void |
addImplements(java.lang.Class s)
Adds an interface to the list of interfaces being implemented by this class or interface. |
void |
addImplements(JavaQName s)
Adds an interface to the list of interfaces being implemented by this class or interface. |
void |
addImport(java.lang.Class s)
Adds a package or class to the list of packages and classes being imported. |
void |
addImport(JavaQName s)
Adds a package or class to the list of packages and classes being imported. |
void |
addInnerClass(JavaInnerClass pClass)
Adds an inner class. |
void |
addRawJavaSource(java.lang.String pSource)
Adds a piece of raw Java source to the class. |
java.lang.String |
asString(JavaQName pQName,
boolean pAddIfPossible)
Returns whether the given JavaQName is a local class. |
void |
clearExtends()
Clears the list of extended classes or interfaces. |
void |
clearImplements()
Clears the list of implemented interfaces. |
void |
clearImports()
Clears the list of imports. |
void |
clearInnerClasses()
Clears the list of inner classes. |
void |
clearRawJavaSources()
Clears the list of raw Java sources. |
JavaClassInitializer[] |
getClassInitializers()
Returns the static class initializers. |
java.lang.String |
getClassName()
Returns the class or interface name. |
JavaComment |
getComment()
Returns the comment describing this class or interface. |
JavaConstructor |
getConstructor(JavaQName[] pParams)
Returns the constructor with the given signature or null, if there is no such constructor. |
java.util.Iterator |
getConstructorIterator()
Returns an iterator the the classes constructors. |
JavaConstructor[] |
getConstructors()
Returns the list of constructors that this class has. |
JavaQName[] |
getExtends()
Returns the class or interface extended by this class or interface. |
JavaSourceFactory |
getFactory()
Returns the JavaSourceFactory that created this instance of
JavaSource. |
JavaField |
getField(java.lang.String pName)
Returns the field with the given name or null, if no such field exists. |
JavaField[] |
getFields()
Returns the list of fields that this class has. |
JavaQName[] |
getImplements()
Returns the list of interfaces being implented by this class or interface. |
JavaQName[] |
getImports()
Returns the list of packages and classes being imported. |
JavaInnerClass |
getInnerClass(java.lang.String pName)
Returns the inner class named pName , or
null, if no such class exists. |
JavaInnerClass[] |
getInnerClasses()
Returns the array of inner classes. |
JavaMethod |
getMethod(java.lang.String pMethodName,
JavaQName[] pParams)
Returns the method with the given signature or null, if there is no such method. |
java.util.Iterator |
getMethodIterator()
Returns an iterator to the classes methods. |
JavaMethod[] |
getMethods()
Returns the list of methods that this class has. |
java.lang.String |
getPackageName()
Returns the package name. |
JavaSource.Protection |
getProtection()
Returns the protection. |
JavaQName |
getQName()
Returns the JavaSource's JavaQName. |
static java.lang.String |
getQuoted(java.lang.String s)
Returns a quoted string constant suitable for embedding into Java source. |
static java.lang.String |
getQuotedNoQuotes(java.lang.String s)
Returns a quoted string constant suitable for embedding into Java source, but without quotes. |
java.lang.String[] |
getRawJavaSources()
Returns an array with the pieces of raw Java sources. |
protected boolean |
getStatic()
Returns whether this JavaSource is static (for inner classes). |
JavaSource.Type |
getType()
Returns the JavaSource type. |
boolean |
hasDynamicImports()
Returns, whether the class is automatically adding imports. |
boolean |
isAbstract()
Returns whether class is abstract. |
boolean |
isExtending(java.lang.Class pClass)
Returns whether the class is extending the given super class or interface. |
boolean |
isExtending(JavaQName pClass)
Returns whether the class is extending the given super class or interface. |
boolean |
isForcingFullyQualifiedName()
Returns, whether class references are always using the fully qualified class name. |
boolean |
isImplementing(java.lang.Class pClass)
Returns whether the class is implementing the given interface. |
boolean |
isImplementing(JavaQName pClass)
Returns whether the class is implementing the given interface. |
boolean |
isInnerClass()
Returns, whether this is an inner class. |
boolean |
isInterface()
Returns whether this is an interface or not. |
void |
newBeanProperty(java.lang.Class pClass,
java.lang.String pName)
Shortcut for newBeanProperty(JavaQNameImpl.getInstance(pClass), pName) . |
void |
newBeanProperty(java.lang.Class pClass,
java.lang.String pFieldName,
java.lang.String pGetMethodName,
java.lang.String pSetMethodName)
Shortcut for newBeanProperty(JavaQNameImpl.getInstance(pClass),
pFieldName, pGetMethodName, pSetMethodName) . |
void |
newBeanProperty(JavaQName pType,
java.lang.String pName)
Creates a new Java property with the given type and name. |
void |
newBeanProperty(JavaQName pType,
java.lang.String pFieldName,
java.lang.String pGetMethodName,
java.lang.String pSetMethodName)
Shortcut for |
JavaComment |
newComment()
Creates a new Javadoc comment describing this class or interface. |
JavaClassInitializer |
newJavaClassInitializer()
Creates a new instance of JavaClassInitializer. |
JavaConstructor |
newJavaConstructor()
Creates a new JavaConstructor with default protection. |
JavaConstructor |
newJavaConstructor(java.lang.reflect.Constructor pConstructor)
Creates a new JavaConstructor with the signature of the given constructor. |
JavaConstructor |
newJavaConstructor(JavaConstructor pConstructor)
Creates a new JavaConstructor with the same parameters, protection and exceptions than the given. |
JavaConstructor |
newJavaConstructor(JavaConstructor pConstructor,
boolean pSuper)
Creates a new JavaConstructor with the same signature than the given constructors. |
JavaConstructor |
newJavaConstructor(JavaSource.Protection pProtection)
Creates a new JavaConstructor with the given protection. |
JavaConstructor |
newJavaConstructor(java.lang.String pProtection)
Creates a new JavaConstructor with the given protection. |
JavaField |
newJavaField(java.lang.reflect.Field pField)
Creates a new JavaField with the given fields signature. |
JavaField |
newJavaField(java.lang.String pName,
java.lang.Class pType)
Creates a new JavaField with the given name, type and default protection. |
JavaField |
newJavaField(java.lang.String pName,
java.lang.Class pType,
JavaSource.Protection pProtection)
Creates a new JavaField with the given name, type and protection. |
JavaField |
newJavaField(java.lang.String pName,
java.lang.Class pType,
java.lang.String pProtection)
Creates a new JavaField with the given name, type and protection. |
JavaField |
newJavaField(java.lang.String pName,
JavaQName pType)
Creates a new JavaField with the given name, type and default protection. |
JavaField |
newJavaField(java.lang.String pName,
JavaQName pType,
JavaSource.Protection pProtection)
Creates a new JavaField with the given name, type and protection. |
JavaField |
newJavaField(java.lang.String pName,
JavaQName pType,
java.lang.String pProtection)
Creates a new JavaField with the given name, type and protection. |
JavaField |
newJavaField(java.lang.String pName,
java.lang.String pType)
Creates a new JavaField with the given name, type and default protection. |
JavaField |
newJavaField(java.lang.String pName,
java.lang.String pType,
JavaSource.Protection pProtection)
Creates a new JavaField with the given name, type and protection. |
JavaField |
newJavaField(java.lang.String pName,
java.lang.String pType,
java.lang.String pProtection)
Creates a new JavaField with the given name, type and protection. |
JavaInnerClass |
newJavaInnerClass(java.lang.String pName)
Creates a new JavaInnerClass with the given name and default protection. |
JavaInnerClass |
newJavaInnerClass(java.lang.String pName,
JavaSource.Protection pProtection)
Creates a new JavaInnerClass with the given name and protection. |
JavaInnerClass |
newJavaInnerClass(java.lang.String pName,
java.lang.String pProtection)
Creates a new JavaInnerClass with the given name and protection. |
JavaMethod |
newJavaMethod(JavaMethod pMethod)
Creates a new JavaMethod with the given methods name and signature. |
JavaMethod |
newJavaMethod(java.lang.reflect.Method pMethod)
Creates a new JavaMethod with the signature of the given method pMethod . |
JavaMethod |
newJavaMethod(java.lang.String pName,
java.lang.Class pType)
Creates a new JavaMethod with the given name, return type and default protection. |
JavaMethod |
newJavaMethod(java.lang.String pName,
java.lang.Class pType,
JavaSource.Protection pProtection)
Creates a new JavaMethod with the given name, return type and protection. |
JavaMethod |
newJavaMethod(java.lang.String pName,
java.lang.Class pType,
java.lang.String pProtection)
Creates a new JavaMethod with the given name, return type and protection. |
JavaMethod |
newJavaMethod(java.lang.String pName,
JavaQName pType)
Creates a new JavaMethod with the given name, return type and default protection. |
JavaMethod |
newJavaMethod(java.lang.String pName,
JavaQName pType,
JavaSource.Protection pProtection)
Creates a new JavaMethod with the given name, return type and protection. |
JavaMethod |
newJavaMethod(java.lang.String pName,
JavaQName pType,
java.lang.String pProtection)
Creates a new JavaMethod with the given name, return type and protection. |
JavaMethod |
newJavaMethod(java.lang.String pName,
java.lang.String pType)
Creates a new JavaMethod with the given name, return type and default protection. |
JavaMethod |
newJavaMethod(java.lang.String pName,
java.lang.String pType,
JavaSource.Protection pProtection)
Creates a new JavaMethod with the given name, return type and protection. |
JavaMethod |
newJavaMethod(java.lang.String pName,
java.lang.String pType,
java.lang.String pProtection)
Creates a new JavaMethod with the given name, return type and protection. |
void |
setAbstract(boolean isAbstract)
Sets whether this class is abstract. |
void |
setDynamicImports(boolean pDynamicImports)
Sets, whether the class is automatically adding imports. |
void |
setForcingFullyQualifiedName(boolean pForcingFullyQualifiedName)
Sets, whether class references are always using the fully qualified class name. |
void |
setProtection(JavaSource.Protection protection)
Sets the protection; use null for default protection. |
void |
setQName(JavaQName pQName)
Sets the JavaSource's JavaQName. |
void |
setStatic(boolean pStatic)
Sets whether this JavaSource is static (for inner classes). |
void |
setType(JavaSource.Type pType)
Sets the JavaSource type. |
java.lang.String |
toString()
Returns a string representation of this JavaSource file. |
void |
write(IndentationTarget pTarget)
Adds the IndentationEngine's contents to the given IndentationTarget . |
void |
write(java.io.Writer pTarget)
Writes the JavaSource contents into the given Writer. |
Methods inherited from class org.apache.ws.jaxme.js.IndentationEngineImpl |
---|
addLine, addLine, addLine, addLine, addLine, addLine, addLine, addLine, addLine, addLine, addLine, addLine, addLine, addLine, addLine, addLine, addLine, addLine, asString, checkNulls, clear, getLevel, getLines, getLines, getPlaceHolder, indent, isEmpty, moveToBottom, moveToTop, newPlaceHolder, removePlaceHolder, setLevel, unindent, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final JavaSource.Type CLASS
INTERFACE
,
getType()
,
setType(org.apache.ws.jaxme.js.JavaSource.Type)
public static final JavaSource.Type INTERFACE
CLASS
,
getType()
,
setType(org.apache.ws.jaxme.js.JavaSource.Type)
public static final JavaSource.Protection PUBLIC
public static final JavaSource.Protection PROTECTED
public static final JavaSource.Protection PRIVATE
public static final JavaSource.Protection DEFAULT_PROTECTION
Method Detail |
---|
public JavaClassInitializer[] getClassInitializers()
public JavaSourceFactory getFactory()
JavaSourceFactory
that created this instance of
JavaSource.
public JavaQName getQName()
public void setQName(JavaQName pQName)
public java.lang.String getClassName()
setQName(org.apache.ws.jaxme.js.JavaQName)
public java.lang.String getPackageName()
public JavaSource.Protection getProtection()
setProtection(org.apache.ws.jaxme.js.JavaSource.Protection)
public void setProtection(JavaSource.Protection protection)
getProtection()
public JavaSource.Type getType()
setType(org.apache.ws.jaxme.js.JavaSource.Type)
public void setType(JavaSource.Type pType)
pType
- "class" or "interface"getType()
public JavaComment getComment()
newComment()
public JavaComment newComment()
getComment()
public void clearExtends()
public JavaQName[] getExtends()
addExtends(JavaQName)
public void addExtends(JavaQName pExtends)
getExtends()
public void addExtends(java.lang.Class pExtends)
getExtends()
public boolean isExtending(JavaQName pClass)
public boolean isExtending(java.lang.Class pClass)
public JavaQName[] getImports()
addImport(JavaQName)
public void addImport(JavaQName s)
getImports()
public void addImport(java.lang.Class s)
addImport(JavaQName)
public void clearImports()
public JavaQName[] getImplements()
addImplements(JavaQName)
public void addImplements(JavaQName s)
getImplements()
public void addImplements(java.lang.Class s)
getImplements()
public void clearImplements()
public boolean isImplementing(JavaQName pClass)
public boolean isImplementing(java.lang.Class pClass)
public JavaField getField(java.lang.String pName)
public JavaField[] getFields()
newJavaField(String, JavaQName, Protection)
public JavaConstructor[] getConstructors()
newJavaConstructor(JavaConstructor, boolean)
public java.util.Iterator getConstructorIterator()
public JavaMethod[] getMethods()
newJavaMethod(String, JavaQName, Protection)
public JavaMethod getMethod(java.lang.String pMethodName, JavaQName[] pParams)
public JavaConstructor getConstructor(JavaQName[] pParams)
public java.util.Iterator getMethodIterator()
public void write(IndentationTarget pTarget) throws java.io.IOException
IndentationEngine
Adds the IndentationEngine's contents to the given
IndentationTarget
.
write
in interface IndentationEngine
write
in class IndentationEngineImpl
java.io.IOException
public static java.lang.String getQuotedNoQuotes(java.lang.String s)
public static java.lang.String getQuoted(java.lang.String s)
public void addInnerClass(JavaInnerClass pClass)
public void clearInnerClasses()
public JavaInnerClass[] getInnerClasses()
public JavaInnerClass getInnerClass(java.lang.String pName)
pName
, or
null, if no such class exists.
protected boolean getStatic()
public void setStatic(boolean pStatic)
public void addRawJavaSource(java.lang.String pSource)
public void clearRawJavaSources()
public java.lang.String[] getRawJavaSources()
public boolean isAbstract()
public void setAbstract(boolean isAbstract)
public boolean isInterface()
public java.lang.String asString(JavaQName pQName, boolean pAddIfPossible)
public boolean isForcingFullyQualifiedName()
public void setForcingFullyQualifiedName(boolean pForcingFullyQualifiedName)
public boolean hasDynamicImports()
public void setDynamicImports(boolean pDynamicImports)
public void write(java.io.Writer pTarget) throws java.io.IOException
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public JavaClassInitializer newJavaClassInitializer()
public JavaConstructor newJavaConstructor()
public JavaConstructor newJavaConstructor(JavaSource.Protection pProtection)
public JavaConstructor newJavaConstructor(java.lang.String pProtection)
newJavaConstructor(Protection.valueOf(pProtection))
.
public JavaConstructor newJavaConstructor(JavaConstructor pConstructor)
newJavaConstructor(pConstructor, false)
.
public JavaConstructor newJavaConstructor(JavaConstructor pConstructor, boolean pSuper)
newJavaConstructor(pConstructor, false)
.
If the pSuper
argument is true, adds an
invocation of the super classes constructor with the
same arguments.
public JavaMethod newJavaMethod(java.lang.String pName, java.lang.String pType)
public JavaMethod newJavaMethod(java.lang.String pName, java.lang.String pType, JavaSource.Protection pProtection)
public JavaMethod newJavaMethod(java.lang.String pName, java.lang.String pType, java.lang.String pProtection)
public JavaMethod newJavaMethod(java.lang.String pName, JavaQName pType)
public JavaMethod newJavaMethod(java.lang.String pName, JavaQName pType, JavaSource.Protection pProtection)
public JavaMethod newJavaMethod(java.lang.String pName, JavaQName pType, java.lang.String pProtection)
public JavaMethod newJavaMethod(java.lang.String pName, java.lang.Class pType)
public JavaMethod newJavaMethod(java.lang.String pName, java.lang.Class pType, JavaSource.Protection pProtection)
public JavaMethod newJavaMethod(java.lang.String pName, java.lang.Class pType, java.lang.String pProtection)
public JavaField newJavaField(java.lang.reflect.Field pField)
public JavaConstructor newJavaConstructor(java.lang.reflect.Constructor pConstructor)
public JavaMethod newJavaMethod(java.lang.reflect.Method pMethod)
pMethod
.
More precise:
pMethod.getName()
.pMethod.getReturnType()
.pMethod
.
pMethod.getParameterTypes()
, calls
AbstractJavaMethod.addParam(Class,String)
with the parameter names "p0", "p1", ...pMethod.getExceptionTypes()
, calls
AbstractJavaMethod.addThrows(Class)
.
public JavaMethod newJavaMethod(JavaMethod pMethod)
JavaSourceObject.isAbstract()
, JavaSourceObject.isStatic()
,
JavaSourceObject.isFinal()
, and JavaMethod.isSynchronized()
.
public JavaField newJavaField(java.lang.String pName, JavaQName pType, JavaSource.Protection pProtection)
public JavaField newJavaField(java.lang.String pName, JavaQName pType, java.lang.String pProtection)
public JavaField newJavaField(java.lang.String pName, JavaQName pType)
public JavaField newJavaField(java.lang.String pName, java.lang.String pType, JavaSource.Protection pProtection)
public JavaField newJavaField(java.lang.String pName, java.lang.String pType, java.lang.String pProtection)
public JavaField newJavaField(java.lang.String pName, java.lang.String pType)
public JavaField newJavaField(java.lang.String pName, java.lang.Class pType, JavaSource.Protection pProtection)
public JavaField newJavaField(java.lang.String pName, java.lang.Class pType, java.lang.String pProtection)
newJavaField(pName, pType,
Protection.valueOf(pProtecttion)
.
public JavaField newJavaField(java.lang.String pName, java.lang.Class pType)
public JavaInnerClass newJavaInnerClass(java.lang.String pName)
public JavaInnerClass newJavaInnerClass(java.lang.String pName, JavaSource.Protection pProtection)
public JavaInnerClass newJavaInnerClass(java.lang.String pName, java.lang.String pProtection)
public boolean isInnerClass()
public void newBeanProperty(JavaQName pType, java.lang.String pName)
String upperCaseName = Character.toUpperCase(pName.charAt(0)) + pName.substring(1); if (JavaQNameImpl.VOID.equals(pType)) { newBeanProperty(pType, pName, "is" + upperCaseName, "set" + upperCaseName); } else { newBeanProperty(pType, pName, "get" + upperCaseName, "set" + upperCaseName); }
public void newBeanProperty(java.lang.Class pClass, java.lang.String pName)
newBeanProperty(JavaQNameImpl.getInstance(pClass), pName)
.
newBeanProperty(JavaQName, String)
public void newBeanProperty(JavaQName pType, java.lang.String pFieldName, java.lang.String pGetMethodName, java.lang.String pSetMethodName)
newJavaField(pFieldName, pType, JavaSource.PRIVATE); JavaMethod getMethod = newJavaMethod(pGetMethodName, pType, JavaSource.PUBLIC); getMethod.addLine("return this.", pFieldName, ";"); JavaMethod setMethod = newJavaMethod(pSetMethodName, JavaQNameImpl.VOID, JavaSource.PUBLIC); setMethod.addParam(pType, pFieldName); setMethod.addLine("this.", pFieldName, " = ", pFieldName, ";");
pType
- The property typepFieldName
- The name of the generated field. The generated field has private
access.pGetMethodName
- The name of the generated get method or null, if no such
method is being created.pSetMethodName
- The name of the generated set method or null, if no such
method is being created.public void newBeanProperty(java.lang.Class pClass, java.lang.String pFieldName, java.lang.String pGetMethodName, java.lang.String pSetMethodName)
newBeanProperty(JavaQNameImpl.getInstance(pClass),
pFieldName, pGetMethodName, pSetMethodName)
.
newBeanProperty(JavaQName, String, String, String)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |