First Commit from Source Code Reply

This commit is contained in:
vincenzofariello
2024-05-09 17:40:24 +02:00
parent 11e3b57c5b
commit 107a016cb9
35225 changed files with 1111346 additions and 1 deletions

View File

@@ -0,0 +1,118 @@
@start rule: main
/**
* This code was automatically generated at @time on @date
* by @generator -- do not edit.
*
* @@version @buildString
* @@author Copyright (c) @year by BEA Systems, Inc. All Rights Reserved.
*/
@generator_package_decl
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
import weblogic.utils.AssertionError;
import weblogic.utils.Debug;
import weblogic.xml.process.GeneratingContext;
import weblogic.xml.process.InvalidPathException;
import weblogic.xml.process.OutProcessor;
import weblogic.xml.process.XMLProcessingException;
import weblogic.xml.process.XMLGenerator;
public final class @generator_class @extends_super_class
implements XMLGenerator, OutProcessor
{
private static final boolean __debug = false;
private static final boolean __verbose = false;
private static Map __paths = new HashMap();
private Writer __out;
@public_id_decl
@sys_id_decl
@init_paths
public void generate(String elementPath, Object[] params)
throws IOException, XMLProcessingException
{
if (__out == null) {
__out = new BufferedWriter(new OutputStreamWriter(System.out));
}
docTypeHeader(__out, elementPath);
GeneratingContext gctx = new GeneratingContext(elementPath);
gctx.setWriter(__out);
generate(gctx, params);
gctx.release();
}
private void generate(GeneratingContext gctx, Object[] params)

View File

@@ -0,0 +1,96 @@
<!--
Top-level element: declare xml generation instructions
-->
<!ELEMENT java-to-xml (
processor-params,
generate-element*)
>
<!--
Declare basic information about the processor that is to be code-generated
from these XML generation instructions.
-->
<!ELEMENT processor-params (
processor-package,
processor-superclass?,
processor-class,
(xml-public-id, dtd-url)?
)>
<!--
Declare a package name for the code-generated processor class.
-->
<!ELEMENT processor-package (#PCDATA)>
<!--
Optional: Declare a superclass that the code-generated processor class will extend.
If omitted, the processor class will extend java.lang.Object.
-->
<!ELEMENT processor-superclass (#PCDATA)>
<!--
Declare the class name of the code-generated processor class.
-->
<!ELEMENT processor-class (#PCDATA)>
<!--
Declare the public ID of the XML documents that will be generated by
this processor.
-->
<!ELEMENT xml-public-id (#PCDATA)>
<!--
Specify a URL from which the DTD for the documents
being processed by this processor can be obtained.
-->
<!ELEMENT dtd-url (#PCDATA)>
<!ELEMENT generate-element ( declare-param*, java)>
<!ATTLIST generate-element
element CDATA #REQUIRED
element-context CDATA #IMPLIED
>
<!ELEMENT declare-param EMPTY>
<!ATTLIST declare-param
name CDATA #REQUIRED
class CDATA #REQUIRED
>
<!--
Java code to be to construct an element.
Note: all elements referenced must be above or at the current element in the
document tree. Soon it will also be possible to reference nodes below the current
node (in actions with phase "element-end" only).
-->
<!ELEMENT java ( #PCDATA |
set-attribute-value |
write-text |
write-xml
)*
>
<!ELEMENT write-text (#PCDATA)>
<!ATTLIST write-text
from-var CDATA #IMPLIED
>
<!ELEMENT set-attribute-value (#PCDATA)>
<!ATTLIST set-attribute-value
name CDATA #REQUIRED
from-var CDATA #IMPLIED
>
<!ELEMENT write-xml (param*)>
<!ATTLIST write-xml
element CDATA #REQUIRED
element-context CDATA #IMPLIED
>
<!ELEMENT param (#PCDATA)>

View File

@@ -0,0 +1,160 @@
@start rule: main
/**
* This code was automatically generated at @time on @date
* by @generator -- do not edit.
*
* @@version @buildString
* @@author Copyright (c) @year by BEA Systems, Inc. All Rights Reserved.
*/
@processor_package_decl
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import org.xml.sax.InputSource;
import weblogic.utils.AssertionError;
import weblogic.utils.Debug;
import weblogic.xml.process.Functions;
import weblogic.xml.process.InProcessor;
import weblogic.xml.process.ProcessorDriver;
import weblogic.xml.process.ProcessingContext;
import weblogic.xml.process.SAXValidationException;
import weblogic.xml.process.SAXProcessorException;
import weblogic.xml.process.XMLParsingException;
import weblogic.xml.process.XMLProcessingException;
import weblogic.xml.process.XMLProcessor;
public final class @processor_class @extends_super_class
implements XMLProcessor, InProcessor
{
private static final boolean debug = true;
private static final boolean verbose = true;
private static final Map paths = new HashMap();
private ProcessorDriver driver;
public ProcessorDriver getDriver() { return driver; }
@public_id_decl
@local_dtd_decl
@init_paths
public @processor_class() {
this(true); // validate by default
}
public @processor_class(boolean validate) {
driver = @get_processor_driver;
}
public void process(String xmlFilePath)
throws IOException, XMLParsingException, XMLProcessingException
{
driver.process(xmlFilePath);
}
public void process(File xmlFile)
throws IOException, XMLParsingException, XMLProcessingException
{
driver.process(xmlFile);
}
public void process(Reader xmlReader)
throws IOException, XMLParsingException, XMLProcessingException
{
driver.process(xmlReader);
}
public void process(InputSource xmlInputSource)
throws IOException, XMLParsingException, XMLProcessingException
{
driver.process(xmlInputSource);
}
// FIX CR046934 : reading as binary to enable xerces automatic encoding detector.
public void process(InputStream xmlInputStream)
throws IOException, XMLParsingException, XMLProcessingException
{
driver.process(xmlInputStream);
}
public void preProc(ProcessingContext pctx) throws SAXProcessorException {
if (debug) Debug.assertion(pctx != null);
String path = pctx.getPath();
if (debug) Debug.assertion(path != null);
Integer id = (Integer)paths.get(path);
if (id == null) return; // nothing to do
@preproc_dispatch
}
public void postProc(ProcessingContext pctx) throws SAXProcessorException {
if (debug) Debug.assertion(pctx != null);
String path = pctx.getPath();
if (debug) Debug.assertion(path != null);
Integer id = (Integer)paths.get(path);
if (id == null) return; // nothing to do
@postproc_dispatch
}
@element_processing_dispatches
@main_method
public void addBoundObject(Object obj, String name) {
driver.currentNode().addBoundObject(obj, name);
}
}
@end rule: main
@start rule: element_processing_dispatch
/*
* ELEMENT PATHS: @element_path
*/
@document_scope_binding_getters
private void @element_preproc_method(ProcessingContext pctx) {
@new_bindings
// pre-actions: not supported at this time
}
private void @element_postproc_method(ProcessingContext pctx) @throws_processing_exceptions {
@fetch_function_values
@fetch_bound_objects
@validations
@post_actions
}
@end rule: element_processing_dispatch
@start rule: invoke_validation_method
try {
@validation_method_name(@element_value_variable);
} catch (Exception e) {
throw new SAXValidationException("Path " + pctx.getPath() + ": " + e.getMessage());
}
@end rule: invoke_validation_method
@start rule: main_method_code
// main method is usually just for debugging and testing purposes
public static void main(String args[]) throws Exception {
if (args.length != 1) {
System.err.println("Usage: @processor_class <XML file>");
System.exit(1);
}
@processor_class processor = new @processor_class();
processor.process(args[0]);
}
@end rule: main_method_code

View File

@@ -0,0 +1,148 @@
<!--
Top-level element: declare xml-to-java processing instructions
-->
<!ELEMENT xml-to-java (
processor-params,
document-start-action?,
processing-action*,
document-end-action?)
>
<!--
Declare basic information about the processor that is to be code-generated from these
processing instructions.
-->
<!ELEMENT processor-params (
processor-package,
processor-superclass?,
processor-class,
xml-public-id,
(local-dtd-resource-name | dtd-url) )
>
<!--
Declare a package name for the code-generated processor class.
-->
<!ELEMENT processor-package (#PCDATA)>
<!--
Optional: Declare a superclass that the code-generated processor class will extend.
If omitted, the processor class will extend java.lang.Object.
-->
<!ELEMENT processor-superclass (#PCDATA)>
<!--
Declare the class name of the code-generated processor class.
-->
<!ELEMENT processor-class (#PCDATA)>
<!--
Declare the public ID of the XML documents that will be handled by this processor.
NOTE: this is currently a required element, but it is under consideration to make it
optional.
-->
<!ELEMENT xml-public-id (#PCDATA)>
<!--
Optional: Specify a local resource name from which the DTD for the documents
being processed by this processor can be obtained. If this is omitted, and if
xml-public-id is specified, the DTD will be obtained from the system ID URI in the
documents DOCTYPE header.
-->
<!ELEMENT local-dtd-resource-name (#PCDATA)>
<!--
Optional: Specify an alternative URL from which the DTD for the documents
being processed by this processor can be obtained. If this is omitted, and if
xml-public-id is specified, the DTD will be obtained from the system ID URI in the
documents DOCTYPE header.
-->
<!ELEMENT dtd-url (#PCDATA)>
<!--
Provide a processing action that will be executed at the start of processing of the
document, before any elements are read.
-->
<!ELEMENT document-start-action ( declare-obj*, java?)>
<!--
Provide a processing action that will be executed at the conclusion of processing
of the document, after all elements have been read and processed.
-->
<!ELEMENT document-end-action ( declare-obj*, java?)>
<!--
Declare a processing action that will be executed when a particular element is read
in a particular context.
The following attributes are required:
element The element name at which the action will fire
The following attributes are optional:
element-context
As much of the path of the parent element as is required to identify
the element in the XML document structure.
phase Whether the action should fire at the beginning of the processing
of the element or after all the subelements of the element have been
processed.
-->
<!ELEMENT processing-action (declare-obj*, validation?, java?)>
<!ATTLIST processing-action
element CDATA #REQUIRED
element-context CDATA #IMPLIED
phase (element-start|element-end) "element-end"
>
<!--
Declare a reference to a bound object. This object will be in scope for the current
element and any elements downward of it in the XML document tree. At the moment,
only one object of a given class can be bound in scope.
-->
<!ELEMENT declare-obj EMPTY>
<!ATTLIST declare-obj
class CDATA #REQUIRED
var-name CDATA #REQUIRED
initialize (true|false) "true"
scope (document|element) "element"
library-name CDATA #IMPLIED
>
<!--
Java code to be executed when the processing action fires. The code must be
compilable Java with the exception of the following pseudo-variables.
@{name} refers to the PCDATA value of an element with name "name"
@{name.attr-name}
refers to the CDATA value of an attribute of name "attr-name" of an
element with name "name"
Note: all elements referenced must be above or at the current element in the
document tree. Soon it will also be possible to reference nodes below the current
node (in actions with phase "element-end" only).
-->
<!ELEMENT java (#PCDATA)>
<!--
Perform validation on the value of the element in the processing action. If the
element value is invalid, a SAXValidationException will be thrown by the processor.
The following attributes are optional:
nullable Indicates whether the element value is allowed to be empty
(i.e., whitespace)
values Provide a list of valid values. These are separated by the delimiter
'|'. For example, values="True|False".
method Indicates the method of the given name should be invoked with the
element value passed as a single String argument. If the method
detects an invalid value, it must throw an Exception of some kind.
-->
<!ELEMENT validation EMPTY>
<!ATTLIST validation
nullable (true|false) "true"
values CDATA #IMPLIED
method CDATA #IMPLIED
>