Package org.rexxla.bsf.engines.rexx
Class ClassAdapter
java.lang.Object
org.rexxla.bsf.engines.rexx.ClassAdapter
This class creates a proxied Java class on the fly, which has concrete implementations for all
abstract (inherited or not) methods. Additionally it allows for creating proxy methods for
concrete methods and matching
"_forwardToSuper" methods to allow ooRexx to forward
proxied Java method invocations to their original target on the Java side.
------------------------ Apache Version 2.0 license -------------------------
Copyright (C) 2010-2019 Rony G. Flatscher
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
----------------------------------------------------------------------------- - Since:
- 2010
- Version:
- 1.04, 2010-03-27, 2010-04-14, 2010-04-17, 2010-04-18, 2010-11-30, 2011-05-31, 2014-08-30, 2016-11-01, 2016-11-04/5, 2017-03-13, 2019-08-24
- Author:
- Rony G. Flatscher (WU-Wien/Wirtschaftsuniversität Wien, http://www.wu.ac.at)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic booleanFlag that determines whether the generated class name should get the CRC32 value appended, defaults totrue.static booleanFlag that determines whether the suppliednewNameshould get the CRC32 value appended, defaults totrue.static booleanFlag that determines whether the generated class name should get the hash value of the class object appended, defaults tofalse.static booleanControls whether the generated file name's date and time portion should contain the date portion only, defaults tofalse.static booleanControls whether the generated file name includes a date and time portion, defaults totrue.static booleanControls whether the generated file name should be led in with the extended class' simple name, defaults totrue.static booleanFlag that determines whether the generated program should be stored in the file system.static booleanstatic booleanstatic StringString that gets appended to the generated class name to ease locating such classes, defaults to"_$RexxExtendClass$_".static StringPackage name that will replace the package name of the extended class, defaults to"org.rexxla.bsf.engines.rexx.onTheFly".static StringPath where a generated program should be stored to, defaults to the Java temporary directory(System.getProperty("java.io.tmpdir")).static final StringVersion information on this class. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringCalculate the CRC32 value for the supplied string and return an uppercased hex-string.static ClasscreateProxiedJavaClass(Class javaClassToProxy, String strNewClzName, String[] methodNames2proxy, Class[] interfaceClasses) Creates and returns a proxy class in which Java method invocations get forwarded to a RexxProxy.static StringCreates and formats aDateobject.static StringFormats aDateobject.static voidAllow using this class from the command line to create an extended Java class and displaying the generated source.
-
Field Details
-
bTiming
public static boolean bTiming -
bShowSource
public static boolean bShowSource -
version
Version information on this class.- See Also:
-
bFileNameWithSimpleName
public static boolean bFileNameWithSimpleNameControls whether the generated file name should be led in with the extended class' simple name, defaults totrue. -
bFileNameWithDateTime
public static boolean bFileNameWithDateTimeControls whether the generated file name includes a date and time portion, defaults totrue. -
bFileNameWithDateOnly
public static boolean bFileNameWithDateOnlyControls whether the generated file name's date and time portion should contain the date portion only, defaults tofalse. -
bSaveToFilesystem
public static boolean bSaveToFilesystemFlag that determines whether the generated program should be stored in the file system. -
bAddCRC32toNewName
public static boolean bAddCRC32toNewNameFlag that determines whether the suppliednewNameshould get the CRC32 value appended, defaults totrue. The CRC32 value gets calculated from the string values of the arguments such that the same arguments are expected to create the same CRC32 value. -
bAddCRC32toGeneratedClassName
public static boolean bAddCRC32toGeneratedClassNameFlag that determines whether the generated class name should get the CRC32 value appended, defaults totrue. -
bAddHashToGeneratedClassName
public static boolean bAddHashToGeneratedClassNameFlag that determines whether the generated class name should get the hash value of the class object appended, defaults tofalse. If name clashes occur in an application due to having duplicate CRC32 values generated, then setting this flag totrueshould allow for creating unique class names thereafter. -
extensionIndicator
String that gets appended to the generated class name to ease locating such classes, defaults to"_$RexxExtendClass$_". -
packageName
Package name that will replace the package name of the extended class, defaults to"org.rexxla.bsf.engines.rexx.onTheFly". If the value isnull, then the package name will not be replaced. If the value is the empty String (length of 0), then the package of the extended class will be removed. -
pathToSaveTo
Path where a generated program should be stored to, defaults to the Java temporary directory(System.getProperty("java.io.tmpdir")).
-
-
Method Details
-
main
Allow using this class from the command line to create an extended Java class and displaying the generated source. Example:
java java org.rexxla.bsf.engines.rexx.ClassAdapter javax.swing.AbstractAction ronysClass "*"- Parameters:
args- array of blank delimited Strings in the form of "fullJavaClassName [newClassName [methodToProxy [...]]". If there is a single method to proxy with a value of "*" (asterisk), then all declared methods will get proxied.- Throws:
org.apache.bsf.BSFException- if any execution error occurs
-
createProxiedJavaClass
public static Class createProxiedJavaClass(Class javaClassToProxy, String strNewClzName, String[] methodNames2proxy, Class[] interfaceClasses) throws org.apache.bsf.BSFException Creates and returns a proxy class in which Java method invocations get forwarded to a RexxProxy.- Parameters:
javaClassToProxy- Class object to use for proxyingstrNewClzName-nullor name for proxy class to createmethodNames2proxy- an array denoting the protected or public methods to proxy. Please note: each proxied class will get all public/protected abstract methods and constructors created (proxied).
Each method name element denotes a public or protected single method which may be optionally preceeded by a blank and preceeded by the name of some Java superclass to be used for looking up the method definitions to proxy. The following special cases apply for this argument:- if this argument is
null, then only the public/protected abstract methods and constructors get proxied. - if this argument has no elements (its
lengthfield is0), then only the public/protected abstract methods and constructors get proxied. - if this argument has a single element with the value
"*"(asterisk), then all public/protected methods and constructors get proxied.
- if this argument is
interfaceClasses- optional, the extended class should in addition implement all abstract methods of these interface classes- Returns:
- the class object representing the extended class
- Throws:
org.apache.bsf.BSFException- if any execution error occurs
-
formatDateTime
Creates and formats aDateobject. Depending onbFileNameWithDateOnlythe time portion may be left out.- Returns:
- formatted
Dateobject representing the date and time of invocation
-
formatDateTime
Formats aDateobject. Depending onbFileNameWithDateOnlythe time portion may be left out. -
calcCRC32
Calculate the CRC32 value for the supplied string and return an uppercased hex-string.- Parameters:
str- the String for which the checksum should get calculated- Returns:
- the uppercased hexadecimal value
-