public class IlvSymbolCompiler extends Object
IlvSymbolCompiler
is the entry point to the JViews Symbol
Compiler API. This compiler lets you convert your palette symbols generated
by the Rogue Wave JViews Symbol Editor into Rogue Wave JViews Graphic
Framework classes, directly usable with regular IlvManager
or
IlvGrapher
objects. This means that the behavior of your symbols
is translated into Java code that you can read, debug, and extend.
You can use this class to compile a list of symbols or a whole symbol palette.
The API of the Symbol Compiler lets you set various options for the generated code. For example:
public
or abstract
modifiers
Constructor and Description |
---|
IlvSymbolCompiler()
Constructs an
IlvSymbolCompiler with a default palette
manager. |
IlvSymbolCompiler(IlvPaletteManager paletteManager)
Constructs an
IlvSymbolCompiler with the given palette
manager. |
Modifier and Type | Method and Description |
---|---|
void |
addURLToClassLoader(URL url)
Add an URL to the class loader used for compilation
The previous behavior added URLs to the system ClassLoader which cannot be done since Java 9.
|
void |
compilePalette(IlvPalette palette,
String javaDir,
String resourceDir,
String classDir)
Compiles the symbols of a given palette.
|
void |
compileSymbols(ArrayList<IlvPaletteSymbol> paletteSymbols,
String javaDir,
String resourceDir,
String classDir)
Generates the Java class source files for
paletteSymbols , and
then compiles to Java .class files. |
void |
generateSymbol(IlvPaletteSymbol symbol,
String javaDir,
String resourceDir)
Generates the Java class source file for
symbol . |
ClassLoader |
getClassLoader()
Returns the current
ClassLoader that is a URLClassLoader that is chained with the one
used by the palette manager. |
String |
getMappedClass(String key)
Returns the mapped name for a given class.
|
IlvPaletteManager |
getPaletteManager()
Returns the palette manager used by the Symbol Compiler.
|
String |
getParameterPrefix()
Returns the prefix of the parameter names.
|
String |
getParameterSuffix()
Returns the suffix of the parameter names.
|
String |
getVersion()
Returns the character string representing the version of the Symbol
Compiler.
|
boolean |
isAbstract()
Tests whether the generated symbol class is an abstract class.
|
boolean |
isExtractingResources()
Returns
true if the Symbol Compiler extracts the resource
files used by your symbols from the palette jars when generating their Java
classes. |
boolean |
isGeneratingParameterChangeSupport()
Returns
true if the Symbol Compiler generates the Parameter
Change Support. |
boolean |
isParameterCapitalized()
Returns
true if the first character of the parameter ID is
converted to upper case in the parameter getter and setter functions. |
boolean |
isPublic()
Returns
true if the generated symbol class is
public . |
void |
mapClass(String key,
String value)
Maps a class rule declaration to another Java class.
|
void |
setAbstract(boolean value)
Specifies whether the generated symbol class is an abstract class.
|
void |
setExtractingResources(boolean flag)
Specifies whether the resources used by the compiled symbols must be
extracted from the symbol palette jars or not.
|
void |
setGeneratingParameterChangeSupport(boolean supported)
Specifies whether the Parameter Change Support must be generated.
|
void |
setPaletteManager(IlvPaletteManager paletteManager)
Specifies a palette manager to be used by the Symbol Compiler.
|
void |
setParameterCapitalized(boolean capitalized)
Specifies whether the first character of the parameter ID is converted to
upper case in the getter and setter function names.
|
void |
setParameterPrefix(String prefix)
Sets a prefix to be added to the parameter names.
|
void |
setParameterSuffix(String suffix)
Sets a suffix to be appended to the parameter names.
|
void |
setPublic(boolean value)
Specifies whether the generated symbol class is a
public
class. |
void |
writeSymbolClass(Writer writer,
IlvPaletteSymbol symbol)
Generates the Java class source file of
symbol . |
public static final int SYMBOL_CONSTRUCTOR_TYPE
public static final int SUB_OBJECT_CONSTRUCTOR_TYPE
public static final int CONDITIONAL_TYPE
public static final int PSEUDO_TYPE
public static final int META_INFO_TYPE
public static final int UNKNOWN_VALUE
public static final int CONSTANT_VALUE
public static final int SUB_OBJECT_VALUE
public static final int PROPERTY_VALUE
public static final int EXPRESSION_VALUE
public static final int UNKNOWN_TYPE
public static final int INT_TYPE
public static final int LONG_TYPE
public static final int FLOAT_TYPE
public static final int DOUBLE_TYPE
public static final int SHORT_TYPE
public static final int BYTE_TYPE
public static final int STRING_TYPE
public static final int BOOLEAN_TYPE
public static final int COLOR_TYPE
public static final int BLINKING_COLOR_TYPE
public static final int FONT_TYPE
public static final int SHAPE_TYPE
public static final String BOOLEAN_TYPE_NAME
public static final String INT_TYPE_NAME
public static final String LONG_TYPE_NAME
public static final String FLOAT_TYPE_NAME
public static final String DOUBLE_TYPE_NAME
public static final String STRING_TYPE_NAME
public static final String COLOR_TYPE_NAME
public static final String BLINKING_COLOR_TYPE_NAME
public static final String FONT_TYPE_NAME
public static final String SHAPE_TYPE_NAME
public static final int JX_PRIMARY
These are the Java expression types. See Java Language Specification, Chapter 15: Expressions.
public static final int JX_POSTFIX
public static final int JX_UNARY
public static final int JX_MULTIPLICATIVE
public static final int JX_ADDITIVE
public static final int JX_SHIFT
public static final int JX_RELATIONAL
public static final int JX_EQUALITY
public static final int JX_BITWISE_AND
public static final int JX_BITWISE_XOR
public static final int JX_BITWISE_OR
public static final int JX_COND_AND
public static final int JX_COND_OR
public static final int JX_CONDITIONAL
public static final int JX_ASSIGNMENT
public static final int JX_ANY
public static final String NOT_MONO_SELECTOR
public static final String UNKNOWN_RULE_TYPE
public static final String UNKNOWN_DECLARATION
public static final String UNKNOWN_PROPERTY
public static final String UNKNOWN_PARAMETER
public static final String FOUR_SPACES
public static final String SYMBOL_TYPE
public static final String CLASS
public static final String PARAMETER
public static final String META_INFO
public static final String PALETTE_JAR_PROTOCOL
public IlvSymbolCompiler()
IlvSymbolCompiler
with a default palette
manager.IlvSymbolCompiler(IlvPaletteManager)
public IlvSymbolCompiler(IlvPaletteManager paletteManager)
IlvSymbolCompiler
with the given palette
manager.paletteManager
- The palette manager.setPaletteManager(IlvPaletteManager)
,
getPaletteManager()
public void setPaletteManager(IlvPaletteManager paletteManager)
paletteManager
- The new palette manager.IlvSymbolCompiler(IlvPaletteManager)
,
getPaletteManager()
public IlvPaletteManager getPaletteManager()
IlvSymbolCompiler(IlvPaletteManager)
,
setPaletteManager(IlvPaletteManager)
public ClassLoader getClassLoader()
ClassLoader
that is a URLClassLoader
that is chained with the one
used by the palette manager.
addURLToClassLoader(URL)
to add URLs to this ClassLoader
ClassLoader
chained with the one used by the palette manager.public void compilePalette(IlvPalette palette, String javaDir, String resourceDir, String classDir) throws IlvSymbolCompilerException, IOException
palette
- The symbol palette containing the palette symbols to compile.javaDir
- The output directory for the generated Java source file.resourceDir
- The output directory for resources used by the generated symbols.classDir
- The output directory for the .class
files.IlvSymbolCompilerException
- Thrown by a compilation operation.IOException
- Thrown by an IO operation.public void compileSymbols(ArrayList<IlvPaletteSymbol> paletteSymbols, String javaDir, String resourceDir, String classDir) throws IlvSymbolCompilerException, IOException
paletteSymbols
, and
then compiles to Java .class
files.paletteSymbols
- The palette symbols to translate to Java classes.javaDir
- The output directory for the generated Java source code.resourceDir
- The output directory for the used resource files.classDir
- The output directory for the .class
files.IlvSymbolCompilerException
- Thrown by a compilation operation.IOException
- Thrown by an IO operation.public void addURLToClassLoader(URL url)
URLClassLoader
that is chained with the palette manager
ClassLoader
and that allows to dynamically add URL to the classpath. Applications should use @see getClassLoader()
when testing class instantiation.url
- URL to addpublic void generateSymbol(IlvPaletteSymbol symbol, String javaDir, String resourceDir) throws IlvSymbolCompilerException, IOException
symbol
.symbol
- The palette symbol to translate to a Java class.javaDir
- The output directory for the generated Java source code.resourceDir
- The output directory for the used resources.IlvSymbolCompilerException
IOException
public void writeSymbolClass(Writer writer, IlvPaletteSymbol symbol) throws IOException, IlvSymbolCompilerException
symbol
.writer
- The writer.symbol
- The palette symbol.IOException
- Thrown by the writer
operations.IlvSymbolCompilerException
- Thrown when something is wrong with symbol
.public void mapClass(String key, String value)
key
- The class name specified in the class rule declaration.value
- The actual Java class name to be used.getMappedClass(String)
public String getMappedClass(String key)
key
- The class name as it is specified in the rule declaration.mapClass(String, String)
public String getParameterPrefix()
setParameterPrefix(String)
public void setParameterPrefix(String prefix)
get
or set
, and before the parameter ID. By
default, there is no prefix.prefix
- The parameter prefix.getParameterPrefix()
public String getParameterSuffix()
setParameterSuffix(String)
public void setParameterSuffix(String suffix)
Parameter
suffix is used.suffix
- The parameter suffix.getParameterSuffix()
public boolean isParameterCapitalized()
true
if the first character of the parameter ID is
converted to upper case in the parameter getter and setter functions.true
if the parameter ID is capitalized.setParameterCapitalized(boolean)
public void setParameterCapitalized(boolean capitalized)
true
.capitalized
- If true
, the parameter ID is capitalized.isParameterCapitalized()
public boolean isGeneratingParameterChangeSupport()
true
if the Symbol Compiler generates the Parameter
Change Support.true
if the Symbol Compiler generates the Parameter
Change Support.setGeneratingParameterChangeSupport(boolean)
public void setGeneratingParameterChangeSupport(boolean supported)
By default, the Symbol Compiler generates this support. If you do not want
the corresponding code to be generated, you can set this option to
false
.
supported
- If true
, the Parameter Change Support is generated.isGeneratingParameterChangeSupport()
public boolean isExtractingResources()
true
if the Symbol Compiler extracts the resource
files used by your symbols from the palette jars when generating their Java
classes.true
if the resources files are extracted.setExtractingResources(boolean)
public void setExtractingResources(boolean flag)
true
. If you do not want the Symbol Compiler to extract the
symbol resource files, call this function with false
as
argument.flag
- true
if the symbol resources are extracted.isExtractingResources()
public String getVersion()
public boolean isAbstract()
true
if the generated symbol class is an abstract
class.setAbstract(boolean)
public void setAbstract(boolean value)
abstract
modifier for your symbol class.value
- true
if the generated symbol class is an abstract
class.isAbstract()
public boolean isPublic()
true
if the generated symbol class is
public
.true
if the generated symbol class is
public
.setPublic(boolean)
public void setPublic(boolean value)
public
class. By default, the Symbol Compiler generates your symbol class with the
public
modifier. If you do not want this modifier to be
generated, this function lets you set this option to false
.value
- true
if the symbol class is public
.isPublic()
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.