SYSTEM AND METHOD FOR TRANSLATING TO AND FROM HIERARCHICAL INFORMATION SYSTEMS

Abstract: A system for translating to and from a hierarchical information system comprises a server (6), an interface (1), a technical architecture framework (8), and a legacy system (9). The method comprises the steps of identifying a non-hierarchical information system containing information stored in a non-hierarchical manner, developing a translation map that identifies organizational and content based rules for translating the non-hierarchical information into a hierarchical information system, and translating the non-hierarchical information for storage into the hierarchical information system according to the rules for translating.

Description: TITLE SYSTEM AND METHOD FOR TRANSLATING TO AND FROM HIERARCHICAL INFORMATION SYSTEMS COPYRIGHT REFERENCE Two Appendixes are included in this application that contain material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the Appendixes, as it appears in the Patent and Trademark Office patent files or records, but otherwise reserves all copyright rights whatsoever. BACKGROUND OF THE INVENTION The present invention relates to a system and method for translating information, to or from, an hierarchical information system. Legacy systems are systems that support business function, many of which have been in use for many years. These systems usually store information, and communicate with each other, using non-hierarchical information systems, such as linear strings (i.e. legacy messages). Modern systems often use an hierarchical system to store information and communicate with each other. Hierarchical system typically store information in a tree structure of objects, each object having specific attributes, and where each object may be linked to other objects. XML (Extensible Markup Language) is an example of an hierarchical system. The need arises for an interface to translate information between systems. Simple systems that translate between linear strings are well known. However, there is a need for products that can read the objects of an hierarchical system and perform the required data transformations. MERCATOR, for example, could be used if first the object model were translated into a standard, predictable data stream. However, the effort to translate the object model into this intermediate format is similar to the effort required to translate the object model into a form directly usable by the legacy system. In addition, MERCATOR is implemented as a single-threaded DLL (Dynamic Linked Library) in Windows NT, which may have an adverse impact on overall system performance and throughput. BRIEF SUMMARY OF THE INVENTION A first aspect of the invention is a method for translating to ana τrom an hierarchical information system, comprising identifying a non-hierarchical information system containing information stored in a non-hierarchical manner; developing a translation map that identifies organizational and content based rules for translating the non-hierarchical information into an hierarchical information system; and translating the non-hierarchical information for storage into the hierarchical information system according to the rules for translating. A second aspect of the invention is computerized method for translating to and from an hierarchical information system. A third aspect of the invention is a system for translating to and from an hierarchical information system, comprising means for identifying a non- hierarchical information system containing information stored in a non- hierarchical manner; means for developing a translation map that identifies organizational and content based rules for translating the non-hierarchical information into an hierarchical information system; and means for translating the non-hierarchical information for storage into the hierarchical information system according to the rules for translating. A fourth aspect of the invention is a system for translating to and from an hierarchical information system, comprising a first computer system having a memory for storing information in an hierarchical information system; an interface coupled to the first computer system, the interface having means for identifying a non-hierarchical information system containing information stored in a non-hierarchical manner, developing a translation map that identifies organizational and content based rules for translating the non-hierarchical information into an hierarchical information system, and translating the non- hierarchical information for storage into the hierarchical information system according to the rules for translating; and a second computer system coupled to the interface, the second computer system having a memory for storing information in a non-hierarchical information system. A fifth aspect of the invention is a method for translating to and from an hierarchical information system, comprising translating data from an object model into a legacy message. A sixth aspect of the invention is a method for translating to and from an hierarchical information system, comprising translating data from a legacy message model into an object. A seventh aspect of the invention is a method for translating to and from an hierarchical information system, comprising identifying an hierarchical information system containing information stored in an hierarchical manner; developing a translation map that identifies organizational and content based rules for translating the hierarchical information into an non-hierarchical information system; and translating the hierarchical information for storage into the non-hierarchical information system according to the rules for translating. An eighth aspect of the invention is a computerized method for translating to and from an hierarchical information system, comprising identifying an hierarchical information system containing information stored in an hierarchical manner; developing a translation map that identifies organizational and content based rules for translating the hierarchical information into an non-hierarchical information system; and translating the hierarchical information for storage into the non-hierarchical information system according to the rules for translating. A ninth aspect of the invention is a system for translating to and from an hierarchical information system, comprising means for identifying an hierarchical information system containing information stored in an hierarchical manner; means for developing a translation map that identifies organizational and content based rules for translating the hierarchical information into a non-hierarchical information system; and means for translating the hierarchical information for storage into the non-hierarchical information system according to the rules for translating. A tenth aspect of the invention is a system for translating to and from an hierarchical information system, comprising a first computer system having a memory for storing information in a non-hierarchical information system; an interface coupled to the first computer system, the interface having means for identifying an hierarchical information system containing information stored in an hierarchical manner, developing a translation map that identifies organizational and content based rules for translating the hierarchical information into a non-hierarchical information system, and translating the hierarchical information for storage into the non-hierarchical information system according to the rules for translating; and a second computer system coupled to the interface, the second computer system having a memory for storing information in an hierarchical information system. BRIEF DESCRIPTION OF THE DRAWINGS These and other features and advantages of the invention will become apparent upon a review of the following detailed description of the presently preferred embodiments of the invention, when viewed in conjunction with the appended drawings. Figure 1 shows the application architecture and components of an interface. Figure 2 shows the application architecture and components of another interface. Figure 3 is an illustration showing the transformation of attributes from an hierarchical system to a non-hierarchical system, and the reverse. DETAILED DESCRIPTION OF THE INVENTION The present invention includes an interface that supports the specific data transformation requirements of translating information from a specific hierarchical system (also referred to as an object model), such as XML data, into a non-hierarchical system, such as linear strings (i.e., custom legacy messages), or into a different specific hierarchical system. The interface performs the mapping, lookups and derivations necessary to format legacy messages in a manner consistent with the legacy applications. The application architecture and components of the interface are shown in Figure 1. The components, and additional optional components, are shown in Figure 2. As will be apparent to those of ordinary skill in the art, the interface may be software implemented on a general purpose computer, or may be dedicated hardware, or a combination thereof. Furthermore each individual component may be software implemented on a general purpose computer, or may be dedicated hardware, or a combination thereof. All components of the interface are described first, followed by a section describing the application flow. A subsequent section includes a summary of the data transformations supported by the interface. As schematically shown in Figure 1 , the interface 1 includes a coordinator 2, a searcher 4, and a writer 5. Also shown in the figure are a map file 3, a toolkit 7, a technical architecture framework 8, a legacy system 9, and a server 6. In addition to those parts shown in Figure 1 , Figure 2 schematically shows another server 12 that may use a different object model, a toolkit 7' for this different object model, a searcher 4' for this different object model, a second legacy system 9, a ruler 10, and a responder 11. The map file defines the attributes that are to be obtained from the object or IDL (interface definition language) structure and used in the construction of legacy messages. The map file defines the attribute location (in each object in the object model), the format of the attribute values as they should appear in the legacy message, and the order in which the attribute values should appear in the legacy message. The map file may be viewed as a series of commands, which instruct the coordinator on how to construct the legacy message from the objects. The coordinator controls the process of reading the map file and using the searcher and optional ruler to obtain information to send to the writer. The coordinator orchestrates the translation, resolution, derivation, message construction, and message delivery processes. The coordinator includes a map interpreter, which interprets the commands in the map file. Preferably the coordinator is developed using JAVACC, a SUN MICROSYSTEMS product. Given a grammar that describes the syntax used in the map file, JAVACC can be used to create the coordinator and allow map files to contain commands that access the searcher, ruler and writer. The searcher provides an interface that is used by the coordinator and the ruler to obtain attribute information within each object. The coordinator uses commands from the map file to translate data (attributes) from an object model to the legacy system attributes. The coordinator executes rules as they are read from the map file. The coordinator uses the searcher to locate attributes used in a command. For example, if a command requires a calculation using attributes in an object, the coordinator would use the searcher to obtain these attributes and perform the calculation. The writer formats attributes passed by the coordinator and uses them to the construct the message that is sent to the legacy system. The optional responder returns confirmations from the legacy system to the system that initiated the transaction. If the initiating system is a server, the responder converts the legacy response to an XML message. For example, systems using the IDL interface will receive responses in the form of IDL structures. The following is an example of how the system shown in Figure 2 may operate. A request is made of the interface via a CORBA IDL interface. Upon receipt of the request, the interface creates a new coordinator passing either the XML string or the IDL defined structure, and starts the coordinator. The coordinator creates a new searcher, passing in the object model to be searched. The coordinator creates a new ruler, passing in the previously created searcher. The ruler will use the searcher if necessary during execution of its rules. The coordinator then requests the target system identifier (e.g. legacy system) of the searcher. The coordinator will create a new writer, passing the target system identifier. The target system identifier is required so that the writer deposits the constructed message on the appropriate legacy queue. The coordinator requests the map file of the map loader. If the map loader has the requested map file cached, the memory-resident map file is returned to the coordinator. If the map is not loaded, the map loader loads it and returns it to the coordinator. The map loader is an optional component that only carries out this function, and advantageously prevents the need to reload map files that have been previously loaded. The coordinator (via the map interpreter) reads the map file and determines that an attribute from an object model is needed. The coordinator (via the map interpreter) makes a request of the searcher to get the needed attribute information. The searcher finds and returns the requested attribute. The coordinator (via the map interpreter) tells the writer to add the obtained attribute information to the message under construction. The writer formats the attribute information as defined by the map file and then appends the formatted attribute to the message under construction. The coordinator reads the map file and may encounter a command that invokes a rule. In this case, the coordinator makes a request of the ruler to execute the specified rule. The ruler makes a request of the searcher to get, if necessary, attribute information needed during execution of the rule. The searcher finds and returns the requested attribute. The coordinator tells the writer to add the obtained attribute information to the message under construction. The writer formats the attribute information as defined by the map file and then appends the formatted attribute to the message under construction. At the end of the map file, the coordinator tells the writer to complete the message under construction and to send it to the appropriate legacy system. The writer makes a request of the technical architecture (also referred to as an underlying architecture) to package the message, for example, as a queued message (for IBM MQ Series, or MICROSOFT MSMQ), and deposit it on the appropriate legacy system queue. The technical architecture creates a new message using the application-defined message content and deposits the message on the appropriate legacy queue. In a preferred embodiment, the memory address of each object is retained as a legacy message is constructed, reducing the time necessary for the reading of additional attributes needed to construct the legacy message. Figure 3 is an illustration showing the transformation of attributes (data) from an hierarchical system (left) to a non-hierarchical system (right), which in this illustration is a linear string. The individual attributes of the objects in the hierarchical system are represented by letters, while attributes in the linear string are represented by numbers. The interface can read the attributes of the objects, and translate them (from letters to number in this illustration), and write them into a linear string. The linear string may then be passed to a legacy system. As illustrated, the reverse is also possible. Once the message has been processed by the legacy system, an optional response is returned to the technical architecture via a message queue. The technical architecture retrieves the message from the queue and creates an optional responder. The technical architecture passes the data portion of the message to the responder and instructs the responder to execute the process of returning the response. The responder creates an object and populates the object with data (attributes) expected by the server. This data includes attributes such as a group identifier that is generated by the legacy system, for example group enrollment of an insurance plan. In the case where the object model is XML, once the object has been populated, the responder creates an XML message. The responder queries the Proxy Pool Manager for a secure proxy to the appropriate server. The responder then uses the secure proxy to send the XML message response to the server. If, after a predefined number of tries, the proxy cannot be used to send the results to the server, a return code is passed back to the technical ' architecture and the message is sent to a resend queue to be delivered at a later time. Once the response has been successfully delivered to the server, a return code is passed back to the technical architecture and the message is deleted from the queue. The application architecture is designed to handle the following categories of data transformations: simple mapping, constants, code lookups, derived rule, multiple source locations (plan modeling), and rate information fields (when the data contains information relating to a service, such as insurance). Simple mapping means mapping fields that can be mapped directly from an object attribute to a legacy message field without any additional mapping logic. Constants are fields in the legacy message that are required and are always populated with the same information. For example, a field that describes the type of transaction would always contain an 'E' for electronic since the framework is an electronic means of creating the message. Code lookups are fields that require a translation from how an attribute is described in the hierarchical system, and how the same attribute is described in a legacy message. A derived rule is a field that is extracted from the object model and translated to the legacy message fields based on rules (such as business rules) as defined in the ruler. Multiple source locations are fields that involve the same process of a simple map. However, the source attribute may be located in different areas of the Vendor object model. Rate information fields are fields that are a specialized form of derivation rules that use name/value pairs. Unlike basic derived fields that rely on class names to find attributes in the object model, data values are used to search for rate attributes in the object model. The map file contains commands, which are defined in the order that the legacy message needs to be constructed. The following are examples of the script used for the different categories of data translations contained in a map file: Simple Mapping: write (search (case.membeπCompanyName), "s30"); write (search (case.membeπSubscriberNumber), "s9"); write (search (case.application: Deposit), "s10"); write (search (case.application:SubjectToErisa), "s1"); write (search (case:CaselnstallationlD), "s20"); Use of Constants: write (" ", "s5"); write ("00000", "s5"); write ("H", "s1"); write ("999999", "s6"); write ("01", "s2"); Value Lookup: table trans able { "1", "0"; // None "2", "1"; // Life "3", "3"; // Health "4", "2"; // Both default, "*"; }; string sval, Ival; sval = search (case.caseinstallation:RetiredCoverageType); Ival = lookup (trans_table, sval); write (Ival, "s1"); release (trans_table); Derived Values: if (search (case:PriorEffectiveDateCoverage) == "") sval = "N"; else sval = "Y"; write (sval, "s1"); Occurrences: int i, j; i = count (case. member); while (j <= i) { write (search (case.member(j):City), "s15"); write (search (case.member(j):State), "s2"); j = j + 1 ; } Other Operations: //specialrule7 is defined in the Business Ruler class write (ruler (specialrule7)), "s30"); i = stringlength (sval); Ival = midstring (sval, pos, length); i = tointeger (sval); The data from hierarchical information system may be sent to the interface from a specific vendor's server, where the vendor may be the same or different from the owner or user of the legacy system. Furthermore, multiple vendors, each having one or more servers, each containing data in one or more hierarchical systems, may send data to the interface. The interface may translate the data into a non-hierarchical system, such as a legacy system, or a different hierarchical system. Examples of hierarchical systems include XML and ChannelPoint (CP XML). Specifically, the interface may carry out one or more of the following: Retrieve values (data) from Vendor object model, using the Vendor toolkit (note: this model is not static between invocations). Concurrently support a different, dynamic map file for each legacy system output format. Support simultaneous access from server components. A toolkit is used to interpret the hierarchical system data exported from a server to the interface. Each toolkit may be specific to each hierarchical system, for example the MICROSOFT XML toolkit is specific to XML. On receipt of the exported hierarchical system data stream, the toolkit creates a copy of the original object (or objects). Data is then read out of this object (or objects) for translation into a custom legacy message. The present invention interface has a number of advantages: Adaptability to different legacy systems, including future systems. Extensibility to other applications requiring access to legacy systems. Maintainability and streamlined operational capability. Scalability to handle production-level volume requirements. Performance requirements to support multiple servers, using multiple Vendors. Re-usability to reduce complexity and implementation timeline. It is to be understood that a wide range of changes and modifications to the embodiments described above will be apparent to those skilled in the art and are contemplated. It is therefore intended that the foregoing detailed description be regarded as illustrative, rather than limiting, and that it be understood that it is the following claims, including all equivalents, that are intended to define the spirit and scope of the invention. package com.uhc . iframework. runtime .mapping; import com.uhc. iframework. FailureCodes import com.uhc . iframework. runtime.configuration.ConfigurationManager.- i port com.uhc . iframework. runtime . queuing . QInfo; import com.uhc . iframework. runtime .queuing.QueuingController; import com.uhc. iframework. runtime.utility.basic.Para Getter; import com. uhc. iframework. run ime. utility. logging.LogController; import Java . io . FileNotFoundException; import Java. io.IOException; ** This class is instantiated upon a Vendor call to <code>CaseInstallation: : installCase ( .. ) , Caselnstallation: : installGroup ( .. ) , or Caselnstallation: : installMembers ( .. )</code>. First, a Searcher object is created that will be used to browse the Vendor object model. Next, a Writer object is created that will construct the translated message for the target legacy system. Next, a static MapLoader object is used to load and parse the appropriate map file that contains the legacy system translation. Finally, a VInterpreter object (Visitor) is created to perform that actual interpretation of the loaded map file. <p> Called operations: <code> <ul> <li>Conf igurationManager : : getlnstance ( ) <li>Conf igurationManager : : getParameter ( . . ) <li>MapLoader : : getlnstance ( ) <li>MapI_oader : : getMap ( . . ) <li>LogController : : getlnstance ( ) <li>LogController : : log ( . . ) <li>Queuing: : getlnstance ( ) <li>Queuing : : getQInfo ( . . ) <li>Searcher : : Searcher ( . . ) <li>Searcher : : getTargetSystem ( . . ) <li>VInterpreter : : VInterpreter ( ) <li>Writer : : riter ( . . ) </ul> </code> Θdate 1 July 1998 ©version 2 . 0 Θauthor Andersen Consulting - Copyright 1998 */ public class Coordinator { /** Searcher */ private Searcher m_searcher = null; /** Writer */ private Writer m__writer = null; /** Ruler */ private Ruler m_ruler = null; /** Root node of the Abstract Syntax Tree generated by Map Loader. */ private SimpleNode m_ASTroot = null; /** Fully-qualified file name of the map used to build the Abstract Syntax Tree . */ private String m_filename = null; /** LogController used for logging messages. */ private LogController m_logger = LogController. getlnstance () ; /** Constructor. First, a flavor of the Searcher class is instantiated based on whether the "UHCSearcher" switch has been set, either on the command-line or within the configuration INI file. If the switch has been set to 'on', a UHCSearcher object is instantiated; otherwise, a CPSearcher object is instantiated. Through the searcher object, the target legacy system is determined. That value is used to retrieve information on the appropriate queue to which the legacy system message will eventually be written. Using the queue information and the string array passed into the Coordinator constructor as a parameter, the fully-formatted header of the legacy message is constructed and passed as a parameter to a new instantiation of a Writer object. Next, a Ruler object is instantiated, receiving a reference to the searcher object as a parameter. Finally, based on the target legacy system, the appropriate map filename that will be used for message translation is retrieved from ConfigurationManager. dpararn xmlDoc_bytes XML document that will be passed to the searcher. Θparam header Header used for response message forwarding, dparairt Exception Exception is thrown if a SearchException or Throwable is encountered on an attempt to instantiate the searcher object or determine the target legacy system. An Exception is also thrown if a FormatException is encountered during construction of the legacy system message header, if a WriterException is encountered on an attempt to instantiate the Writer object, or a Throwable is encountered through any of the Coordinator constructor's functionality. */ public Coordinator (byte [ ] xmlDoc_bytes, String [] headerlnfo) throws Exception { m_logger. log ( "Entering Coordinator: :Coordinator ( IF Searcher) " , ogController.BENCHMARK3) ; Byte targetSystem = null; // Create searcher try { boolean uhcSearcher = ParamGetter. trueValue( ConfigurationManager. getlnstance ( ) . getParameter (ConfigurationManager.UHC_S EARCHΞR) ) ; if (uhcSearcher) { m_logger . log( "UHC Searcher is being implemented by this IF session" , LogController.DEBUG3) ; m_searcher = new UHCSearcher (xmlDoc_bytes) ; } else m_searc er = new CPSearcher ( xmlDoc_bytes ) ; m_logger . log ( " Searcher successfully instantiated" , LogController . DEBUG3 ) ; } catch ( SearchException e ) { m_logger . log(e, LogController.ERROR3 ) ; m_logger. log ( " eaving Coordinator: :Coordinator (IF Searcher) " , LogController .BENCHMARK3) ; throw new Exception (e. getMessage ()) ; } catch (IllegalArgumentException ex) { m_logger. log (ex, LogController. ERR0R3 ) ; m_logger. log ( "Leaving Coordinator: Coordinator(IF Searcher) " , LogController. BENCHMARKS) ; throw new Exception (FailureCodes .getFailureCode (FailureCodes.MAJOR_RECOVERABLE) + ex . getMessage ( ) ) ; } catch ( Throwable t ) { m_logger. log ( t , LogController. ERROR3 ) ; m_logger. log ( "Leaving Coordinator: Coordinator (IF Searcher) " , LogController .BENCHMARK3) ; throw new Exception ( t . getMessage ( ) ) ; } // Create Writer try { targetSystem = m_searcher .getTargetSystem( ) ,- // Build message header from (String.] Jheaderlnfo using Formatter ob ect Qlnfo qHeader = null; if (targetSystem. equals (Searcher. PRIME_RETVAL) ) qHeader = QueuingController . getlnstance ( ) . getQHeaderlnfo (QueuingController. PRIME) ; else if (targetSystem. equals (Searcher.C0SM0S_RETVAL) ) qHeader = QueuingController.getlnstance ( ) .getQHeaderlnfo (QueuingController.COSMOS) ; else { m_logger. log ( "Coordinator could not get a valid target system from Searcher", LogController . ERR0R3 ) ; throw new Exception ( "Coordinator could not get a valid target system from searcher"); } Formatter f = new Formatter () ; String header = f . forma (headerlnfo [0] , "41s" ) + // Transaction ID f .format (headerlnfo [1] , "40s") + // Interface Name f .format (headerlnfo [2] , "40s") + // API Server Name f . format (headerlnfo [3] , "5s" ) + // OSAgent Port f. format (headerlnfo [4] , "32s" ) + // OSAgent Host f .format (qHeader. getPrimaryQMgr (), "48s" ) + // Primary Q Mgr f . forma (qHeader .getPrimaryQ ( ) , "48s" ) + // Primary Q f . format (qHeader. getSecondaryQMgr (), "48s" ) +// Secondary Q Mgr f.format (qHeader. getSecondaryQ ( ) , "48s" ) + // Secondary Q f .formatC" , "450s") ; // Filler // Create the writer object m_writer = new Writer (targetSystem, header) ; m_logger . log ( "Writer success ully instantiated" , LogController .DEBUG3) ; } catch (SearchException e) { m_logger . log (e, ogController . ERROR3 ) ; m_logger. log ( "Leaving Coordinator: Coordinator (IF Searcher) ", ogController .BENCHMARK3 ) ; throw new Exception ( e. getMessage ( ) ); } catch (FormatException ex) { m_logger. log (e , LogController . ERR0R3 ) ; m_logger. log ( "Leaving Coordinator: Coordinator (IF Searcher) " , LogController.BENCHMARKS) ; throw new Exception (ex. getMessage ()) ; } catch (WriterException ex) { m_logger . log (ex, LogController. ERROR3) ; m_logger . log ( "Leaving Coordinator : :Coordinator (IF Searcher) " , LogController. BENCHMARK3) ; throw new Exception (ex. getMessage ()) ; } catch ( Throwable t ) { m_logger . log ( t , LogController . ERROR3 ) ; m_logger . log ( "Leaving Coordinator : : Coordinator (IF Searcher) " , LogController.BENCHMARK3 ) ; throw new Exception (t .getMessage ()) ; } // Create Ruler m_ruler = new Ruler (m_searcher) ,• m_logger. log ( "Ruler successfully instantiated" , ogController. DEBUG3) ; / / MapLoader m_filename = ConfigurationManager .getlnstance ( ) .getParameter (targetSystem) ; if (m_filename == null) { m_logger . log ( "A map file name was not returned by ConfigurationManager : : getParameter for " + "the target system specified in the XML (" + headerlnfo [0] + ")", LogController .ERROR3 ) ; throw new Exception (FailureCodes .getFailureCode (FailureCodes . AJOR_RECOVERABLE) + "No map file for target system specified in XML (" + headerlnfo [0] + ")"); } m_filename = m_filena e. toStringt ) .replace ('/',' \\ ') ; m_logger.log( "Coordinator successfully instantiated" , LogController .DEBUG3 ) ; m_logger. log ( "Leaving Coordinator: Coordinator (IF Searcher) " , LogController .BENCHMARK3) ; } Performs the interpretation of the map file to construct the legacy system message. A value for the max number of interpretation errors allowed is retrieved from ConfigurationManager . If the max value has not been set, the default contained by VisitorException is used. A VInterpreter visitor object is instantiated with the filename of the map file being used for interpretation, references to the searcher, writer, and ruler objects, and a value for the max number of interpretation errors allowed passed in as parameters. The root node of the AST constructed from the map file is retrieved from the MapLoader object. The root node receives the visitor object and the legacy system message is constructed. If interpretation was completely successful, the legacy system message is deposited on the appropriate outgoing queue via the writer object. ©exception Exception Exception is thrown if a VisitorException is encountered during the visitor object's traversal of the AST. Exception is also thrown if a Throwable is encountered within the method. */ public void run ( ) throws Exception { m_logger. log ( "Entering Coordinator: : run" , LogController. BENCHMARK3 ) ; String val = ConfigurationManager. getlnstance () .getParameter (ConfigurationManager. AX_ERRORS) int maxErrors = 0; try { maxErrors = Integer. arselnt (val) ; } catch (NumberFormatException ex) {} try { VInterpreter vi = null; vi = new VInterpreter (m_filename,m_searcher,m_writer,m_ruler,maxErrors) ; // vi = new VInterpreter (m_filename, ull,m_writer,m_ruler,maxErrors) ; m_logger. log ( "Coordinator :: run getting map (astRoot) from MapLoader" , LogController .BENCHMARK4) ; m_ASTroot = (MapLoader.getlnstance ()) .getMap (m_filename) ; if (m_ASTroot != null) m_logger.log ("Root AST node successfully received from MapLoader" , ogController. DEBUG3) ; else { m_logger. log ( "Root AST node received from MapLoader is null ! " , ogController . ERR0R3 ) ; throw new Exception ( "AST Root from MapLoader is null"); } m_logger .log ( "Coordinator :: run map file interpretation BEGIN" , ogController. BENCHMARK3) ; m_ASTroot . j tAccept ( vi, null ) ; m_logger. log ( "Coordinator:: run map file interpretation END" , LogController . BENCHMARK3 ) ; m_logger. log ( "VInterpreter was accepted by the AST" , ogController . DEBUG3 ) ; if (m_writer . sendMsg( ) ) m_logger. log ( "Legacy message was successfully placed on queue" , ogController. DEBUG3 ) ; else m_logger. log ( "Legacy message could not be placed on queue" , LogController .DEBUG3) ; } catch (VisitorException e) { m_logger.log (e. getDetailMessages () , LogController . ERR0R3 ); // multiple messages m_logger. log ( "Leaving Coordinator: : run" , LogController. BENCHMARK3) ; throw new Exception ( e. getDetailMessages () ) ; } catch (Exception e) { m_logger.log( e, LogController . ERR0R3 ); m_logger.log ("Leaving Coordinator: :run" , LogController. BENCHMARK3) ; throw new Exception ( e. getMessage ( ) ) ,- } catch (Throwable t) ( m_logger.log( t, LogController .ERR0R3 ) ; m_logger. log ( "Leaving Coordinator: -.run" , LogController.BENCHMARK3) ; throw new Exception ( t .getMessage ( ) ) ; } m_logger. log ( "Leaving Coordinator: : run", LogController.BENCHMARK3) ; } Default constructor. This constructor should never be called and is therefore private. */ private Coordinator ( ) {} // should never be called /** This method performs finalization on the Coordinator Object */ public void finalize () { m_logger. log ( "Coordinator is about to get garbage collected.", LogController. DEBUG3) ; } } package com. uhc . iframework. runti e .mapping; import com.uhc . iframewor . runtime .utility. logging . LogController; import vendor.util .AttributeDescription; import vendor .util .AttributeContainer; import vendor .util.CPDate; import vendor.util PException; import vendor.util .Money; import vendor. util .Types; import vendor.xml .XMLload; import java.io.FilelnputStream; import java.util . Enumeration; import java. util.Hashtable; import Java.util. StringTokenizer; import java.util .Vector; / ** This class is an implementation of the abstract Searcher class. It performs searches of the Vendor object model (as defined by the XML document passed to the constructor) through utilization of the Vendor Toolkit. <p> Called operations: <code> <ul> <li>LogController : : log ( .'. ) <li>XMLload: : getRootObject ( ) <li>XMLLoad: :getA110bjects ( ) <li>XMLObject: :getAttributeDescriptions () <li>AttributeDescription: :getType ( ) <li>AttributeDescription : : getName ( ) <li>AttributeContainer: :getAttributeNames ( ) </ul> </code> ©date 23 June 1998 ©version 2.0 ©author Andersen Consulting - Copyright 1998 */ public class CPSearcher extends Searcher { /** Root objects of the Vendor object model as defined by the XML document. */ private Vector _rootObjects = null; /** Reference to the Vendor object model container object. */ private XMLload _xmlin = null; /** Reference to an AttributeContainer object within the Vendor object model. */ private AttributeContainer _currAC = null; /** Cache of Vendor object model branches previously walked. This cache is used to provide faster access to elements at the end of branches that have already been traversed. */ private Kashtable _cache = new Hashtable () ; // could tune the initial capacity and load factor Constructor. Calls the <code>initialize ( ) </code> method, passing as parameters option 0, the XML byte array, and a null file input stream object. ©param XML XML document that the searcher will search during subsequent requests, ©exception SearchException */ public CPSearcher( byte[] XML ) throws SearchException { initialize ( 0, XML, null ) ; } //$DEBUG_START // This ctor is for testing only ! ! ! public CPSearcher( int option, byte[] XML, FilelnputStream fis ) throws SearchException { initialize) option, XML, fis ) ; } //$DEBUG_END A byte array representing an XML document is converted to a String and then parsed by the Vendor toolkit, resulting in a Vendor object model. The reference to the object model's root objects is set. ©param option Debugging option. <i>Not implemented.</i> ©param XML Byte array representing an XML document . ©param fis Debugging file stream. <i>Not implemented. </i> ©exception SearchException SearchException is thrown if byte array is null or if a CPExcetion or Throwable was caught during the parsing and construction of the object model . */ private void initialize ( int option, byte[] XML, FilelnputStream fis ) throws SearchException { m__logger. log ( "Entering Searcher: : initialize" , LogController . BENCHMARK3 ) ; if (XML == null) { m__logger . log ( " Searcher: .- initialize ( ) received null XML array" , LogController . ERR0R3 ) ; m_logger . log ( "Leaving Searcher : initialize " , ogController. BENCHMARK3 ) ; throw new SearchException ( " Initialize ( ) received null XML array" ) ; try { m_logger. log ( "Searcher is loading XML document of size " + XML. length + " bytes" , LogController .BENCHMARKS) ; // Performance testing long loadStart = System. currentTimeMillis () ; switch (option) { case 0: _xmlin = new XMLload ( new String ( XML ) ) ; // Some time is spent here building the String break; //$DEBUG_START case 1.- _xmlin = new XMLload ( new FilelnputStream ( " L : \ \Testing\\source\ \com\ \uhc\\if WmappingWcase .2 . xml " ) ) ; / /fis ) ; break ,- / /$DEBUG_END default : throw new SearchException ( "Bad ctor option."); } _rootObjects = _xmlin.getRootObjects ( ) ; // It would be nice of XMLload took a byte[]. long loadEnd = System. currentTimeMillis () ; m_logger.log( "XML loading time ( s) : " + (loadEnd - loadStart), LogController. BENCHMARK3) ; m_logger.log( "XML document loaded successfully by Searcher. " , LogController.DEBUG3) ; } catch ( CPException e ) { m_logger .log ( "Searcher: : initialize ( ) caught Vendor exception: " + e . getMessage ( ) , LogController.ERR0R3) ; m_logger . log (e, LogController.ERR0R3 ) ; m_logger. log ( "Leaving Searcher: initialize" , LogController .BENCHMARK3) ; throw new SearchException (e) ; } catch ( Exception e ) { m_logger. log ( "Searcher: : initialize () caught general exception: " + e . getMessage ( ) , LogController. ERROR3 ) ; m_logger. log (e, LogController .ERR0R3 ) ; m_logger. log ( "Leaving Searcher: : initialize" , LogController .BENCHMARK3) ,- throw new SearchException ( "A general exception was caught: Description: "+e. toString( ) + " Message: " + e.getMessage ( ) ) • } catch ( Throwable t ) { m_logger. log ( "Searcher: : initialize () caught throwable: " + t .getMessage ( ) , LogController. ERR0R3) ; m_logger. log ( t, LogController. ERR0R3 ) ; m_logger . log ( "Leaving Searcher: initialize" , ogController.BENCHMARK3 ) ; throw new SearchException ( "A throwable was caught: Description: "+t.toString( ) + " Message: " + t .getMessage ()) ; } m_logger . log ( " Leaving Searcher : initialize" , LogController . BENCHMARK3 ) ; } / * * Searches the Vendor object model for the target legacy system and returns the result as a Byte object. The valid return values are defined in the parent class. ©return Constant representing target legacy system. ©exception SearchException SearchException is thrown if a valid target system value could not be found within the object model. */ public Byte getTargetSyste f ) throws SearchException { m_logger. log ( "Entering Searcher: .-getTargetSystem" , LogController.BENCHMARK3) ; String omLocation = "vendor/xml/XMLMessageHeader :messageType" ; m_logger. log ( "Searching for target system in (" + omLocation + ")", LogController. DEBUG3) ; String target = findAttribute (omLocation) ; if ( target. compareTo (PRIME_TARGET_SYSTEM) == 0 ) { m_logger.log ("Target system is PRIME" , LogController .DEBUG3) ; m_logger. log( "Leaving Searcher: :getTargetSystem" , LogController. BENCHMARK3 ) ; return PRIME_RETVAL; } else if ( target .compareTo (COSMOS_TARGET_SYSTEM) == 0 ) { m_logger.log ("Target system is COSMOS" , ogController.DEBUG3) ; m_logger. log ( "Leaving Searcher: :getTargetSystem" ,LogController .BENCHMARK3) ; return COSMOS_RETVAL; } else { m_logger. log( "Leaving Searcher: :getTargetSystem" , LogController. BENCHMARK3) ; throw new SearchException ( "No valid target system found."); } } //$DEBUG_START // This method is for debugging only i ! public String findAttribute (String str, int num ter) throws SearchException { String retStr = null; for (int i=0; i<numlter; i++) { retStr = findAttribute (str) ,- } return retStr; } //$DEBUG_END Obtains the collection's total number of elements. If the collection hasn't been previously obtained the collection is obtained and the total number of element is obtained from the newly obtained collection. ©param collection The collection from which to obtain the total number of elements, ©exception Exception Thrown if the collection wasn't found in the Vendor object model. */ public String getCollectionCount ( String fqCollection ) throws SearchException { return this . findAttribute (fqCollection) ,- } Gets the attribute of an element in the Vendor object model. First, the cache is checked to see if an <code>AttributeContainer</code> object exists for the given object path. If so, the object is retrieved and the value from its <code>AttributeDescription</code> is returned. Otherwise, the object path is tokenized on the period (.) character. Each token is checked to see if it is an occurrence. If it is an indexed occurrence, the number of <code>AttributeContainers<code> in the collection is returned. For a non- indexed occurrence, the i Λ th <code>AttributeContainer</code> is set to the current node. Otherwise, the reference value contained within the current node (<code>AttributeContainer</code>) is set to the current node . Once the object path has been tokenized, the value of the <code>AttributeDescription</code> contained in the current <code>AttributeContainer</code> is returned. ©param fqAttributeStr The fully-qualified attribute for which to search the Vendor object model. This attribute can be in one of the two following forms : <ul> <li>Fully-qualified single attribute (outside of a collection) <p> For example: "Case. Plan: PlanID" , where "Case. Plan" is the "path" to the "PlanID" element of the Vendor object model. <li>Fully-qualified single attribute (within a collection) <p> For example : "Case.Member [n] :LastName", where <ul> <li>"Case.Member" is the collection. <li>'n' is the element number in the collection to reference. <li>"LastName" is the attribute to obtain (for the nth element of the collection) in the Vendor object model. </ul> <p> Nested collections would look like "Case.Member [n] .Dependant [n ' ] .Age" </ul> <p> NOTE: This method does not support returning multiple attribute values. <p> ©return The value (as a string) of the found element, ©exception Exception Thrown if the attribute wasn't found in the Vendor object model. */ public String findAttribute (String fqAttributeStr) throws SearchException { m_logger . log ( "Entering Searcher: : findAttribute" , LogController .BENCHMARK3) ; if (fqAttributeStr == null) { m_logger . log ( " Searcher: : findAttribute ( ) received a null search string" , LogController .ERROR3) ; m_logger. log ( "Leaving Searcher: : findAttribute" , LogController.BENCHMARK3) ; throw new SearchException ( "The search string passed is null."); } if (fqAttributeStr. trim( ) .length ( ) == 0) // make sure we have a string { m_logger. log ( "Searcher :: findAttribute ( ) received an empty string" , LogController .ERROR3 ) ; m_logger . log ( "Leaving Searcher: : findAttribute" , LogController .BENCHMARK3) ; throw new SearchExceptio ( "The search string passed is empty.") ,- } _currAC = null; String attributeName = null; try { // seperate the root class name & member vars from the attribute StringTokenizer attribST = new StringTokenizer (fqAttributeStr, ":" ) String allClasses = attribST.nextToken () ; // not really classes, but rather // the root class then member vars m_logger. log ( "Searcher is about to travel object path: " + allClasses , LogController . DEBUG3 ) ; if ( attribST. countTokens ( ) > 0 ) // if we have an attribute { attributeName = attribST.nextToken( ) ,- // the attribute for which we want // a value m_logger .log ( "Searcher is looking for attribute: " + attributeName , LogController . DEBUG3 ) ; // Look in cache for the AttributeContainer _currAC = (AttributeContainer)_cache. get (allClasses) ,- if (_currAC != null) { " // found AttributeContainer in cache, return its value m_logger. log ( "Searcher found attribute container " + allClasses + " in cache !" , ogController .DEBUG3 ) ; m_logger. log ( "Leaving Searcher: : findAttribute" , LogController.BENCHMARK3 ) ; return getStringValue (attributeName) ; } } else // we might (should) have an empty occurrence - we're looking for the count ( m_logger . log ( " Searcher is looking for occurrence : " + allClasses , LogController.DEBUG3 ) ; // Look in cache for the AttributeContainer // _currAC = (AttributeContainer) _cache .get (allClasses) ; Vector v = (Vector) _cache. get (allClasses) ; // if (_currAC != null) if (v != null) { // found AttributeContainer in cache, return its value // int num = ( (Vector) _currAC) . size () ; // JAY int num = v.size(); m_logger. log ( "Searcher found occurrence " + allClasses + " in cache!. Size: " +num, LogController .DEBUG3) ; m_logger. log ( "Leaving Searcher: : findAttribute" , LogController. BENCHMARK3 ) ,- return (new Integer (num) ) . toString() ; ; } } // AttributeContainer not found in cache ... // seperate the root class name and member vars from each other StringTokenizer classesST = new StringTokenizer (allClasses, ".") ; while ( classesST. hasMoreTokens ( ) ) { // get the next token String currClassName = classesST.nextToken () ,- // look for class in Vendor Object Model if ( _currAC == null ) { // we're just beginning to look - we haven't found an AttributeContainer yet for (int i=0; i < _rootObjects . size ( ) ; i++ ) { // look for class name // ASSUME no occurance of the first class - it has to be a class name ! ! String clName = ( (AttributeContainer) (_rootObjects.elementAt (i) ) ) .getClassName () ; if ( currClassName. <_:ompareTo(clName) == 0 ) // if what we found matches what { // we're looking for m_logger. log ( "Searcher found root class: " + currClassName, LogController .DEBUG3) ; _currAC = (AttributeContainer)_rootObjects.elementAt (i) ; // we now have break,- // the next branch } } if ( _currAC == null ) // if I couldn't find the root class, bug out { m_logger. log ( "Search could not find root class: " + currClassName, LogController. ERR0R3) ; m_logger . log ( "Leaving Searcher: : findAttribute" , LogController .BENCHMARK3) ; throw new SearchException ( "Unable to locate the root class: "+currClassName) ; } } else // we've already found at least one AttributeContainer { // check for an occurance of this AttributeContainer StringTokenizer occurTokens = new StringTokenizer ( currClassName, "[" ) ,- // NOTE: this allows "mem] n] " , etc . I l l should be getting a well formed string, so it shouldn't matter. // I'm not going to pay the overhead to check this. if ( occurTokens . countTokens ( ) > 1 ) { // we have an occurance, or a count request // the first token is the member variable name; the second, the index of the // occurance to obtain (with the close bracket) or just the close bracket (to get count) String occurrenceName = occurTokens .nextToken () ; m_logger. log ( "Searcher is browsing occurrence: " + occurrenceName, LogController. DEBUG3 ) ; Vector v = (Vector) _currAC . getAttribute ( occurrenceName ) ; // Vector of member variables String nextToken = occurTokens .nextToken () ; if ( nextToken . compareTo ( " ] " ) == 0 ) 1 no index passed - we are after the ' size ' of the set (count ) { m_logger. log ( "Putting occurrence "+allClasses+" in cache", LogController .DEBUG3) ; // _cache. ut (allClasses,_currAC) ; // put found AttributeContainer TREE PATH in cache _cache. ut (allClasses,v) ; // put found AttributeContainer TREE PATH in cache String count = (new Integer (v. size ())) .toString( ) ; m__logger . log (" Searcher found size of occurrence: " + occurrenceName + ", Size: "+count, LogController.DEBUG3) ; m_logger. log( "Leaving Searcher: : findAttribute" , LogController.BENCHMARK3) ; return count; } else // indexed occurrence C String index = nextToken.substring (0 , nextToken. length( ) -1) ; // strip off the ']' AttributeDescription ad = null; try { ad = _currAC . getAttributeDescription (occurrenceName) ; } catch ( CPException e ) { m_logger . log ( "Leaving Searcher: : findAttribute" , ogController.BENCHMARK3 ) ; throw new SearchException ( "Can' t get attribute description for: "+occurrenceName+" , CPException: " +e. getMessage ()) ; } // validate the type if ( ad == null ) throw new SearchException ( "attribute description for: "+occurrenceName+" is null"); switch( ad.getType() ) // it had better be a SET_OF_OBJECT ... { case Types . SET_OF_OBJECT: case Types. ANY_TO_MANY: break,- default: throw new SearchException! "The token <" +occurrenceName+"> is not an occurrence. "+ "It's of type: " + Types . typeString (ad. getType ())),- } _currAC = (AttributeContainer) v. elementAt ( (new Integer (index) ). intValue ( ) ); } ) else { m_logger. log ( "Searcher is getting an attribute description from: " + currClassName, LogController.DEBUG3) ; // no occurrence // the className (currClass) should now be a Reference (or Indirect Reference) type // member var on the currObject AttributeDescription ad = _currAC.getAttributeDescription (currClassName) ; // validate the type switch ( ad.getTypeO ) // it had better be a REFERENCE or INDIRECT_REF ... { case Types . REFERENCE: case Types . INDIRECT_REF : case Types . SET_MEMBER: case Types . IREF_SET_MEMBER: _currAC = (AttributeContainer) (_currAC .getAttribute (currClassName) ) ; break; default: { m_logger . log ( "Leaving Searcher: : findAttribute" , LogController .BENCHMARK3 ) ; throw new SearchException ( currClassName+" is not a Reference. It's of type: "+ Types. typeString(ad. getTypef ) ) ) ; } } } } } _cache. ut (allClasses, _currAC) ; // put found AttributeContainer TREE PATH in cache //$DEBUG_START // System. out .println( "Value: " + value); //$DEBUG_END m_logger. log( "Leaving Searcher: : findAttribute" , ogController. BENCHMARK3 ) ; return getStringValue (attributeName) ; } catch ( CPException e ) { m_logger . log (e, LogController. ERR0R3 ) ; m_logger . log ( "Leaving Searcher: : findAttribute" , ogController. BENCHMARK3 ) ; throw new SearchException (e) ,- catch ( Throwable t ) { m_logger. log (t , LogController . ERROR3 ) ; m_logger. log ( " eaving Searcher: : findAttribute" , LogController.BENCHMARK3 ) ; throw new SearchException ( t. getMessage () ); } } ** Returns a string representation of a Vendor object model attribute's value . The <code>AttributeDescription</code> object is retrived from the current <code>AttributeDescription</code> object. Based on the type of the description object, its value is converted to a string (if necessary) and returned as a string. ©param attribName Name of the attribute contained within the Vendor object model. ©return Returns a string representation of a Vendor object model attribute's value. */ private String getStringValue (String attribName) throws SearchException { try { // get AttributeDescription - so I know what type it is so I can cast, etc. AttributeDescription ad = _currAC . getAttributeDescription (attribName) ; Object attribVal = null; //get value switch ( ad.getTypeO ) { case Types . STRING: attribVal = _currAC. getAttribute (attribName) ; return (attribVal == null ? "" : (String) attribVal) ; // case Types. LONG: // CP SDK ERROR? - duplicate id for LONG type (same as for INTERGER) - works, but ugly, case Types. INTEGER: case Types.DOUBLE: case Types. BOOLEAN: attribVal = _currAC. getAttribute (attribName) ; return (attribVal == null ? "" : attribVal . toString( )) ; case Types.DATE: attribVal = _currAC. getAttribute (attribName) ; return (attribVal == null? "" : ( (CPDate) attribVal) .toStringO ) ,- case Types.MONEY: attribVal = _currAC. getAttribute (attribName) ; return (attribVal == null ? " " : ( (Money) attribVal) .toString ) ; case Types. BLOB: case Types.REFERENCE: case Types . INDIRECT_REF : case Types . SET_OF_OBJEC : case Types .MANY_TO_MANY: case Types. SET_MEMBER: case Types.CLASS: case Types . SEQUENCE: case Types. ENUMERATION: case Types . IREF_SET_MEMBER: case Types .NOTYPE : throw new SearchException (attribName + " is of type "+Types. typeString(ad.getTypeO )+" - cannot convert to a String."); default: throw new SearchException ( "No type found (default:) for the " + attribName + " attribute."); } } catch ( CPException e ) { throw new SearchException (e) ; } } package com . uhc . i framewor . runtime . mapping ; / ** Class represents an exception thrown by the Formatter class. <p> Called operations: <code> <ul> <li>None </ul> </code> ©date 1 July 1998 ©version 2.0 ©author Andersen Consulting - Copyright 1998 */ public class FormatException extends Exception { /** Constructor. ©param detailMessage Reason for FormatException. */ public FormatException ( String detailMessage ) { super ( detailMessage ) ; } / ** Default constructor. */ private FormatException 0 {} package com.uhc. iframework. runtime.mapping; import com.uhc. iframework. runtime.utility. logging. ogController; import Java.util . StringTokenizer; /** This class takes the value and the format type of an attribute and returns a formatted string. The definition for the format specifier is as follows: <P> C + " I « _")? ( (<integer> "." <precision> ("f" | "F")) | (<width> (("s" | "S") | ("d" j "D") I ("n" I "N")))) <P> Specifier syntax:<br> <ul> <li><b>"+"</b> Right justification. Only used for string types. Ignored for all other types. </li> <li><b>"-"</b> Left justification (Default). Only used for string types. Ignored for all other types.</li> <li><b>&ltinteger&gt</b> Number of digits on integer side for float type.</li> <li><b>&ltprecision&gt</b> Number of digits on decimal side for float type.</li> <li><b>&ltwidth&gt</b> Number of characters or digits for string or integer types, respectively.</li> <li><b>f/F</b> Float type value specifier.</li> <li><b>s</b> String type value specifier. Character case is not modified.</li> <li><b>S</b> String type value specifier. All characters are forced to upper-case.</li> <li><b>d/D</b> Integer type value specifier.</li> <li><b>n</b> Non-padded string type value specifier. Character case is not modified. </li> <li><b>N</b> Non-padded string type value specifier. All characters are forced to upper-case. </li> </ul> <p> Examples : <br> <ul> <li><code>"10s"</code> - Left justified, 10 character string, (i.e. "Hello! ")</li> <li><code>"+8S"</code> - Right justified, 8 character string with forced uppercase, (i.e. "world!" becomes " WORLD! ") </li> <li><code>"3.2f "</code> - Float with 2 digit precision, (i.e. "1.5" becomes "001.50" )</li> <li><code>"5d"</code> - 5 digit integer, (i.e "15" becomes "00015" ) </li> </ul> <p> String type values are padded with spaces and numerical type values (i.e. float and integer) are padded with zeros. Non-padded string type values (i.e. "n") are not padded at all, regardless of the &ltwidth&gt specifier. <p> Called operations: <code> <ul> <li>None </ul> </code> ©date 1 July 1998 ©version 2.0 ©author Andersen Consulting - Copyright 1998 */ public class Formatter { /** Format specifier for string. */ private static final char _STRING = ' s ' ; /** Format specifier for integer. */ private static final char _INTEGER = 'd'; /** Format specifier for float. */ private static final char _FLOAT = ' f ' ; /** Format specifier indicating no padding. */ private static final char _NOPAD = 'n'; /** Format specifier for right justification. */ private static final char _RIGHT_JUSTIFY = ' + ' ; /** Format specifier for left justification (default) . */ private static final char _LEFT_JUSTIFY = ' - ' ; /** Pad character for strings. */ private static final String STRING_PADCHAR = " " ; /** Pad character for integers and floats. */ private static final String NUMBER_PADCHAR = "0"; /** Format type. */ private char m_type = _NO AD; /** Width of string, integer, or integer portion of float. */ private int m_width = 0; /** Precision of float. */ private int m_precision = 0; /** Justification of string. */ private char m_justify = _LEFT_JUSTIFY; /** Flag to force all letters to uppercase. */ private boolean m_uppercase = false; ** Constructor. Returns a Formatter object. */ public Formatter () {} This method formats the attribute as defined by format specifier. <code>validateFormatStructure ( ) </code> is called to parse the specifier and set the formatting flags appropriately. Then, depending on the value type, either <code>formatString ( ) </code>, <code>formatlnteger ( )</code>, <code>formatFloat ( ) </code>, or <code>formatNoPad( ) </code> is called with the string value as a parameter. ©param aValue A string value to be formatted ©param aFormat The format specifier ©return The formatted string ©exception FormatException if value or specifier is null, if the specifier is empty, or if the the value could not be formatted according to the contents of the specifier. */ public String format (String aValue, String aFormat) throws FormatException { // validate value and format specifier not null if (aValue == null) throw new FormatException ( "Invalid Format: value is null"); if (aFormat == null) throw new FormatException) "Invalid Format: format specifier is null") ; // validate format specifier not empty strings. It is okay for the value to be empty string if (aFormat .trim0. length ( ) == 0) throw new FormatException ( "Invalid Format: format specifier is empty" ) ; // Init formatter according to format specifier validateFormatStructure (aFormat . trim ( ) ) ; // Format the value if ( m_type == _STRING ) return formatString (aValue . trim( ) ) ; else if ( m_type == _INTEGER ) return formatlnteger (aValue . trim( ) ) ; else if ( m_type == _FL0AT ) return formatFloat (aValue . trim 0 ) ; else if (m_type == _NOPAD) return formatNoPad (aValue. trim( ) ) ; else throw new FormatException ( "Bad format specifier: " + aFormat) ,- } This method validates the format specifier. It verifies that the format complies with the format specification definition. Flags for value type, forced-uppercase, and justification are set. For string and integer types, the width value is set and for the float type, the width values of the integer and decimal sides are set. ©param fs Format specifier. ©exception FormatException if parameter cannot be parsed according to the format specifier definition. */ private void validateFormatStructure (String fs) throws FormatException { m_type = fs .charAt (fs. length ( ) - 1) ; // Check for force to upper case if (Character. isUpperCase (m_type) ) m_uppercase = true; else m_uppercase = false,- m_type = Character. toLowerCase (m_type) ; // Drop specifier char fs = fs. substring (0,fs. length () - 1) ,- if (fs.lengthO < 1) throw new FormatException ( "Invalid format specifier: " + m_type) // Justification if (fs.charAt(O) == '+' || fs.charAt(O) { if (fs.charAt(O) == '+') m_justify = _RIGHT_JUSTIFY; else m_justify = _LEFT_JUSTIFY; // Drop justification char fs = fs . substring (1) ; } switch (m_type) { case _INTEGER: case _STRING: case _NOPAD: m_width = getlntSpec (fs) ; break; case _FLOAT: StringTokenizer st = new StringTokenizer (fs, ".", false) ; if (st .countTokens () == 2) { m_width = getlntSpec (st .nextToken ( ) ) ; m_precision = getlntSpec (st .nextToken ( )) ; } else throw new FormatException ( "Invalid float precision: " + fs) break; default : throw new FormatException (" Invalid format specifier: must be ' s ' , ' d ' , ' f ' , ' n ' " ) ; } if (m_width < 0 | | m_precision < 0) throw new FormatException ( " Invalid format specifier : width or precision less than zero" ) ; } /** Obtains the integer value of the string parameter. ©param s String representing an integer, ©return Integer value of parameter. ©exception FormatException if the string does not represent an integer. */ private int getlntSpec (String s) throws FormatException { try { return Integer .parselnt (s) ; } catch (NumberFormatException ex) { throw new FormatException ( "Invalid integer value: " + s); } } This method formats a string type using the justification and width of the format specifier as set in <code>validateFormatStructure ( ) </code> . If the format specifier was set to force all letters to uppercase, the letter contents of the return value are all set to uppercase. ©param str A string to format ©return String The formatted string */ private String formatString (String str) { if (m_width == 0) return " " ; if (str. length ( ) > m_width) return (str. substring (0,m_width) ) ; else { while (str. length () < m_width) { str = ( (m_justify == _LEFT_JUΞTIFY) ? " " : STRING_PADCHAR) + str + ((m_justify == _LEFT_JUSTIFY) ? STRING_PADCHAR: " " ) ; } return (m_uppercase ? str . toUpperCase ( ) : str) ; } } This method formats an integer type using the width of the format specifier as set in <code>validateFormatStructure () </code>. If the string to format represents a negative number, the negative sign is not considered in width padding. ©param str . A string to format, ©return The formatted string. ©exception FormatException if string to format does not represent a valid integer value. */ private String formatlnteger (String str) throws FormatException { boolean isNegative = false; if (m_width == 0) return " " ; if (str. length () > 0) { if (str.charAt(O) == '-') { isNegative = true,- str = str. substring (1 ) ; } else if (str.charAt (0) == '+') { isNegative = false; str = str. substring (1) ; } } // Validate value representation if ( IvalidNumber (str) ) throw new FormatException ( "Invalid integer: " + str); .if (str. length ( ) > m_width) return (isNegative ? "_" : "") + (str. substring ( 0, m_width) ) ; else { while (str. length () < m_width) str = NUMBER_PADCHAR + str; return (isNegative ? » - « : » ") + str; } ** This method formats a float type using the width and precision of the format specifier as set in <code>validateFormatStructure ( ) </code>. If the string to format represents a negative number, the negative sign is not considered in width padding. ©param str A string to format, ©return The formatted string. ©exception FormatException if string to format does not represent a valid floating-point value. */ private String formatFloat (String str) throws FormatException { String slnt = null; String sDec = null; boolean isNegative = false; if (str. length () < 1) str = "0.0"; // Check for negative value if (str.charAt(O) == '-') { str = str . substring (1) ,- isNegative = true; } else if (str.charAt (0) == '+') { str = str. substring (1) ; isNegative = false; } StringTokenizer st = new StringTokenizer (str, ".", false) ; if (st .hasMoreTokens ( ) ) slnt = st.nextTokenO; else throw new FormatException (" Invalid float: " + str); if (st .hasMoreTokens ( ) ) sDec = st.nextTokenO; else sDec = " 0 " ; if ( ivalidNumber(slnt) || IvalidNumber (sDec) ) throw new FormatException ( "Invalid float: " + str) ; // Pad integer side while (slnt . length ( ) < m_width) slnt = "0" + slnt; // Pad decimal side while (sDec. length ( ) < m_precision) sDec = sDec + " 0 " ; if (m_width == 0) slnt = " " ; if (m_precision == 0) sDec = " " ; return (isNegative ? " - « : " •• ) + (slnt. length() > m_width ? slnt .substring (0,m_width) : slnt) + (m_precision == 0 ? " " : " . " ) + (m_precision == 0 ? "": (sDec. length () > m_precision ? sDec. substring (0,m_precision) :sDec) ) ; } ** This method formats the string and does not add any padding characters . If the format specifier was set to force all letters to uppercase, the letter contents of the return value are all set to uppercase. ©param str A string to format ©return The formatted string */ private String formatNoPad(String str) { ■ if (m_width == 0) return " " ; if (str. length ( ) > m_width) return (m_uppercase ? str. substring (0,m_width) . toUpperCase( ) : str. substring(0,m_width) ) ; else return (m_uppercase ? str . toUpperCase ( ) :str) ,- } Checks to make sure that a string represents a valid number (i.e. all characters within the string are digits) . ©param s String representing a number. ©return <b>true</b> if string represents a valid number, otherwise <b>false</b>. */ private boolean validNumber (String s) { boolean retVal = true; for (int i=0 ; i<s . lengt ( ) ; i++) { if (s.charAt(i) < '0' || s.charAt(i) > '9') { retVal = false; break; } } return retVal ; } /** This method performs finalization on the Formatter Object */ public void finalize () { LogController .getlnstance O .log ( "Formatter is about to get garbage collected. " , LogController . DEBUG3 ) ; } } package com.uhc . iframework. runtime .mapping; Class represents an exception thrown by the lexer. <p> Called operations: <code> <ul> <li>None </ul> </code> ©date 1 July 1998 ©version 2.0 ©author Andersen Consulting - Copyright 1998 */ public class LexerException extends Error { private String m_message = null; /** NOTE: This constructor has been customized for use with WinEdit for map file development! * Returns a detailed message for the Error when it is thrown by the * token manager to indicate a lexical error. * Parameters : * EOFSeen : indicates if EOF caused the lexicl error * curLexState : lexical state in which this error occured * errorLine : line number when the error occured * errorColumn : column number when the error occured * errorAfter : prefix that was seen before this error occured * curchar : the offending character * Note: You can customize the lexical error message by modifying this method. */ public LexerException (boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) { m_message = new String ( "Encountered \"" + (EOFSeen ? "<EOF> " : addEscapes (String.valueOf (curChar) ) + "\" at line " + errorLine + ", column " + errorColumn + ".")); } public String getMessage 0 { return m_message; } protected static final String addEscapes (String str) { StringBuffer retval = new StringBuffer ( ) ,- char ch; for (int i = 0; i < str . length () ; i++) { switch (str . charAt (i) ) { case 0 : continue; case ' \b' : retval . append ( " \ \b" ) ; continue; case ' \t ' : retval . append ( " \\t" ) ,- continue; case ' \n' : retval . append ( " \ \n" ) ; continue; case ' \f ' : retval . append ( " \ \f " ) ; continue; case ' \r' : retval . append ( " \ \r" ) ■ continue; case ' \" ' : retval . append ( " \\\ " " ) ; continue; case ' \ ' ' : retval . appen ( " \ \ \ ' " ) ; continue; case ' \\ ' : retval . append ( " \ \ \ \ " ) ,- continue; default : if ((ch = str.charAt(i) ) < 0x20 | | ch > 0x7e) { String s = "0000" + Integer . toString (ch, 16); retval. append (" \\u" + s . substring (s . length () - 4, s.lengthO) } else { retval. append (ch) ; } continue; } return retval . toString ( ) ; package com.uhc . iframework. runtime .mapping; import com.uhc . iframework.FailureCodes ; import com.uhc . iframework. runtime . configuration. ConfigurationManager; import com.uhc .iframework. runtime. utility.basic . IFMutex; import com.uhc . iframework. runtime.utility. logging. LogController; import Java.util .Hashtable; import Java.util .Vector; * * This class is responsible for loading, retaining, and handing out the abstract syntax trees constructed from various translation maps. <p> Called operations: <code> <ul> <li>ConfigurationManager: .-getlnstance ( ) <li>ConfigurationManager: : getParmaeter ( .. ) <li>LogController: : getlnstance ( ) <li>LogController: :log( .. ) </ul> </code> ©date 23 June 1998 ©version 2.0 ©author Andersen Consulting - Copyright 1998 */ public class MapLoader { /** Static reference to the MapLoader class. */ private static MapLoader m_instance = null; /** Mutex object for thread synchronization. */ private static IFMutex m_mutex = new IFMutex (); /** List of loaded maps (identified by legacy system name - e.g. PRIME, COSMOS) . */ private Hashtable m_maps = new Hashtable () ,- /** Reference to LogController used for logging. */ private LogController m_logger = LogController .getlnstance () ; / ** Obtains an instance of the Maploader class. ©return An instance of the MapLoader. */ static MapLoader getlnstance ( ) { if (m_instance == null) { synchronized) m_mutex ) { iff m_instance == null ) { m_instance = new MapLoader () ; } } } return m_instance; } /** The fully-qualified filename of a map file is used as the key in checking whether an AST already exists for the specified map file. If found in the collection, the root node of the AST is returned. Otherwise, the MapParser class is reinitialized using an input stream based on the map file. A VInterpreter visitor object is instantiated and its syntax check mode is set to <code> true</code>. The visitor object then visits the root node of the AST resulting from the initialization of the MapParser object. If no parser or surface-level syntax errors are encountered by the visitor, the AST is added to the AST collection and the root node of the AST is returned. ©param mapName Fully qualified filename of the map to be obtained ©return Root node of the AST constructed after passing the map file through the MapParser object, ©exception Exception is thrown if map file parameter is null or empty. An Exception is also thrown if the specified map file could not be found. Finally, an Exception is thrown if a ParseException or VisitorException is encountered during visit of the AST, or if a general Throwable is caught during visit of the AST. */ public synchronized SimpleNode getMap (String mapFile) // possible to minimize the synch body ?? Jay throws Exception { m_logger. log ( "Entering MapLoader: : getMap" , LogController .BENCHMARK3) ; MapParser parser = null; SimpleNode root = null; if (mapFile == null) { m_logger. log ( "Parameter to SimpleNode: -.getMap () was null" , LogController. ERR0R3) ; m_logger. log ( "Leaving MapLoader: : getMap", ogController. BENCHMARK3 ) ; throw new Exception (" Parameter to SimpleNode: :getMap ( ) was null") ; } if (mapFile. trim() .equalsC") ) { m_logger. log( "Parameter to SimpleNode.- .-getMap ( ) was empty" , LogController . ERROR3 ) ; m_logger . log ( "Leaving MapLoader: : getMap" , LogController.BENCHMARK3 ) ; throw new Exception ( "Parameter to SimpleNode: : getMap ( ) was empty" ) ,- } m_logger. log ( "MapLoader checking for mapfile in cache" , LogController.DEBUG3) ; // check to see if map is in cache ... root = (SimpleNode)m_maps.get (mapFile) ,- if( root != null ) { m_logger. log ( "MapLoader found mapfile in cache! " , LogController .DEBUG3) ; m_logger. log ( "Leaving MapLoader: .-getMap" , LogController. BENCHMARK3 ) ; return root ; } m_logger. log ( "MapLoader attempting to load map file: " + mapFile, LogController.DEBUG3) ; ava. io. FilelnputStream fstream = null; try { fstream = new Java. io . FilelnputStream(mapFile) ; } catch (Java. io.FileNotFoundException e) { m_logger.log( "Map file (" + mapFile + ") could not be found" , LogController. ERR0R3) ; m_logger. log ( "Leaving MapLoader: :getMap" .LogController .BENCHMARK3) ; throw new Exception (FailureCodes .getFailureCode (FailureCodes .MAJOR_RECOVERABLE) + "Map file not found" ) ; } MapParser. Relnit (fstream) ,- String val = ConfigurationManager. getlns ance ( ) .getParameter (ConfigurationManager .MAX_ERRORS) int maxErrors = 0 ; try { maxErrors = Integer.parselnt (val) ,- catch (NumberFormatException ex) {} try { root = MapParser. CompilationUnit 0 ,- // root. dump (" " ) ; VInterpreter v = new VInterpreter (mapFile,null, null,null,maxErrors) ; // check the syntax v.setSyntaxCheckMode (true) ; m_logger. log( "MapLoader: : getMap interpreting map for syntax BEGIN" , LogController. BENCHMARK3) ; root . j tAccept (v, null); m_logger. log( "MapLoader: : getMap interpreting map for syntax END" , LogController. BENCHMARK3) ; } catch (ParseException e) { m_logger. log( e, LogController. ERR0R3 ); m_logger. log ( "MapLoader:: getMap interpreting map for syntax END" , ogController. BENCHMARKS) ; m_logger. log ( "Leaving MapLoader: : getMap", LogController.BENCHMARKS) ; throw new Exception ( e .getMessage ( ) ) ,- } catch (VisitorException e) { m_logger. log( e, LogController. ERROR3 ); m_logger. log ( "MapLoader: : getMap interpreting map for syntax END" , LogController. BENCHMARK3) ; m_logger. log ( "Leaving MapLoader: : getMap" , LogController. BENCHMARKS) ; throw new Exception ( e. getDetailMessages ( ) ); // multiple messages } catch (Exception e) { m_logger.log( e, LogController. ERR0R3 ) ; m_logger. log( "MapLoader: : getMap interpreting map for syntax END" , LogController . BENCHMARK3 ) ; m_logger. log ( "Leaving MapLoader: : getMap" ,LogController.BENCHMARKS ) ; throw new Exception ( e. getMessage ( ) ),- } catch (Throwable t) ( m_logger.log( t, LogController. ERR0R3 ) ; m_logger. log ( "MapLoader :: getMap interpreting map for syntax END" , ogController. BENCHMARK3 ) ; m_logger. log ( "Leaving MapLoader: : getMap" , LogController .BENCHMARKS) ; throw new Exception ( t .getMessage ( ) ) ; } finally { fstream. close ( ) ; } m_maps.put (mapFile, root) ; // put the map (root node) in the cache m_logger. log ( "Leaving MapLoader: :getMap", LogController .BENCHMARK3) ; return root; } /** Default constructor. */ private MapLoader ( ) { } package com.uhc . iframework. runtime.mapping; import com. uhc. iframework. runtime,utility, logging. LogController,- import Java. sql .Date; This class contains translation rules that could not be done using the map. <p> Called operations: <code> <ul> <li>LogController: : getlnstance ( ) <li>LogController: : log ( .. ) </ul> </code> ©date 1 July 1998 ©version 2.0 ©author Andersen Consulting - Copyright 1998 */ public class Ruler { /** Searcher */ private Searcher m_searcher = null; /** LogController */ private LogController m_logger = LogController . getlnstance () ; /** RULES */ private static final String RULE1 = "WI_C_Avg_Dependent_Age" ; private static final String RULE2 = "TX_P_Do_Something" ; / * * Constructor. Returns a Ruler object */ public Ruler ( Searcher aSearcher ) { m_searcher = aSearcher; } Constructor. Returns a Ruler object */ private Ruler () {} //This should never be called This method begins the execution of a custom rule identified by a rule name. First, it verifies the name of the rule is not empty, then it calls the method to execute the rule. ©param aRule The string name of the rule to be executed ©return String The string results of the rule. */ public String executeRule (String aRule) throws RulerException { String ruleResults = null; if ( aRule == null ) throw new RulerException ( "Invalid Rule: Rule cannot be null"); if ( aRule . length () == 0) throw new RulerException ( "Invalid Rule: Rule is empty string"),- ruleResults = execute ( aRule ) ; return ruleResults; } /** This method executes a custom rule identified by a rule name. The rule name must match one of the names in the list of rules declared in the Ruler class. If the rule does not exist, it throws the RulerException. ©param aRule The string name of the rule to be executed ©return String The string results of the rule. */ private String execute (String aRule) throws RulerException { String results = null; //Execute the method for the rule passed. If rule does not exist, throw exception if (aRule. equals (RULEl) ) { m_logger. log ( "Ruler executing rule:"+ aRule, LogController. DEBUG3) ; results = rulel ( ) ; } else if (aRule. equals (RULE2) ) { m_logger. log ( "Ruler executing rule:"+ aRule, LogController.DEBUG3) ; results = rule2 ( ) ,- } else { m_logger. log ( "Ruler executing rule:"+ aRule, LogController. ARNING3) ; throw new RulerException ( "Invalid Rule: Rule does not exist."); } return results,- } private String rulel () { int i = 0; int dep_count = 0; int tmp_age = 0; int sum_age = 0; int avg_age = 0; int true_dep_count = 0; String age, avg_age_str; try { dep_count = ( Integer . valueOf (m_searcher . findAttribute ( "UHC/xml/UHCCase.members [0] . dependents [ ] " ) ) ) . intValue ( ) ; } catch (SearchException e) (} for ( i = 0; i < dep_count ; i++) { try { age = m_searcher. findAttribute ( "UHC/xml/UHCCase.members [0] .dependents [i] :age" ) ; tmp_age = (Integer .valueOf (age) ). intValue () ; sum_age = sum_age + tmp_age; ++true_dep_count ,- } catch (Exception e){} } avg_age = sum_age / dep_count; avg_age_str = String.valueOf (avg_age) ; return avg_age_str; } private String rule2 ( ) { return null; } This method performs finalization on the Ruler Object */ public void finalize () { m_logger .log { "Ruler is about to get garbage collected.", m_logger . DEBUG3 ) ; } } package com . uhc . i framework . runt ime . mapping ; ** This class represents an exception thrown by the Ruler. <p> Called operations: <code> <ul> <li>None </ul> </code> ©date 1 July 1998 ©version 2.0 ©author Andersen Consulting - Copyright 1998 */ public class RulerException extends Exception { public RulerException ( String detailMessage ) { super ( detailMessage ) ; } // force user to enter a reason private RulerException () {} package com.uhc . iframework. runtime . apping; import com.uhc. iframework. runtime. configuration.ConfigurationManager; import com.uhc . iframework . runtime .utility. logging.LogController; This abstract class defines the interface for an XML searcher class. <P> Called operations: <code> <ul> <li>LogController: : getlnstance ( ) </ul> </code> ©date 15 October 1998 ©version 2.0 ©author Andersen Consulting - Copyright 1998 */ public abstract class Searcher { /** Constant value contained within the object model associated with the PRIME legacy system. */ protected static final String PRIME_TARGET_SYSTEM = "10002"; /** Constant value contained within the object model associated with the COSMOS legacy system. */ protected static final String COSMOS_TARGET_SYSTEM = "10001"; /** Constant value returned if target system is PRIME. */ protected static Byte PRIME_RETVAL = ConfigurationManager . PRIME_MAP; /** Constant value returned if target system is COSMOS. */ protected static Byte COSMOS_RETVAL = ConfigurationManager. C0SMOS_MAP,- /** Reference to LogController used for logging. */ protected static LogController m_logger = LogController. getlnstance () ; Obtains the target legacy system. */ abstract public Byte getTargetSystem( ) throws SearchException; Obtains the number of members of an occurence. */ abstract public String getCollectionCount (String fqCollection) throws SearchException; / ** Obtains the value of an item in the object model. */ abstract public String findAttribute (String fqAttributeStr) throws SearchException; / ** This method performs finalization on the Searcher Object. */ public void finalize () { m_logger. log ( "Searcher is about to get garbage collected. LogController. DEBUG3) ; } } package com.uhc . iframework. runtime .mapping; import vendor .util CPException; /** This class represents an exception thrown by the Searcher object. <p> Called operations: <code> <ul> <li>None </ul> </code> ©date 24 August 1998 ©version 2.0 ©author Andersen Consulting - Copyright 1998 */ public class SearchException extends Exception { Constructor. ©param detailMessage Message describing source of error. */ public SearchException ( String detailMessage ) { super ( detailMessage ) ,- } ** Constructor. ©param e Vendor exception thrown by the Vendor toolkit. */ public SearchException ( CPException e ) { super ( "Vendor exception caught during search: " + e. getMessage ( ) } / ** Default constructor. */ private SearchException ( ) O /* Generated By: JJTree: Do not edit this line. SimpleNode. Java */ package com.uhc . iframework. runtime .mapping; // ADDED to generated code import com.uhc. iframework. runtime.mapping.Node; // end ADDED /** This class acts as the parent class for all node classes comprising the AST object model. SimpleNode is actually a class generated by JJTree. This particular SimpleNode class has been slightly modified for use with the VInterpreter object. <p> Called operations: <code> <ul> <li>None </ul> </code> ©date 24 August 1998 ©version 2.0 ©author Andersen Consulting - Copyright 1998 */ public class SimpleNode implements Node { protected Node parent; protected Node [ ] children- protected int id; protected MapParser parser; // ADDED to generated code /** Added to generated code. */ public String name = " " ; /** Added to generated code. */ public String format = " " ,- /** Added to generated code. */ public int val = 0; /** Added to generated code. */ public int type = 0 ; /** Added to generated code. */ public String parmO = " " ; public String parml = ""; public String parm2 = " " ; /** Added to generated code. Indicates current line of map file being interpreted by Visitor. */ public int line = 0; /** Added to generated code. Indicates current column of map file being interpreted by Visitor. */ public int column = 0; // end ADDED public SimpleNode (int i) { id = i; } public SimpleNode (MapParser p, int i) { this (i) ; parser = p; } public void jjtOpenO { } public void jjtCloseO ( } public void jjtSetParent (Node n) { parent = n; } public Node jj tGetParent ( ) { return parent; } public void j j tAddChild(Node n, int i) { if (children == null) { children = new Node[i + 1] ; } else if (i >= children. length) { Node c [ ] = new Node [i + 1] ; System.arraycopy(children, 0, c, 0, children, length) ,- children = c; } children [i] = n; } public Node j j tGetChild( int i) { return children[i] ; } public int j tGetNumChildren ( ) { return (children == null) ? 0 : children. length; } /** Accept the visitor. **/ public Object jjtAccept (MapParserVisitor visitor. Object data) throws com. uhc. iframework. runtime.mapping.VisitorException { return visitor, visit (this, data); } /** Accept the visitor. **/ public Object childrenAccept (MapParserVisitor visitor, Object data) throws com.uhc . iframework.runtime .mapping.VisitorException { if (children != null) { for (int i = 0; i < children. length; ++i) { children [i] . jjtAccept (visitor, data) ; } } return data; ) /* You can override these two methods in subclasses of SimpleNode to customize the way the node appears when the tree is dumped. If your output uses more than one line you should override toString (String) , otherwise overriding toStringO is probably all you need to do. */ public String toStringO { return MapParserTreeConstants. jjtNodeName [id] ; } public String toString (String prefix) { return prefix + toStringO; } /* Override this method if you want to customize how the node dumps out its children. */ public void dump (String prefix) { System. out .println (toString (prefix) ) ; if (children != null) { for (int i = 0; i < children. length; ++i) { SimpleNode n = (SimpleNode) children [i] ; if (n != null) { n. dump (prefix + " " ) ; } } /* Generated By:JavaCC : Do not edit this line . TokenMgrError . Java Version 0.7pre2 */ /** Class represents an exception thrown by the token manager. <p> Called operations: <code> <ul> <li>None </ul> </code> ©date 1 July 1998 ©version 2.0 ©author Andersen Consulting - Copyright 1998 */ package com. uhc .iframework. runtime.mapping; public class TokenMgrError extends Error { /* * Ordinals for various reasons why an Error of this type can be thrown. */ / * * * Lexical error occured. */ static final int LEXICAL_ERROR = 0; / ** * An attempt wass made' to create a second instance of a static token manager . */ static final int STATIC_LEXER_ERROR = 1; * Tried to change to an invalid lexical state. */ static final int INVALID„LEXICAL_STATE = 2; /** * Detected (and bailed out of) an infinite loop in the token manager. */ static final int LOOP_DETECTED = 3 ; * Indicates the reason why the exception is thrown. It will have * one of the above 4 values . */ int errorCode; * Replaces unprintable characters by their espaced (or Unicode escaped) * equivalents in the given string */ protected static final String addEscapes (String str) { StringBuffer retval = new StringBuffer () ,- char ch; for (int i = 0; i < str. length () ; i++) { switch (str. charAt (i) ) { case 0 : continue; case ' \b' : retval . append( " \\b" ) ; continue; case ' \t ' : retval . append ( " \ \t " ) ; continue; case ' \n' -. retval . append ( " \\n" ) ,- continue; case ' \f ' : retval . append ( " \ \f" ) ; continue; case ' \r ' : retval . append ( " \\r" ) ; continue; case ' \ " ' : retval . append ( " \\\ " " ) ; continue; case ' \ ' ' : retval . append ( " \\\ ' " ) ; continue; case ' \\ ' : retval . append ( " \\\\ " ) ; continue; default: if ( (ch = str.charAt(i) ) < 0x20 | | ch > 0x7e) { String s = "0000" + Integer. toString (ch, 16); retval .append(" \\u" + s. substring (s . length () - 4, s.lengthO)) } else { retval .append (ch) ,- } continue; } } return retval . toString ( ) ; } j * * NOTE: This method has been customized for use with WinEdit for map file development ! * Returns a detailed message for the Error when it is thrown by the * token manager to indicate a lexical erro . * Parameters : * EOFSeen : indicates if EOF caused the lexicl error * curLexState : lexical state in which this error occured * errorLine : line number when the error occured * errorColumn -. column number when the error occured * errorAfter : prefix that was seen before this error occured * curchar : the offending character * Note: You can customize the lexical error message by modifying this method. */ private static final String LexicalError (boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) throws LexerException { throw new LexerException (EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar) ; } / ** * You can also modify the body of this method to customize your error messages . * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not * of end-users concern, so you can return something like -. * * "Internal Error : Please file a bug report .... " * from this method for such cases in the release version of your parser. */ public String getMessage ( ) { return super .getMessage ( ) ; } /* * Constructors of various flavors follow. */ public TokenMgrError ( ) { } public TokenMgrError (String message, int reason) { super (message) ; errorCode = reason; } public TokenMgrError (boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) throws LexerException { this (LexicalError (EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar) , reason) ; } } package com.uhc . iframework.runtime .mapping; import com.ms .xml . om.Document; import com.ms. ml. om. Element; import com. s .xml . om. ElementEnumeration; import com.ms .xml .parser. ParseException; import com.ms .xml .util .Name; import Java . io .ByteArraylnputStream; import Java . io .FileNotFoundException; import Java. io. InputStream; import Java. io. IOException; import Java. util. Enumeration; import Java . util . StringTokenizer; /** This class is an implementation of the abstract Searcher class. It performs searches of the MS XML object model (as defined by the XML document passed to the constructor) through utilization of the MS XML library. <p> Called operations: <code> <ul> <li>None </ul> </code> ©date 1 July 1998 ©version 2.0 ©author Andersen Consulting - Copyright 1998 */ public class UHCSearcher extends Searcher { /** Object identifier describing path to target legacy system value. */ private static String TARGET_SYSTEM_KEY = "UHC/xml/UHCCase: legacySystem" ; /** Container object for XML object model. */ private Document m_objModel = null; ** Constructor . An input stream is created from the byte array parameter and used to populate the object model container. ©param xml Byte array representation of XML document . ©exception SearchException Thrown in the event of a ParseException or IOException while populating object model container. */ public UHCSearcher (byte [] xml) throws SearchException { try C ByteArraylnputStream stream = new ByteArraylnputStream(xml) ,- m_objModel = new Document () ; m_objModel. load( (InputStream) stream) ,- stream. close () ; } catch (ParseException ex) { throw new SearchException (ex. getMessage () ) ; } catch (IOException ex) { throw new SearchException (ex. getMessage ()) ; } } /** Searches the object model for the target legacy system and returns the result as a Byte object. The valid return values are defined in the parent class . ©return Constant representing target legacy system. ©exception SearchException SearchException is thrown if a valid target system value could not be found within the object model. */ public Byte getTargetSystem( ) throws SearchException { String target = findAttribute (TARGET_SYSTEM_KEY) ,- if ( target. equals (PRIME_TARGET_SYSTEM) ) return PRIME_RETVAL; else if (target . equals (COSMOS_TARGET_SYSTEM) ) return COSMOS_RETVA ; else throw new SearchException ( "No valid target system found"); } j ** Obtains a collection's total number of elements. If the collection hasn't been previously obtained, the collection is found and the total number of element is obtained- from the newly obtained collection. ©param collection The collection from which to obtain the total number of elements . ©exception Exception Thrown if the collection wasn't found in the object model. */ public String getCollectionCount ( String collection) throws SearchException { return f indAttribute (collection) ,- } * * Method iterates through the object model, beginning with the root node, by tokenizing on the dot (.) character. For each iteration, the token is checked for whether it is an occurrence. If it is an occurrence, an enumeration of the current node's children is obtained. If the object identifier is a count object identifier, the number of children nodes is returned, otherwise the i Λ th child node becomes the current node, as specified by the occurrence index. Once the object identifier has been completely tokenized, a match is made based on the specified attribute name against the names of the current node's element objects. The value contained by the element object described by the attribute name is returned. ©param path Object identifier describing location of attribute within object model, ©exception SearchException Thrown if the object identifier passed as a parameter does not correspond to a valid path through the object model. */ public String findAttribute (String path) throws SearchException { String attributeName = null; String pathName = null; String rootObject = null; Enumeration cnodes = null; int collectionlndex; // Validate parameter value if (path == null) throw new SearchException ( "XMLSearcher: : findAttribute () received null for argument"); if (path, trim() .equalsC") ) throw new SearchException ( "XMLSearcher :: findAttribute ( ) received empty argument " ) ; // Get top node of object model Element node = m_objModel .getRoot ( ) ; StringTokenizer st = new StringTokenizer (path, ":") ; if (s . countTokens ( ) > 0) { // Get path to object model attribute StringTokenizer objPath = new StringTokenizer (st .nextToken (),".") ; // Get attribute name (if specified) if (st .countTokens ( ) == 1) attributeName = st .nextToken (). trimO ; if (obj Path. countTokens () > 0) { rootObject = objPath .nextToken ( ) . trim( ) . replace ('/','.'); // Point to root object if (rootObject. equals (node . getTagName () . toString ( ) ) ) { while (obj Path. hasMoreTokens () ) { pathName = obj Path.nextToken ( ) . trim() ; // Check for collection node StringTokenizer index = new StringTokenizer (pathName, " [") if (index. countTokens ( ) == 2) { pathName = index.nextToken (). trim( ) ; // Collection name collectionlndex = -1; try { collectionlndex = Integer.parselnt ( (new StringTokenizer (index. nextToken () ,"]")) .nextToken() ) ; } catch (NumberFormatException ex) { // If index could not be interpreted, assume bad index throw new SearchException (ex. getMessage ( ) ) // For collection count, nextToken throws NoSuchElementException catch (Throwable t) { } // Create an enumeration of children whose tag name matches collection name cnodes = new ElementEnumeration (node. Name, create (pathName) , Element .ELEMENT) ,- Element e = (Element) cnodes .nextElement ( ) ; if (e != null) { // Get enumeration of collection's children int count = 0 ; cnodes = e.getElements ( ) ,- while (cnodes .hasMoreElements ( ) ) { node = (Element) cnodes .nextElement ( ) ; // Count collection's child if node type is Element .ELEMENT if (node.getTypef) == Element. ELEMENT) count++ ,- if (collectionlndex >= 0 && count > collectionlndex) break; if (collectionlndex < 0) return Integer. toString (count) ; } else throw new SearchException ( "Invalid collection (" + path + "): " + pathName); } else if (index. countTokens ( ) == 1) { // Get next child in object model cnodes = new ElementEnumeration (node, Name . create (pathName) , Element . ELEMENT) ; node = (Element) cnodes.nextElement () ,- if (node == null | | cnodes . hasMoreElements ( ) ) throw new SearchException ( "Invalid object model path(" + path + "): " + pathName); } else throw new SearchException ( "Invalid object model path(" + path + "): " + pathName); } // Get attribute value if (attributeName != null) { cnodes = new ElementEnumeration (node,Name . create (attributeName) , Element . ELEMENT) ; node = (Element) cnodes .nextElement ( ) ; if (node != null) return node . getText ( ) ; else throw new SearchException ( "Attribute could not be found: " + attributeName) ; } else throw new SearchException ( "Invalid object model path: " + path) ; } else throw new SearchException ( "Could not find root node: " + rootObject + instead found " + m_objModel .getRoot () .getTagName 0. toString( )) ,- } else throw new SearchException (" Invalid object model path: + path) ; } else throw new SearchException ( "Invalid object model path: " + path) ; } } package com . uhc . i framework . runtime . mapping ; import ava. util .Date; import ava.util.Hashtable; import ava.util .NoSuchElementException; import Java. util . StringTokenizer; This class represents a Visitor object for the abstract syntax trees constructed by MapLoader. It acts as the interpreter for the mapping files and coordinates between the Searcher object. Ruler object, and the Writer object to build a String-based message that will be sent to a legacy system via the technical architecture. <p> Note that the methods of this class have been written such that they assume that a <code>null</code> value is never passed in for the node parameter due to the nature of the AST ' s generation via Java ' s JJTree utility. <P> Called operations: <code> <ul> <li>Searcher: : getCollectionCount ( .. ) <li>Searcher: : findAttribute ( .. ) <li>VisitorException: :add( .. ) <li>VisitorException: :getCount ( ) <li>Writer: :add( ... ) </ul> </code> ©date 20 August 1998 ©version 2.0 ©author Andersen Consulting - Copyright 1998 */ public class VInterpreter implements MapParserVisitor, MapParserConstants { private long _totalFindTime = 0; // DEBUG public StringBuffer _formatOut = new StringBuffer ( " " ) ; // DEBUG /** Symbol table */ protected Hashtable m_symtab = new Hashtable (); /** Table structures table */ protected Hashtable m_tables = new Hashtable () ; /** Class name preface for object identifiers within the Vendor object model. */ protected String m_preface = new String (),- /** VisitorException exceptions collection. */ private VisitorException m_Ierrors = null; /** Fully-qualified file name of map file being interpreted by this Visitor object. */ private String m_filename = " (unknown file to visitor) " ,- /** Private reference to the Searcher object. */ private Searcher m_searcher = null; /** Private reference to the Writer object. *7 private Writer m_writer = null; /** Private reference to the Ruler object. */ private Ruler m_ruler = null; /** Syntax checking flag. Used to indicated that the vistor is syntax checking and not interpreting. Default value is <code>false</code> . */ private boolean SYNTAX CHECK = false; /** Flag used to indicate whether MapChecker tool is interpreting map file. Default value is <code>false</code> and will remain that way unless <code>setMapCheckerMode( ) </code> is called.*/ private boolean m_mapCheckerMode = false; /** Default constructor. */ private VInterpreter ( ) {} // should never be called. // I require the filename from which the AST was generated so I can provide // it in the error messages /** Constructor. Sets the map file name and initializes the VisitorException collection. The collection will use the VisitorException' s default value for the max number of exceptions it will contain. ©param fqFilename Fully-qualified map file name. */ public VInterpreter ( String fqFilename ) // fully qualified file name { m_filename = " ( "+fqFilename+" ) " ; if (m_Ierrors == null) m_Ierrors = new VisitorException ( 0) ; } /** Constructor. Sets the map file name, searcher reference, writer reference, ruler reference, and initializes the VisitorExceptions collection. The collection will contain a max number of exception as specified by the <code>maxErrors</code> parameter. ©param fqFilename Fully-qualified map file name. ©param s Reference to Searcher object. ©param w Reference to Writer object. ©param r Reference to Ruler object. ©param maxErrors Max number of errors during interpretation. */ public VInterpreter (String fqFilename, Searcher s, Writer w, Ruler r,int maxErrors) { this (fqFilename) ,- m_searcher = s,- m_writer = w; m_ruler = r; m_Ierrors = new VisitorException (maxErrors) ,- } Sets the visitor to syntax checking mode. ©param mode Syntax checking mode (true or false). ©return Returns the previous mode. */ public boolean setSyntaxCheckMode ( boolean mode ) { boolean prevMode = this . SYNTAX_CHECK; this.SYNTAX_CHECK = mode; return prevMode; } / * * Sets the map checker mode flag to <code>true</code> . */ public void setMapCheckerMode ( ) { m_mapCheckerMode = true; } ** Gets the visitor syntax checking mode. ©return Returns the previous mode. */ public boolean getSyntaxCheckMode ( ) { return this . SYNTAX_CHECK; } If the object parameter is of type Boolean, the associated primitve value is returned. ©param objval Object containing value to be returned as a boolean primitive. ©param errmsg Pre-defined error message in the case of an exception. ©param line Line in map file which caused this method to be called by the interpreter. ©param column Column in map file which caused this method to be called by the interpreter. ©return Returns a boolean primitive. ©exception A VisitorException is thrown if the value contained by the Object cannot be converted to a boolean primitive. */ protected boolean fetchBool (Object objval, String errmsg,int line, int column) throws VisitorException { boolean val = false; if (objval instanceof Boolean) val = ( (Boolean) objval) .booleanValue ( ) ; else m_Ierrors .add (m_filename, errmsg + " is not boolean" , line, column) ; return val ; } ** If the object parameter is of type Integer, the associated primitve value is returned. ©param objval Object containing value to be returned as an integer primitive. ©param errmsg Pre-defined error message in the case of an exception. ©param line Line in map file which caused this method to be called by the interpreter . ©param column Column in map file which caused this method to be called by the interpreter. ©return Returns an integer primitive. ©exception A VisitorException is thrown if the value contained by the Object cannot be converted to an integer primitive. */ protected int fetchlnt (Object objval, String errmsg, int line, int column) throws VisitorException { int val = 0 ; if (objval instanceof Integer) val = ( (Integer) objval) .intValue O ,- else m_Ierrors .add (m_filename, errmsg + " is not int" , line, column) ,- return val; } This method is called in lieu of an operation on the Format object when the visitor' s reference to the Format object is <code>null</code> . ©param val String to be formatted, ©param form Formatting string. */ protected void tempFormatter (String val. String form) { // System. out.println("Format {" + val + "} using {" + form + "}"),- // _formatOut. append( "Format{" + val + "} using {" + form + "}"),- } This method is called in lieu of an operation on the Ruler object when the visitor' s reference to the Ruler object is <code>null</code>. ©param val A String. ©return Returns a debug message. */ protected String tempRuler (String val) { return new String ( "Rule{" + val + "}"); } This method is called in lieu of the Searcher: : getCollectionCount ( ) method when the visitor's reference to the Searcher object is <code>null</code> . ©param val Occurence object identifier. ©return Returns <code> (int) l</code> */ protected Integer tempCount (String val) { return (new Integer ( 1) ) ; } This method is called in lieu of the Searcher: : findAttribute ( ) method when the visitors' s reference to the Searcher object is <code>null</code> . ©param val Attribute to search for within Vendor object model. ©return Returns a debug message. */ protected String tempFind (String val) { return new String ( "Found{ " + val + "}"); } Generic visit method for a SimpleNode object. ©param node SimpleNode object reference. ©param data Arbitrary data contained in an Object. ©return Returns <code>null</code>. ©exception VisitorException */ public Object visit (SimpleNode node, Object data) throws VisitorException { // shouldn ' t have children to visit return null ; } / * * This method is called when a Visitor object is accepted into an ASTCompilationUnit object. All children nodes are asked to accept the Visitor object. ©param node ASTCompilationUnit object reference. ©param data Arbitrary data contained in an Object. ©exception VisitorException is thrown if, during the traversal of the AST, at least one syntax or runtime error was encountered. ©return Returns reference to the <code>data</code> parameter. ©exception VisitorException */ public Object visit (ASTCompilationUnit node, Object data) throws VisitorException { data = node. childrenAccept (this, data) ; //JAY // System. out .println( "Total time spent searching: " +_totalFindTime+" ms" ) ,- // After AST has been traversed, check for collection of errors (both syntactical and // runtime) . If there are errors in the collection, throw the VisitorException . if (m_Ierrors .getCount ( ) > 0) { throw m_Ierrors; } return data; } This method is called when the Visitor object is interpreting a variable declaration. Upon a variable declaration, the identifier is added to the symbol table for future reference, along with its value. ©param node ASTVarDeclaration object reference, ©param data Arbitrary data contained in an Object. ©exception VisitorException is thrown if the variable has already been declared. ©return Returns <code>null</code>. */ public Object visit (ASTVarDeclaration node, Object data) throws VisitorException { if (node. type == BOOL) { if (m_symtab.put (node.name, new Boolean (false) ) != null) m_Ierrors. add (m_filename, "identifier (" + node.name + ") has already been declared", node. line, node. column) ; } else if (node. type == INT) { if (m_symtab.put (node.name, new Integer(O)) != null) m_lerrors. add (m_filename, "identifier (" + node.name + ") has already been declared", node. line, node. column) ,- } else { if (m_symtab.put (node.name, new StringO) != null) m_Ierrors. add (m_filename, "identifier (" + node.name + ") has already been declared", node. line, node. column) ,- } return null; } / ** This method is called when the visitor is interpreting a variable assignment. The symbol table is updated accordingly. ©param node ASTAssignment object reference, ©param data Arbitrary data contained in an Object. ©exception VisitorException is thrown if the left-hand side is a constant value or if the assignment has a type conflict, ©return Returns new assignment value as a non-primitive, (i.e. Boolean, Integer) */ public Object visit (ASTAssignment node. Object data) throws VisitorException { //m_logger. log ( "Visitor is in ASTAssignment ", LogController .DEBUG3 ) ,- Object objval = node. jjtGetChild(l) .jjtAccept (this, data); // interpret value first // (ASTId)node. j jtGetChild(O) does not get -interpreted—only want its name // Make sure that left side of assignment is a declared identifier if ( ! (node. jjtGetChild(O) instanceof ASTId) ) { m_Ierrors .add (m_filename, "constant value on left side of assignment" , ( (SimpleNode) node. j jtGetChild(O) ) .line, ( (SimpleNode) node. jjtGetChild(O) ) .column) ; return null; } String strval = ( (ASTId) node . jjtGetChild(O) ) .name; // identifier Object symret = m_symtab.get (strval) ; //m_logger. log ("ASTAssignment lvalue (" + strval + ") has symtab value ( " + symret + " ) " , // LogController.DEBUG3) ; if (symret == null) { m_Ierrors.add(m_filename, "assignment of '" + strval + "' before declaration" , ( (SimpleNode) node. jjtGetChild(O) ) .line, ( (SimpleNode) node. jjtGetChild(O) ) .column) ; return null; } if (objval.getClass ( ) != symret .getClass () ) { m__Ierrors. add(m_filename, "assignment would change class of '" + strval + " ' " , ( (SimpleNode) node. jjtGetChild(O) ) .line, ( (SimpleNode) node. jjtGetChild(O) ) .column) ; return null; } if (objval instanceof Boolean) { m_symtab.put (strval, (Boolean) objval) ; return (Boolean) objval ; } else if (objval instanceof Integer) { m_symtab.put (strval, (Integer) objval) ; return (Integer) objval; } else { //remove quotes around string (better method avail?) String newval = ( (String) objval) .replace( '"' , ' ' ).trim(); m_symtab.put ( strval , newval) ; return newval; } } This method is called when the visitor is interpreting a logical OR expression. <code>fetchBool ()</code> is called to get boolean values for both of the node's children. The result of the logical OR operation on the boolean values is returned. ©param node ASTOrNode object reference, ©param data Arbitrary data contained in an Object, ©exception VisitorException ©return Returns boolean result of OR expression as a Boolean object. */ public Object visit (ASTOrNode node, Object data) throws VisitorException { boolean vail = fetchBool (node. jjtGetChild(O) .jjtAccept (this, data), "Left parameter to ' | | ' " , ( ( SimpleNode) node. jjtGetChild(O) ) . line, ( (SimpleNode) node. jjtGetChild(O) ) .column) ; boolean val2 = fetchBool (node. jjtGetChild(l) .jjtAccept (this, data), "Right parameter to ' ) | ' " , ( (SimpleNode) node. jjtGetChild(l) ) .line, ( (SimpleNode) node. j j tGetChild(l) ) .column) ; return new Boolean (vail | |val2) ,- } ** This method is called when the visitor is interpreting a logical AND expression. <code>fetchBool ()</code> is called to get boolean values for both of the node ' s children. The result of the logical AND operation on the boolean values is returned. ©param node ASTAndNode object reference, ©param data Arbitrary data contained in an Object, ©exception VisitorException ©return Returns boolean result of AND expression as a Boolean object. public Object visit (ASTAndNode node. Object data) throws VisitorException { boolean vail = fetchBool (node. j jtGetChild(O) .jjtAccept (this, data), "Left parameter to '&&'", ( (SimpleNode) node. jj tGetChild(O) ) .line, ( (SimpleNode) node. jjtGetChild(O) ) .column) ; boolean val2 = fetchBool (node. j tGetChild(l) . jjtAccept (this, data), "Right parameter to '&&'", ( ( SimpleNode) node. jjtGetChild(l) ) .line, ( (SimpleNode) node, jjtGetChild(l) ) .column) ,- return new Boolean (vall_i&val2) ,- ' } This method is called when the visitor is interpreting a logical equality expression. <code>fetchInt () </code> or <code>fetchBoolean</code> is called to get integer values or boolean values for both of the node's children, depending on whether integers or booleans are being compared, resectively. The result of the equality operation is returned. ©param node ASTEQNode object reference. ©param data Arbitrary data contained in an Object. ©exception VisitorException is thrown if an integer is not compared against an integer or if a boolean is not compared against a boolean. ©return Returns boolean result of equality expression as a Boolean object. */ public Object visit (ASTEQNode node. Object data) throws VisitorException { // Arguments can be either BOTH boolean or BOTH integer, but not a combination thereof . Object objVall = node, jjtGetChild(O) .jjtAccept (this, data) ,- Object objVal2 = node . jjtGetChild (1) . jtAccept (this, ata) ; if ( (objVall instanceof Integer) && (objVal2 instanceof Integer) ) { int vail = fetchlnt (node . jjtGetChild(O) . jjtAccept (this , data), "Left parameter to '=='", ( (SimpleNode) node. jjtGetChild (0) ) .line, ( (SimpleNode) node. jjtGetChild(O) ) .column) ; int val2 = fetchlnt (node . jj tGetChild(l) . jjtAccept (this, data), "Right parameter to '=='", ( (SimpleNode) node. jjtGetChild (1) ) .line, ( (SimpleNode) node. j jtGetChild(l) ) .column) ; return new Boolean (vall==val2 ) ; } else if ( (objVall instanceof Boolean) && (objVal2 instanceof Boolean) ) { boolean vail = fetchBool (node. jjtGetChild(O) .jjtAccept (this, data) , "Left parameter to '=='", ( (SimpleNode) node. jjtGetChild (0) ) .line, ( (SimpleNode) node. jjtGetChild(O) ) .column) ; boolean val2 = fetchBool (node. jj GetChild(l) . jjtAccept (this , data) , "Right parameter to '=='". ( (SimpleNode) node. jjtGetChild(l) ) .line, ( (SimpleNode) node. jjtGetChild(1) ) .column) ; return new Boolean (vall==val2) ; } else { m_Ierrors .add (m_filename, "must compare int againt int or boolean against boolean", ( (SimpleNode) node. jjtGetChild(O) ) .line, ( (SimpleNode) node. jjtGetChild(O) ) .column) ; return new Boolean (false) ,- } } /** This method is called when the visitor is interpreting a logical non- equality expression. <code>fetchInt ( ) </code> or <code>fetchBoolean</code> is called to get integer values or boolean values for both of the node's children, depending on whether integers or booleans are being compared, resectively. The result of the non-equality operation is returned. ©param node ASTNENode object reference, ©param data Arbitrary data contained in an Object. ©exception VisitorException is thrown if an integer is not compared against an integer or if a boolean is not compared against a boolean, ©return Returns boolean result of non-equality expression as a Boolean. */ public Object visit (ASTNENode node, Object data) throws VisitorException { // Arguments can be either BOTH boolean or BOTH integer, but not a combination thereof. Object objVall = node. jjtGetChild(O) .jjtAccept (this, data) ; Object objVal2 = node. jjtGetChild (1) .jjtAccept (this, data) ; if ( (objVall instanceof Integer) && (objVal2 instanceof Integer) ) { int vail = fetchlnt (node. jjtGetChild(O) .jjtAccept (this, data), "Left parameter to '!='", ( (SimpleNode) node. jjtGetChild(O) ) .line, ( (SimpleNode) node. jjtGetChild(O) ) .column) ; int val2 = fetchlnt (node . jjtGetChild (1) . jj tAccept (this , data), "Right parameter to '!='", ( (SimpleNode) node. jjtGetChild (1) ) .line, ( (SimpleNode) node. jjtGetChild(1) ) .column) ; return new Boolean (vail ! =val2 ) ; } else if ( (objVall instanceof Boolean) && (objVal2 instanceof Boolean) ) { boolean vail = fetchBool (node . j j tGetChild( O) . j j tAccept ( this , data) "Left parameter to '!='", ( (SimpleNode) node. jjtGetChild(O) ) .line, ( (SimpleNode) node. jjtGetChild(O) ) .column) ; boolean val2 = fetchBool (node. jjtGetChild(l) . jjtAccept (this, data) , "Right parameter to '!='", ( (SimpleNode) node. jjtGetChild (1) ) .line, ( (SimpleNode) node. jjtGetChild (1) ) .column) ; return new Boolean (vail ! =val2) ; } else { m_Ierrors .add (m_filename, "must compare int againt int or boolean against boolean" , ( (SimpleNode) node. j tGetChild(O) ) .line, ( (SimpleNode) node. j j tGetChild(O) ) .column) ; return new Boolean ( false) ; } } This method is called when the visitor is interpreting a less-than expression. <code>fetchInt ( ) </code> is called to get integer values for both of the node's children. The result of the less-than operation on the integer values is returned. ©param node ASTLTNode object reference, ©param data Arbitrary data contained in an Object, ©exception VisitorException ©return Returns boolean result of less-than expression as a Boolean object. */ public Object visit (ASTLTNode node, Object data) throws VisitorException { int vail = fetchlnt (node . jjtGetChild ( 0) . jjtAccept (this, data), "Left parameter to '<'", { (SimpleNode) node. jjtGetChild(O) ) .line, ( (SimpleNode) node. jjtGetChild(O) ) .column) ; int val2 = fetchlnt (node. jjtGetChild(l) . jjtAccept (this, data), "Right parameter to '<'", ( (SimpleNode) node. jjtGetChild (1) ) .line, ( (SimpleNode) node. jjtGetChild(l) ) .column) ; return new Boolean (vall<val2 ) ; } /** This method is called when the visitor is interpreting a greater-than expression. <code>fetchInt ( ) </code> is called to get integer values for both of the node ' s childre . The result of the greater-than operation on the integer values is returned. ©param node ASTGTNode object reference, ©param data Arbitrary data contained in an Object, ©exception VisitorException ©return Returns boolean result of greater-than expression as a Boolean object. */ public Object visit (ASTGTNode node, Object data) throws VisitorException { int vail = fetchlnt (node. jjtGetChild (0) . jjtAccept (this, data), "Left parameter to '>'", ( (SimpleNode) node. jjtGetChild(O) ) .line, ( (SimpleNode) node. jj tGetChild(O) ) .column) ; int val2 = fetchlnt (node . jjtGetChild (1) . jjtAccept (this, data), "Right parameter to '>'", ( (SimpleNode) node. jjtGetChild(l) ) .line, ( (SimpleNode) node. jjtGetChild(l) ) .column) ; return new Boolean (vall>val2) ; } J ** This method is called when the visitor is interpreting a less-than-or- equal expression. <code>fetchInt ( )</code> is called to get integer values for both of the node's children. The result of the less-than-or-equal operation on the integer values is returned. ©param node ASTLENode object reference, ©param data Arbitrary data contained in an Object, ©exception VisitorException ©return Returns boolean result of less-than-or-equal expression as a Boolean object. */ public Object visit (ASTLENode node, Object data) throws VisitorException { int vail = fetchlnt (node. jjtGetChild (0) . jj tAccept (this, data), "Left parameter to '<='", ( (SimpleNode) node. jjtGetChild(O) ) .line, ( (SimpleNode) ode. j jtGetChild(O) ) .column) ; int val2 = fetchlnt (node . jj tGetChild(l) . jjtAccept (this, data), "Right parameter to '<='", ( (SimpleNode) node. jjtGetChild(l) ) .line, ( ( SimpleNode) ode. jjtGetChild(l) ) .column) ; return new Boolean (vall<=val2 ) ,- } ** This method is called when the visitor is interpreting a greater-than-or- equal expression. <code>fetchInt ( ) </code> is called to get integer values for both of the node ' s children. The result of the greater-than-or-equal operation on the integer values is returned. ©param node ASTGENode object reference, ©param data Arbitrary data contained in an Object, ©exception VisitorException ©return Returns boolean result of greater-than-or-equal expression as a Boolean object. */ public Object visit (ASTGENode node, Object data) throws VisitorException { int vail = fetchlnt (node. jjtGetChild( 0) . jjtAccept (this, data), "Left parameter to '>='", ( (SimpleNode) node. jjtGetChild (0) ) .line, ( (SimpleNode) node, j jtGetChild(O) ) .column) ,- int val2 = fetchlnt (node . jjtGetChild(l) .jjtAccept (this, data), "Right parameter to '>='", ( (SimpleNode) node. jjtGetChild(l) ) .line, ( (SimpleNode) node. jjtGetChild(l) ) .column) ; return new Boolean (vall>=val2 ) ; } This method is called when the visitor is interpreting an integer addition expression. <code>fetchInt ( ) </code> is called to get integer values for both of the node's children. The result of the addition operation on the integer values is returned. ©param node ASTAddNode object reference, ©param data Arbitrary data contained in an Object, ©exception VisitorException ©return Returns integer result of addition expression as an Integer object. */ public Object visit (ASTAddNode node. Object data) throws VisitorException { int vail = fetchln (node. j jtGetChild(O) . jjtAccept (this, data), "Left parameter to '+'", ( (SimpleNode) node. tGetChild(O) ) .line, ( (SimpleNode) node. jjtGetChild(O) ) .column) ; int val2 = fetchlnt (node. jjtGetChild(l) .jjtAccept (this, data), "Right parameter to '+'", ( (SimpleNode) node.j tGetChild(l) ) .line, ( (SimpleNode) node. jjtGetChild (1) ) .column) ; return new Integer (vall+val2) ; } This method is called when the visitor is interpreting an integer subtraction expression. <code>fetchInt ( ) </code> is called to get integer values for both of the node's children. The result of the subtraction operation on the integer values is returned. ©param node ASTSubtractNode object reference, ©param data Arbitrary data contained in an Object, ©exception VisitorException ©return Returns integer result of subtraction expression as an Integer object. */ public Object visit (ASTSubtractNode node. Object data) throws VisitorException { int vail = fetchlnt (node. jjtGetChild(O) . jjtAccept (this, data), "Left parameter to '-'", ( (SimpleNode) node. jjtGetChild(O) ) .line, ( (SimpleNode) node, jjtGetChild(O) ) .column) ,- int val2 = fetchlnt (node. jjtGetChild (1) . jjtAccept (this, data), "Right parameter to '-'", ( ( SimpleNode) node. jjtGetChild(l) ) .line, ( (SimpleNode) node, jtGetChild(l) ) .column) ,- return new Integer (vall-val2) ; } /** This method is called when the visitor is interpreting an integer multiplication expression. <code>fetchlnt ( )</code> is called to get integer values for both of the node's children. The result of the multiplication operation on the integer values is returned. ©param node ASTMulNode object reference, ©param data Arbitrary data contained in an Object, ©exception VisitorException ©return Returns integer result of multiplication expression as an Integer object. */ public Object visit (ASTMulNode node. Object data) throws VisitorException { int vail = fetchlnt (node. j jtGetChild(O) . jjtAccept (this, data), "Left parameter to '*'", ( (SimpleNode) node. jjtGetChild(O) ) .line, ( (SimpleNode) node. jjtGetChild(O) ) .column) ; int val2 = fetchln (node. jjtGetChild(l) .jjtAccept (this, data), "Right parameter to '*'", ( (SimpleNode) node. jjtGetChild (1) ) .line, ( (SimpleNode) node. jjtGetChild(l) ) .column) ; return new Integer (vall*val2) ; } / ** This method is called when the visitor is interpreting an integer division expression. <code>fetchInt () </code> is called to get integer values for both of the node's children. The result of the division operation on the integer values is returned. ©param node ASTDivNode object reference, ©param data Arbitrary data contained in an Object, ©exception VisitorException is thrown if division by zero is attempted. ©return Returns integer result of division expression as an Integer object. */ public Object visit (ASTDivNode node. Object data) throws VisitorException { int vail = fetchlnt (node. jjtGetChild ( 0) .jjtAccept (this, data), "Left parameter to '/'", ( ( SimpleNode) node. jjtGetChild(O) ) .line, ( (SimpleNode) node. jjtGetChild(O) ) .column) ; int val2 = fetchlnt (node . jjtGetChild (1) . jjtAccept (this, data), "Right parameter to '/'", ( (SimpleNode) node. jjtGetChild(l) ) .line, ( (SimpleNode) node. jjtGetChild(l) ) .column) ; if (val2 == 0) { m_Ierrors. add (m_filename, "Division by zero error", ( (SimpleNode) node. jjtGetChild (1) ) .line, ( (SimpleNode) node, j jtGetChild(l) ) .column) ,- return new Integer (0) ; } return new Integer (vall/val2) } /** This method is called when the visitor is interpreting an integer modulus expression. <code>fetchInt ( )</code> is called to get integer values for both of the node's children. The result of the modulus operation on the integer values is returned. ©param node ASTModNode object reference, ©param data Arbitrary data contained in an Object, ©exception VisitorException is thrown if modulo by zero is attempted. ©return Returns integer result of modulus expression as an Integer object. */ public Object visit (ASTModNode node. Object data) throws VisitorException { int vail = fetchlnt (node. jjtGetChild (0) . jjtAccept (this, data), "Left parameter to '%'", ( (SimpleNode) node. tGetChild(O) ) .line, ( (SimpleNode) node. jjtGetChild(O) ) .column) ; int val2 = fetchlnt (node . jjtGetChild (1) . jjtAccept (this, data), "Right parameter to '%'", ( (SimpleNode) node. j jtGetChild(l) ) .line, ( (SimpleNode) node. jjtGetChild (1) ) .column) ; if (val2 == 0) C m_Ierrors .add (m_filename, "Modulo by zero error", ( (SimpleNode) node. jjtGetChild (1) ) . line, ( (SimpleNode) node. jjtGetChild (1) ) .column) ; return new Integer (0); } return new Integer (vall%val2) ; } / ** This method is called when the visitor is interpreting a logical negation expression. <code>fetchBool () </code> is called to get the boolean value for the node's child. The result of the negation operation on the boolean value is returned. ©param node ASTNotNode object reference, ©param data Arbitrary data contained in an Object, ©exception VisitorException ©return Returns boolean result of negation expression as a Boolean object. */ public Object visit (ASTNotNode node, Object data) throws VisitorException { boolean vail = fetchBool (node. jjtGetChild(0 ). jj tAccept (this, data), "negation expression", ( (SimpleNode) node. jjtGetChild(O) ) .line, ( (SimpleNode) node. jjtGetChild(O) ) .column) ; return new Boolean (!vail) ; } This method is called when the visitor is interpreting an identifier. ©param node ASTIdNode object reference, ©param data Arbitrary data contained in an Object, ©exception VisitorException is thrown if the identifier being interpreted has not already been declared in a variable declaration (and subsequently added to the symbol table) . ©return Returns value associated with identifier as a non- primitive, (i.e. Boolean, Integer) */ public Object visit (ASTId node, Object data) throws VisitorException { Object objval = m_symtab. get (node .name) ; if (objval == null) { m_Ierrors .add (m_filename, "usage of '" + node.name + "' before declaration", node. line, node. column) ; return null; } if (objval instanceof Boolean) return (Boolean) obj al; else if (objval instanceof Integer) return (Integer) objval,- else return (String) objval; } This method is called when the visitor is interpreting an integer constant . ©param node ASTIntConstNode object reference. ©param data Arbitrary data contained in an Object. ©exception VisitorException ©return Returns integer constant value as an Integer. */ public Object visit (ASTIntConstNode node, Object data) throws VisitorException { return new Integer (node.val) ; } / * * This method is called when the visitor is interpreting a boolean constant. ©param node ASTBooleanNode object reference. ©param data Arbitrary data contained in an Object, ©exception VisitorException ©return Returns boolean constant value as a Boolean. */ public Object visit (ASTBooleanNode node. Object data) throws VisitorException { if (node.name. equals ( "true" ) ) return new Boolean (true) ,- else return new Boolean (false) ; } This method is called when the visitor is interpreting a String constant. ©param node ASTStrConstNode object reference. ©param data Arbitrary data contained in an Object. ©exception VisitorException ©return Returns String constant value. */ public Object visit (ASTStrConstNode node, Object data) throws VisitorException { return new String (node .name) ; } /** This method is called when the visitor is interpreting a block of instructions . All children nodes (statements) are asked to accept the Visitor object for interpretation. ©param node ASTBlock object reference. ©param data Arbitrary data contained in an Object. ©exception VisitorException ©return Returns reference to data parameter. */ public Object visit (ASTBlock node, Object data) throws VisitorException { data = node. childrenAccept (this, data); return data; } This method is called when the visitor is interpreting a statement expression. All children nodes (assignement) are asked to accept the Visitor object for interpretation. ©param node ASTStatementExpression object reference. ©param data Arbitrary data contained in an Object. ©exception VisitorException ©return Returns reference to data parameter. */ public Object visit (ASTStatementExpression node, Object data) throws VisitorException { data = node. childrenAccept (this, data) " ; return data; } ** This method is called when the visitor is interpreting a semicolon. ©param node ASTSe iColon object reference. ©param data Arbitrary data contained in an Object. ©exception VisitorException ©return Returns <code>null</code> . */ public Object visit (ASTSemiColon node, Object data) throws VisitorException { return null; } This method is called when the visitor is interpreting an ' if-then- (else) ' block. The if expression is evaluated and, depending on the result, the then expression is interpreted, or the else expression is evaluated (if it exists) . ©param node ASTIfStatement object reference, ©param data Arbitrary data contained in an Object, ©exception VisitorException ©return Returns <code>null</code> . */ public Object visit (ASTIfStatement node, Object data) throws VisitorException { boolean vail = fetchBool (node. jjtGetChild(O) . jjtAccept (this, data), "Expression in 'if'", node. line, node .column) ; if (vail) node. jjtGetChild (1) .jjtAccept (this, data) ; else if (node. jj tGetNumChildren ( ) == 3) node.j jtGetChild(2) .jjtAccept (this, data) ; return null; } / * * This method is called when the visitor is interpreting a 'while' block. The boolean while expression is evaluated and, while the result is <b>true</b>, continues to interpret the statements contained within the while block. ©param node ASTWhileStatement object reference, ©param data Arbitrary data contained in an Object, ©exception VisitorException ©return Returns <code>null</code> . * / public Obj ect visit (ASTWhileStatement node , Obj ect data) throws VisitorException { boolean vail; do { vail = fetchBool (node. jjtGetChild (0) .jjtAccept (this, data), "Expression in 'while'", node. line, node. column) ; if (vail) node. jjtGetChild (1) . j j tAccept (this, data) ; else break; } while (true) ; return null; } I -k -k This method is called when the visitor is interpreting a debug statement. For a string literal, the string is forwarded to the standout out stream. For a variable, the name of the variable and its associated value are forwarded to the standard out stream if the variable has been defined and exists within the symbol table. If the variable has not yet been defined and does not exist within the symbol table, a message indicating this fact is forwarded to the standard out stream. ©param node ASTDebugStatement object reference. ©param data Arbitrary data contained in an Object. ©exception VisitorException ©return Returns <code>null</code>. */ public Object visit (ASTDebugStatement node. Object data) throws VisitorException { //remove entire command from final version if (node. type == STRING_LITERAL) { //remove quotes around string (better method avail?) String val = node .name.replace ('"' , ' ').trim(); System, out .println( "Debug: " + node. name); return null; } Object symret = m_symtab. get (node. name) ; if (symret == null) System. out . println ( "Debug : ( " + node . name + " ) = ♦ undefined* " ) ; else System. out .println( "Debug: (" + node.name + ") = " + symret) ; return null; } This method is called when the visitor is interpreting a find expression. The object identifier is parsed and the results are sent to the Searcher object. The Search object returns the return value for the method. The syntax to get a value from an object that is a direct child of the root node is <code>" :&ltobject identifier&gt"</code>. In this case, the colon is removed during the parsing procedure. • If in map checker mode, the result of the find expression is forwarded to the standard out stream in a format that can be recognized by the WinEdit application ' for debugging purposes . ©param node ASTFindExpression object reference, ©param data Arbitrary data contained in an Object, ©exception VisitorException is thrown if the object identifier specified could not be found by the Searcher. VisitorException is also thrown if a variable is used as an occurrence index and the variable has not been defined or the variable is not of an integer type, ©return Returns the value of the object identifier from the Vendor object model. */ public Object visit (ASTFindExpression node, Object data) throws VisitorException { // If find parameter is off of root (i.e. ":caseID"), remove the trailing // period from m_preface String preface = null; if (node.parmO.charAt (0) == ':') preface = m_preface. substring (0,m_preface . length () -1) ,- else preface = m_preface; StringTokenizer t = new StringTokenizer (preface + node.parmO, "["); String out = " " ,- String index = " " ; Object objval = null; out = t .nextToken ("["),- while (t .hasMoreTokens ( ) ) { index = t . nextToken ( " ] " ) ; try { objval = new Integer (index) ; } catch ( NumberFormatException e ) { // index must be a variable objval = m_symtab. get (index) ; if (objval == null) C m_Ierrors. add (m_filename, "usage of " + index + " before declaration", node. line, node. column) ,- return new String(""); } if ( ! (objval instanceof Integer) ) { m_Ierrors. add (m_filename, "expression '" + index + "' in 'find' is not int.", node. line, node. column) ; return new String ( " " ) ; } } // why isn't "]" consumed in t .nextToken ( ) ? out = out + "[" + objval . toString ( ) ,- out = out + t .nextToken ( " [ " ) ; } if (m_searcher == null) return tempFind(out) ; else { try { if (m_mapCheckerMode) C String s = m_searcher . findAttribute (out) ,- System. out.println(winEditMsg( "DEBUG! find(" + out + ")=" + s, node. line, node. column) ) ; return (Object) s; } else return m_searcher. findAttribute (out) ,- } catch (SearchException ex) { m_Ierrors. add (m_filename, "Searcher could not find " +out . toString ( ) ,node. line, node. column) ; return new String ( " " ) ; } } } Tests whether a string expression can be successfully converted to an integer. ©param s String expression ©return Returns <b>true</b> if the string expression can be converted to an integer, otherwise <b>false</b . */ private boolean islnteger (String s) { int val; try { val = Integer.parselnt (s) ; return true; } catch (NumberFormatException ex) { return false; } } / * * This method is called when the visitor is interpreting a count expression. The object identifier is parsed and the results are sent to the Searcher object. The Search object returns the return value for the method. The syntax to get a value from an occurrence that is a direct child of the root node is <code>" :&ltobject identifier&gt "</code> . In this case, the colon is removed during the parsing procedure. If in map checker mode, the result of the find expression is forwarded to the standard out stream in a format that can be recognized by the WinEdit application for debugging purposes. ©param node ASTFindExpression object reference, ©param data Arbitrary data contained in an Object, ©exception VisitorException is thrown if the object identifier specified could not be found by the Searcher. VisitorException is also thrown if a variable is used as an occurrence index and the variable has not been defined or the variable is not of an integer type, ©return Returns the value of the object identifier from the Vendor object model. */ public Object visit (ASTCountExpression node, Object data) throws VisitorException { // If find parameter is off of root (i.e. ":caseID"), remove the trailing // period from m_preface String preface = null; if (node.name. charAt (0) == ':') preface = m_preface. substring (0,m_preface. lengt () -1) ; else preface = m_preface; StringTokenizer t = new StringTokenizer (preface + node.name, "]"); StringTokenizer ob = null; StringBuffer out = new StringBuffer ( " " ) ; String variable = null; String token = null; Object objval = null; int numTokens ,- try { while ( t .hasMoreTokens ( ) ) { token = t .nextToken ( ) ; ob = new StringTokenizer (token, "[") ; numTokens = ob. countTokens ( ) ; out. append (ob. nextToke ( ) ) ; if (numTokens > 1) { variable = ob.nextToken () ; // Is index an integer literal? if (this . islnteger (variable) ) out . ppend ( " [ " + variable + " ] " ) ; else { // Try find value associated with variable index .objval = m_symtab. get (variable) ; if (objval == null) { m_Ierrors .add(m_filename, "usage of '" + variable + "' before declaration", node. line, node .column) ; return new String ( " " ) ; } if ( ! (objval instanceof Integer) ) { m_Ierrors .add (m_filename, "expression '" + variable + "' in 'count' is not int", node. line, node .column) ; return new String ( " " ) ; } out . append ("[ " + objval . toString ( ) + " ] " ) ; } else out . ppend("[]"); } } catch (NoSuchElementException e) { m_Ierrors. add (m_filename, "No such element, trying to tokenize ' "+m_preface + node.name+ " ' . Should be of format ' element [] ' . Description: " +e, node. line, node .column) ; return new String ( " " ) ; } catch (Throwable th) { m_Ierrors. add (m__filename, "Throwable caught: Description: "+th. toString ()+" , Message: " +th.getMessage 0 , node, line, node. column) ,- return new StringO'"); } if (m_searcher == null) return tempCount (out . toString () ) ,- else { try { if (m_mapCheckerMode) { String s = m_searcher.getCollectionCount (out .toString ( ) ) ; System. out.println(winEditMsg( "DEBUG! count ( " + out. toString ( ) + ")=" + s , node. line, node . column) ) ; return new Integer (s) ,- } else return new Integer (m_searcher .getCollectionCount (out. toString ( ) ) ) ; } catch (SearchException ex) { m_Ierrors . add (m_filename, " SearcherException : " +ex.getMessage ()+" , searching for: " +out . toString () ,node. line,node . column) ; return new Integer ( 0 ) ,- } } } This method is called when the visitor is interpreting a FindWrite statement . The object identifier is parsed and the results are sent to the Searcher object. The Search object returns the return value for the method. The syntax to get a value from an occurrence that is a direct child of the root node is <code>" :&ltobject identifier&gt"</code> . In this case, the colon is removed during the parsing procedure. If in map checker mode, the result of the findwrite expression is forwarded to the standard out stream in a format that can be recognized by the WinEdit application for debugging purposes. Once the value of the object identifier is returned from the Searcher object, it is sent to the Writer object with the appropriate formatting instructions. ©param node ASTFindExpression object reference. ©param data Arbitrary data contained in an Object. ©exception VisitorException is thrown if the object identifier specified could not be found by the Searcher. VisitorException is also thrown if a variable is used as an occurrence index and the variable has not been defined or the variable is not of an integer type. Finally, a VisitorException is thrown if the format specifier is invalid. ©return Returns <code>null</code> . */ public Object visit (ASTFindWriteStatement node. Object data) throws VisitorException { // If find parameter is off of root (i.e. ":caseID"), remove the trailing // period from m_preface String preface = null; if ( ode.name. charAt (0) == ':') preface = m_preface. substring (0,m_preface. length () -1) ; else preface = m_preface; StringTokenizer t = new StringTokenizer (preface + node.name, "["); String out = " " ,- String index = " " ; Object objval = null; out = t .nextToken ("["); while (t .hasMoreTokens () ) { index = t .nextToken ("]"); try { objval = new Integer (index) ; } catch ( Nu berFormatException e ) { // index must be a variable objval = m_symtab. get (index) ; if (objval == null) { m_Ierrors .add (m_filename, "usage of " + index + " before declaration", node. line, node. column) ; return null; } if (! (objval instanceof Integer)) { m_Ierrors .add (m_filename, "expression '" + index + "' in 'find' is not int.", node. line, node. column) ,- return null; } } // why isn't "]" consumed in t . nextToken () ? out = out + "[" + objval. toString ( ) ; out = out + t. nextToken ( " [" ) ,- } String searcherResult = null; if (m_searcher == null) searcherResult = tempFind(out ) ; else { try { searcherResult = m_searcher. findAttribute (out) ,- } catch (SearchException ex) { m_Ierrors . add (m_filename , " SearcherException : "+ex. getMessage ()+" , searching for: " +out. toString ( ) ,node. line, node. column) ,- return null; } } String newformat; //remove quotes around string (better method avail?) newformat = node . format . replace ('"' , ' ').trim(); if (m_mapCheckerMode) System. out .println(winEditMsg( "DEBUG! findwrite(" + out + "," + newformat + ")=" + formatAttribute( searcherResult, newformat) , node, line, node, column) ) ,- if (m_writer == null) tempFormatter (searcherResult, newformat) ; else { try { m_wri ter . add ( searcherResult , newformat ) ; } catch (FormatException ex) { m_Ierrors.add(m_filename, "Format exception: " + e . getMessage ( ) , node . line, node . column) ,- } } return null; } /** This method is called when the visitor is interpreting a ClassPreface statement. The class preface name is set. ©param node ASTClassPrefaceExpression object reference. ©param data Arbitrary data contained in an Object. ©exception VisitorException ©return Returns <code>null</code>. */ public Object visit (ASTClassPrefaceStatement node, Object data) { m_preface = node. name; return null; } This method is called when the visitor is interpreting a Write statement. If the value being written is not a string literal, the (implied) identifier's value is looked up in the symbol table. If in map checker mode, the result of the write expression is forwarded to the standard out stream in a format that can be recognized by the WinEdit application for debugging purposes. Once the value of the object identifier is returned from the Searcher object, ©param node ASTClassPrefaceExpression object reference, ©param data Arbitrary data contained in an Object. ©exception VisitorException is thrown if an identifier is used as a parameter before it has been declared. A VisitorException is also thrown if the format specifier is invalid, ©return Returns <code>null</code>. */ public Object visit (ASTWriteStatement node, Object data) throws VisitorException { String val ,- String newformat ; //remove quotes around string (better method avail?) newformat = node . format . replace ('"' , ' ').trim(); if (node. type == STRING_LITERAL) { //remove quotes around string (better method avail?) val = node.name. replace ( ' " ' , ' ' ).trim(); if (m_mapCheckerMode) System. out.println(winEditMsg( "DEBUG! write ( " + val + "," + newformat + ")=" + formatAttribute (val, newformat) , node, line, node, column) ) ,- if (m_writer == null) tempFormatter (val , newformat ) ,- else { try { m_writer . add (val , newformat ) ; } catch (FormatException ex) { m_Ierrors .add (m_filename, "Format exception: " + ex. getMessage ( ) , node . line, node. column) ; } } return null; } Object objval = m_symtab. get (node. name) ; if (objval == null) { m_Ierrors .add (m_filename, "usage of '" + node.name + "' before declaration", node. line, node . column) ; return null; } if (objval instanceof Boolean) val = ( (Boolean) objval) .toStringO ; else if (objval instanceof Integer) val = ( (Integer) objval) . toString () ; else val = (String) objval; if (m_mapCheckerMode) System. out. println (winEditMsg ( "DEBUG! write ( " + val + "," + newformat + ")=" + formatAttribute (val, newformat) , node . line, node. column) ) ; if (m_writer == null) tempFormatter (val, newformat); else { try { m_writer. add (val , newformat) ,- } catch (FormatException ex) { m_Ierrors .add(m_filename, "Format exception: " + ex. getMessage ( ) ,node. line, node. column) ,- } } return null; This method is called when the visitor is interpreting a ruler expression. ©param node ASTRulerExpression object reference, ©param data Arbitrary data contained in an Object, ©exception VisitorException is thrown if a Ruler exception is caught during rule execution. ©return Returns debug ruler object value. */ public Object visit (ASTRulerExpression node. Object data) throws VisitorException { if (m_ruler == null) { String val = tempRuler (node. name) ; return val; } else { String rule = node.name; String val = null; try { val = m_ruler. executeRule (rule) ; return val; } catch (RulerException ex) { m__Ierrors .add(m_filename, "Ruler exception: " + ex. getMessage () , node, line, node, column) ,- return new String ( " " ) ; } } } This method is called when the visitor is interpreting an exception statement. If syntax checking is turned on, the exception statement is ignored. ©param node ASTExceptionStatement object reference. ©param data Arbitrary data contained in an Object. ©exception VisitorException ©return Returns <code>null</code> . */ public Object visit (ASTExceptionStatement node, Object data) throws VisitorException { // Add exception to exceptions collection String msg = node.name. replace ('"', ' ' ).trim(); if ( ! this . SYNTAX_CHECK ) // not syntax checking { m_Ierrors . add (m_filename, sg, node . line, node . column) ; } return null ; } This method is called when the visitor is interpreting a table statement. By definition, a table has a default lookup value, so that key/value pair is automatically inserted into the Hashtable object that represents the table. Then, for each child of the table statement node, a string array is returned representing a key/value pair for each table element within the table structure and that key/value pair is also inserted into the Hashtable object. Finally, the table definition itself (the Hashtable object) is inserted into a tables collection maintained by the visitor. ©param node ASTTableStatement object reference, ©param data Arbitrary data contained in an Object. ©exception VisitorException is thrown if the table name has already been used in a previous table statement, or if duplicate keys exist for key/value pairs that make up table elements within the table definition. ©return Returns <code>null</code>. */ public Object visit (ASTTableStatement node, Object data) throws VisitorException { Hashtable table = new Hashtable ( ) ,- String[] element = null; // Put "default" element in table first table.put ( "default" , node. format .replace ( ' " ' , ' ' ) . tri O ) ; // Add remaining table elements for (int i=0,-i<node. jj tGetNumChildren ( ) ;i++) { element = (String []) node. jjtGetChild (i) . jjtAccept (this, null) ; if (table.put (element [0] , element [1] ) != null) { m_Ierrors. add (m_filename, "a table element with key(" + element [0] + ") has already been defined for this table", ( (SimpleNode) node. j j tGetChild(i) ) .line, ( (SimpleNode) node . jjtGetChild(i) ) .column) return null; } } // Add table definition if (m_tables.put (node.name, table) != null) { m_Ierrors .add (m_filename, "a table named " + node. name + " has already been defined", node. line, node. column) ,- return null; } return null; } / * * This method is called when the visitor is interpreting a table element. A string array consisting of two strings is constructed, with the first array element containing the key of the table element, and the second array element containing the value of the table element . ©param node ASTTableElement object reference. ©param data Arbitrary data contained in an Object. ©exception VisitorException is thrown if the key of the (key, value) pair is blank. ©return Returns a string array containing the key and value of the table element . */ public Object visit (ASTTableElement node, Object data) throws VisitorException { String [] stringPair = new String [2] ,- stringPair[0] = node.name. replace ('"', ' ').trim(); // Key stringPair [1] = node . format . replace ('"', ' ' ) .trim(); // Value if ( stringPair [0] .equals ("") ) C m_Ierrors .add (m_filename, "key value in table element cannot be blank (empty string)", node, line, node, column) ,- return stringPair; } return stringPair; } /** This method is called when the visitor is interpreting a lookup expression. The specified table is retrieved from the tables collection. Either a string literal or a variable name is used as the index to retrieve the desired value from the table. If the specified index could not be found within the table, the default value from the table is returned. ©param node- ASTLookupExpression object reference, ©param data Arbitrary data contained in an Object, ©exception VisitorException is thrown if an undefined table is specified, or if a variable is used as the table index and the variable is not of a string type. ©return Returns the value associated with the key for the specified table. */ public Object visit (ASTLookupExpression node, Object data) throws VisitorException { String objval = null; String retVal = null; String tableName = null; Object symbol = null; // Get table tableName = node.name; Hashtable tbl = (Hashtable)m_tables .get (tableName) ,- if (tbl == null) { m_Ierrors. add(m_filename, "table (" + tableName + ") has not been defined", node. line, node. column) ; return new String ( " " ) ; } // Get table element if (node. format. charAt (0) == '"') objval = node. format .replace ('"', ' ').trim(); else { symbol = m_symtab. get (node. format) ; if (symbol != null) { if (symbol instanceof String) objval = (String) symbol; else { m_Ierrors.add(m_filename, "lookup identifier (" + node. format + ") must be of type string" , node . line, node . column) ; return new String ( " " ) ; } } else { m_Ierrors. add(m_filename, "usage of '" + node. format + before declaration", node. line, node. column) ; return new String(""),- } } retVal = (String) tbl. get (objval) ; // If lookup key was not found, default value is returned if (retval == null) retVal = (String) tbl . get ( "default" ) ; return new String (retVal) } This method is called when the visitor is interpreting a StringLength expression. Assuming a well-formed string literal (i.e. both opening and closing dbl- quote marks) is required to pass the lexical checker, a determination can be made as to whether the token's image is a string literal or a variable by checking if the first character of the image is a quotation mark. If this is the case, then the length of the string is returned. Otherwise, the parameter to the expression is a variable, its value is looked up in the symbol table, and the length of the variable's value is returned. ©param node ASTStringLengthExpression object reference, ©param data Arbitrary data contained in an Object. ©exception VisitorException is thrown if an undeclared identifier is used as the parameter or if, in the case of a variable parameter, the variable is not of a string type, ©return Returns the length of the string value of the identifier, or the length of the string literal. */ public Object visit (ASTStringLengthExpression node, Object data) throws VisitorException { if (node.name. charA (0) == '"') { String newval = node.name .replace ('"' , ' ').trim(); return new Integer (newval . length ( ) ) ; } else { Object objval = m_symtab. get (node .name) ; if (objval == null) { m_lerrors .add (m_filename, "usage of '" + node.name + "' before declaration", node. line, node. column) ,- return new Integer(0) ; } if ( ! (objval instanceof String) ) { m_Ierrors. add (m__filename, "Parameter to ' stringlength' must be a string", node. line, node. column) ; return new Integer (0); } int val = ( (String) objval) . length () ; return new Integer (val) ; } } /** This method is called when the visitor is interpreting a StringEqual expression. Assuming a well-formed string literal (i.e. both opening and closing dbl- quote marks) is required to pass the lexical checker, a determination can be made as to whether the token's image is a string literal or a variable by checking if the first character of the image is a quotation mark. This assumption is used for both parameters to determine whether they are string literals or variables. If either parameter is a variable, their value is looked up in the symbol table. Finally, the two strings (string literals or the values of variables) are compared and their logical result is returned. ©param node ASTStringEqualExpression object reference, ©param data Arbitrary data contained in an Object. ©exception VisitorException is thrown if an undeclared identifier is used as a parameter, or if a variable parameter is not of a string type. ©return Returns logical result of equality as a Boolean object. */ public Object visit (ASTStringEqualExpression node, Object data) throws VisitorException { Object objvail = null; Object objval2 = null; // Assuming a well-formed string literal (i.e. both opening and closing dbl-quote marks) // is required to pass the lexical checker, a determination can be made as to whether // the token's image is a string literal or a variable by checking if the first character // of the image is a quotation mark. if (node.name. charAt (0) == '"') objvall = node.name. replace ( '"', ' ' ).tri (); else { objvall = m_symtab. get (node.name) ,- if (objvall == null) { m_Ierrors.add(m_filename, "usage of '" + node.name + "' before declaration", node. line, node. column) ; return new Boolean ( false) ; } if ( ! (objvall instanceof String) ) { m_Ierrors. add (m_filename, "First parameter to ' stringequal ' must be a string", node. line, node, column) ,- return new Boolean (false) ; } } if (node. format . charAt (0) == '"') // Assume a string literal objval2 = node. format .replace ('"', ' ').trim(); else { objval2 = m_symtab. get (node . format) ; if (objval2 == null) { m_Ierrors.add(m_filename, "usage of '" + node. format + "' before declaration", node. line, node . column) ; return new Boolean (false) ; } if (!(objval2 instanceof String)) { m_Ierrors .add(m_filename, "Second parameter to 'stringequal' must be a string", node. line, node . column) ; return new Boolean (false) ; } } boolean val = ( (String) objvall) .equals ( (String) objval2 ) ; return new Boolean (val) ; / * * This method is called when the visitor is interpreting a MidString expression. Assuming a well-formed string literal (i.e. both opening and closing dbl- quote marks) is required to pass the lexical checker, a determination can be made as to whether the token's image is a string literal or a variable by checking if the first character of the image is a quotation mark. If the parameter is a variable, its value is looked up in the symbol table. For both the beginning position parameter and the ending position parameter, an attempt is made to convert their values into integers. For either parameter that cannot be converted, it is assumed that they are variable names and their respective values are looked-up in the symbol table. Finally, a subsection of the string value is returned. ©param node ASTMidStringExpression object reference, ©param data Arbitrary data contained in an Object. ©exception VisitorException is thrown if an undeclared identifier is used as any parameter, if the first parameter is not of a string type, or if the second and third parameters are not integer types, ©return Returns sub-string as String. */ public Object visit (ASTMidStringExpression node, Object data) throws VisitorException { String val; Object objval = null; // Assuming a well-formed string literal (i.e. both opening and closing dbl-quote marks) // is required to pass the lexical checker, a determination can be made as to whether // the token's image is a string literal or a variable by checking if the first character // of the image is a quotation mark. if (node.name. charAt (0) == '"') " objval = node.parmO .replace ('"', ' ' ).trim(); else { objval = m_symtab. get (node.parmO) ; if (objval == null) { m_Ierrors. add (m_filename, "usage of '" + node.parmO + "' before declaration", node. line, node. column) ,- return new String ( " " ) ; } if ( ! (objval instanceof String) ) { m_Ierrors .add(m_filename, "Parameter 1 to 'midstring' must be a string", node. line, node. column) ,- return new String ( " " ) ; } } int lastpos = ( (String) objval) . lengthO ; int beginpos = 0 ,- try { beginpos = Integer.parselnt (node.parml) - 1; } catch (NumberFormatException ex) { // is it a symbol (variable)? Object oBeginPos = m_symtab. get (node .parml) ; if (oBeginPos == null) { // symbol not found m_Ierrors.add (m_filename, "usage of '" + node. arml + "' before declaration", node. line, node. column) ; return new String ( " " ) ; } // get the int value of the symbol if ( ! (oBeginPos instanceof Integer) ) { m_Ierrors. add (m_filename, "Parameter 2 to 'midstring' must be an int", node. line, node. column) ,- return new String(""); } beginpos = ( (Integer) oBeginPos) .intValue ( ) - 1; } if (beginpos < 0) beginpos = 0 ; if (beginpos > lastpos) beginpos = lastpos; int lengthToGet = 0; try { lengthToGet = Integer .parselnt (node. parm2 ) ,- } catch (NumberFormatException ex) { // is it a symbol (variable)? Object oLengthToGet = m_symtab. get (node .parm2 ) ; if (oLengthToGet == null) { // symbol not found m_Ierrors .add (m_filename, "usage of '" + node.parm2 + "' before declaration", node, line, node. column) ,- return new String ( " " ) ; } // get the int value of the symbol if ( ! (oLengthToGet instanceof Integer) ) { m_ errors. add (m_filename, "Parameter 3 to 'midstring' must be an int", node. line, node. column) ; return new String ( " " ) ; } lengthToGet = ( (Integer) oLengthToGet) . intValue () ; } int endpos = beginpos + lengthToGet; if (endpos < 0) endpos = 0; if (endpos > lastpos) endpos = lastpos ,- val = ( (String) objval) .substring (beginpos, endpos) return val; This method is called when the visitor is interpreting a Tolnteger expression. Assuming a well-formed string literal (i.e. both opening and closing dbl- quote marks) is required to pass the lexical checker, a determination can be made as to whether the token's image is a string literal or a variable by checking if the first character of the image is a quotation mark. If the parameter is a variable, its value is looked up in the symbol table. For either the string literal or the variable value, an attempt is made to convert it to an integer value. If the value cannot be converted to an integer, a value of zero is returned, otherwise the integer value is returned. ©param node ASTToIntegerExpression object reference, ©param data Arbitrary data contained in an Object. ©exception VisitorException is thrown if an undeclared identifier is used as the parameter. A VisitorException is also thrown if the parameter is not of a string type, ©return Returns the integer value represented by the string if possible, othewise returns zero. */ public Object visit (ASTToIntegerExpression node, Object data) throws VisitorException { Integer val ; Object objval = null; // Assuming a well-formed string literal (i.e. both opening and closing dbl-quote marks) // is required to pass the lexical checker, a determination can be made as to whether // the token's image is a string literal or a variable by checking if the first character // of the image is a quotation mark. if (node. name. charAt (0) == '"') objval = node.name. replace ( ' " ' , ' ' ) .trim() ; else { objval = m_symtab. get (node.name) ; if (objval == null) • { m_lerrors. add(m_filename, "usage of '" + node.name + "' before declaration", node. line, node. column) ; return new Integer (0) ; } if (! (objval instanceof String)) { m_Ierrors. add (m_filename, "Parameter to 'tointeger' must be a string", node. line, node. column) ; return new Integer (0) ,- } } try { val = new Integer ( (String) objval) ; } catch (NumberFormatException e) { // return 0 if string does not contain a number val = new Integer ( 0 ) ; } return val; } / ** This method is called when the visitor is interpreting a MajorVer expression. ©param node ASTMajorVerExpression object reference. ©param data Arbitrary data contained in an Object. ©exception VisitorException ©return Returns zero as an Integer. */ public Object visit (ASTMajorVerExpression node, Object data) throws VisitorException C return new Integer (1) ; } / ** This method is called when the visitor is interpreting a MinorVer expression. ©param node ASTMinorVerExpression object reference. ©param data Arbitrary data contained in an Object. ©exception VisitorException ©return Returns one (1) as an Integer. */ public Object visit (ASTMinorVerExpression node, Object data) throws VisitorException { return new Integer (0); } / * * This method is called when the visitor is interpreting a TimeExpression expression. The current system date is returned. ©param node ASTTimeExpression object reference, ©param data Arbitrary data contained in an Object. ©exception VisitorException ©return Returns the current date and time as a string. */ public Object visit (ASTTimeExpression node. Object data) throws VisitorException { Date todaysdate = new Date ( ) ; return new String (todaysdate. toStringO ) ; } / ** Constructs a string that can be recognized by the WinEdit application for debug purposes . The string returned is of the form: <code> &ltmap filename&gt : Encountered " &ltmessage&gt " at line &ltline number&gt, column Sdtcolumn number&gt . ©param msg Message to be formatted. ©param line Line number in map file causing message to be displayed, ©param column Column number of corresponding line number in map file. ©return String formatted for use by WinEdit. */ private String winEditMsg (String msg, int line, int column) { String r = m_filename + ": Encountered \"" + msg + "\" at line " + line + " , column " + column + " . " ; return r; } /** Method is used in the case that a null was assigned to the Formatter object. ©param aValue String to be formatted, ©param aFormat Format specifier. ©return Returns the formatted string value. If the specifier is invalid, the original string is returned. */ private String formatAttribute (String aValue, String aFormat) { try { return (new Formatter ()). format (aValue, aFormat) ,- } catch (FormatException ex) { return aValue; } package com. uhc . if ramework . runtime . mapping ; import j ava . util .Vector ,- * * This class represent an exception thrown by the VInterpreter visitor object during interpretation of an abstract syntax tree (AST) . <P> Called operations: <code> <ul> <lι>None </ul> </code> ©date 20 August 1998 ©version 2.0 ©author Andersen Consulting - Copyright 1998 */ public class VisitorException extends Exception { /** Max number of errors the collection before the exception is finally thrown . */ private static mt MAX_ERRORS = 50; /** Collection of VisitorException exceptions. */ public Vector m_errors = new VectorO; Constructor. Adds a Throwable object's message to the collection. ©param filename Map file. ©param t Throwable object. ©param line Line in map file that caused exception. ©param column Column of line in map file that caused exception. */ public VisitorException (String filename, Throwable t, mt line, mt column) throws VisitorException { thιs.add(new ErrorMessage (filename, t, line, column) ) ; } Constructor. Adds a Throwable object's message to the collection. ©param filename Map file. ©param t Throwable object. ©param line Line m map file that caused exception */ public VisitorException (String filename, Throwable t, mt line) throws VisitorException { this .add (new ErrorMessage (filename, t, line, 0 ) ) ; } Constructor. Adds a Throwable object's message to the collection. ©param filename Map file, ©param t Throwable object. */ public VisitorException (String filename, Throwable t) throws VisitorException { this .add(new ErrorMessage (filename, t, 0, 0) ) ; } /** Constructor. Adds a message to the collection. ©param filename Map file, ©param message Exception message, ©param line Line in map file that caused exception. ©param column Column of line in map file that caused exception. */ public VisitorException (String filename. String message, int line, int column) throws VisitorException { this.add(new ErrorMessage ( filename, new Exception (message) , line, column) ) } / * * Constructor. Adds a message to the collection. ©param filename Map file. ©param message Exception message. ©param line Line in map file that caused exception. */ public VisitorException (String filename, String message, int line) throws VisitorException { this.add(new ErrorMessage (filename, new Exception (message) , line, 0) ) ; } I ** Constructor. Adds a message to the collection. ©param filename Map file. ©param message Exception message. */ public VisitorException (String filename, String message) throws VisitorException { this.add(new ErrorMessage ( filename, new Exception (message) ,0,0) ) ,- } public VisitorException ( int max) { if (max > 0 ) MAX_ERRORS = max; } Default Constructor . * / public VisitorException ( ) { } / * * Adds a new ErrorMessage object to the exceptions collection. ©param em ErrorMessage object, ©execption VisitorException when number of errors in the collection reaches MAX_ERRORS . */ void add (ErrorMessage em ) throws VisitorException { m_errors . addElement (em) ; if (this.getCountO >= MAX_ERRORS) throw this; } Adds a new ErrorMessage object to the exceptions collection. ©param filename Map file, ©param t Throwable object. ©param line Line in map file that caused exception, ©param column Column of line in map file that caused exception, ©execption VisitorException when number of errors in the collection reaches MAX_ERRORS . */ void add( String filename, Throwable t, int line, int column ) throws VisitorException { m_errors. addElement (new ErrorMessage (filename, t, line, column) ) ; if (this.getCountO >= MAX_ERRORS) throw this; } /** Adds a new ErrorMessage object to the exceptions collection. ©param filename Map file. ©param t Throwable object. ©param line Line in map file that caused exception. ©execption VisitorException when number of errors in the collection reaches MAX_ERRORS . */ void add( String filename, Throwable t, int line ) throws VisitorException { m_errors. addElement (new ErrorMessage (filename, t, line, 0) ) ; if (this.getCountO >= MAX_ERRORS) throw this; } / ** Adds a new ErrorMessage object to the exceptions collection. ©param filename Map file, ©param t Throwable object. ©execption VisitorException when number of errors in the collection reaches MAX_ERRORS . */ void add( String filename, Throwable t ) throws VisitorException { m_errors . addElement (new ErrorMessage ( filename, t, 0 , 0 ) ) ; if (this.getCount >= MAX_ERRORS) throw this; } / ** Adds a new ErrorMessage object to the exceptions collection. ©param filename Map file, ©param message Error message. ©param line Line in map file that caused exception, ©param column Column of line in map file that caused exception, ©execption VisitorException when number of errors in the collection reaches MAX_ERRORS . */ void add( String filename, String message, int line, int column ) throws VisitorException { m_errors . addElement (new ErrorMessage ( filename , new Exception(message) , line, column) ) ,- if (this.getCountO >= MAX_ERRORS) throw this; } * * Adds a new ErrorMessage object to the exceptions collection. ©param filename Map file. ©param message Error message . ©param line Line in map file that caused exception, ©execption VisitorException when number of errors in the collection reaches MAX_ERRORS . */ void add( String filename, String message, int line ) throws VisitorException { m_errors . addElement (new ErrorMessage (filename, new Exception (message) ,line,0) ) ; if (this.getCountO >= MAX_ERRORS) throw this; } Adds a new ErrorMessage object to the exceptions collection. ©param filename Map file, ©param message Error message. ©execption VisitorException when number of errors in the collection reaches MAX_ERRORS . */ void add( String filename, String message ) throws VisitorException { m_errors . addElement (new ErrorMessage ( filename , new Exception (message) ,0,0)); if (this.getCountO >= MAX_ERRORS) throw this,- } /** Return the number of VisitorExceptions in the exceptions collection. ©return Number of VisitorExceptions in the exceptions collection. */ public int getCount ( ) C return m_errors . size ( ) ; } / ** Returns a reference to the exceptions collection. ©return Reference to the exceptions collection. */ public Vector getErrors ( ) { return m_errors ; / / clone or deep copy here ? } Returns a String containing descriptions of the accumulated VisitorExceptions thrown by the VInterpreter object. ©return String representations of all VisitorExceptions thrown. */ public String getDetailMessages ( ) { String ret = new StringC'"); for ( int i=0; i<m_errors .size ( ) ; i++ ) { ret += ( (ErrorMessage) (m_errors.elementAt (i) )) ._filename + ": Encountered \ " " + ( (ErrorMessage) (m_errors.elementAt (i) )) ._t .getMessage () + "\"" + " at line " + ( (ErrorMessage) (m_errors .elementAt (i) )) ._line + ", column " + ( (ErrorMessage) (m_errors. elementAt (i) )) ._column + " .\r\n" ,- } return ret; } / * * Sends a stack trace of all exceptions in the exceptions collection to the standard error stream. */ public void printStackTraces ( ) { for ( int i=0; i<m_errors.size ( ) ; i++ ) { ( (ErrorMessage) (m_errors . elementAt (i) ) ) ._t .printStackTrace 0 ; } } } / * * This class acts as a container for the detailed information that comprise a VisitorException. ©date 21 August 1998 ©version 2.0 ©author Andersen Consulting - Copyright 1998 */ class ErrorMessage { /** Filename containing mapping error. */ String _filename = "unknown file to exception" ; /** Reference to exception object thrown due to mapping error. */ Throwable _t = null; /** Line number of map file that caused an error. */ int _line = 0; /** Column of line number of map file that caused an error. */ int _column = 0 ; Default constructor. */ ErrorMessage ( ) { } /** Constructor. ©param filename Map file. ©param t Throwable object. ©param line Line in map file that caused exception. ©param column Column of line in map file that caused exception. */ ErrorMessage ( String filename, Throwable t, int line, int column ) { _filename = filename; _t = t; _line = line; _column = column; } package com.uhc. iframework. runtime.mapping; import java.util .Hashtable; import Java.util . StringTokenizer,- import ava. util .Date,- public class VSyntaxChecker implements MapParserVisitor, MapParserConstants { /** Symbol table */ protected static Hashtable m_symtab = new Hashtable ( ) ; protected String m_preface = new StringO; private String m_filename = "(unknown file to visitor)"; private VSyntaxChecker ( ) {} // should never be called. // I require the filename from which the AST was generated so I can provide // it in the error messages public VSyntaxChecker ( String fqFilename ) // fully qualified file name { m__filename = " ( "+fqFilename+" ) " ; } protected boolean fetchBool (Object objval, String errmsg) throws VisitorException { boolean val; if (objval instanceof Boolean) val = ( (Boolean) objval) .booleanValue ( ) ; else if (objval instanceof Integer) val = ( (Integer) objval) . intValue ( ) != 0 ? true : false; else throw new VisitorException (m_filename, errmsg + " is not boolean or mt 1 return val; } protected int fetchlnt (Object objval, String errmsg) throws VisitorException { int val; if (objval instanceof Integer) val = ( (Integer) objval) . intValue () ,- else if (objval instanceof Boolean) val = ( (Boolean) objval) .booleanValue () ? 1 : 0; else throw new VisitorException(m_filename, errmsg + " is not int or boolean" ) ; return val ; } protected void tempFormatter (String val, String form) { System. out.println( "Format{" + val + "} using (" + form + "}"); protected String tempRuler (String val) { return new String ( "Rule { " + val + "}"); } protected Integer te pCount (String val) { return new Integer (4) ,- } protected String tempFind (String val) { return new String ( "Found{" + val + "}"); } public Object visit (SimpleNode node, Object data) throws VisitorException { // shouldn't have children to visit return null ; } public Object visit (ASTCompilationUnit node, Object data) throws VisitorException { data = node. childrenAccept (this, data) ; return data; } public Object visit (ASTVarDeclaration node, Object data) throws VisitorException { if (node. type == BOOL) m_symtab . put (node . name , new Boolean ( false) ) ,- else if (node. type == INT) m_symtab. put (node. name, new Integer (0) ) ,- else m_symtab. put (node,name, new StringO); return null; } public Object visit (ASTAssignment node, Object data) throws VisitorException { Object objval = node. jjtGetChild (1) .jjtAccept (this, data); // interpret value first // (ASTId)node. j jtGetChild(O) does not get interpreted--only want its name if ( ! (node. jjtGetChild(O) instanceof ASTId) ) // this should be disallowed by grammar throw new VisitorException (m_filename, "constant value on left side of assignment"); String strval = ( (ASTId) node. jjtGetChild( 0) ) .name; // identifier Object symret = m_symtab. get (strval) ; if (symret == null) throw new VisitorException (m_filename, "assignment of '" + strval + "' before declaration" ) ; if (objval. getClass () != symret .getClass 0 ) throw new VisitorException (m_filename, "assignment would change class of ' " + strval + " ' " ) ; if (objval instanceof Boolean) { m_symtab.put (strval, (Boolean) objval) ; return (Boolean) objval; } else if (objval instanceof Integer) { m_symtab.put (strval, (Integer) objval) ; return (Integer) objval; } else { //remove quotes around string (better method avail?) String newval = ( (String) objval) .replace ('"' , ' ' ).trim(); m_symtab .put ( strval , newval) ; return newval; } } public Object visit (ASTOrNode node, Object data) throws VisitorException { boolean vail = fetchBool (node . jjtGetChild(O) . jjtAccept (this , data), "Left parameter to ' | | ' " ) ; boolean val2 = fetchBool (node . jjtGetChild (1) . jjtAccept (this, data), " Right parameter to ' | | ' " ) ; return new Boolean (vail | |val2) ; } public Object visit (ASTAndNode node, Object data) throws VisitorException { boolean vail = fetchBool (node. jjtGetChild(O) .jjtAccept (this, data), "Left parameter to '&&'"); boolean val2 = fetchBool (node . jjtGetChild (1) . jjtAccept (this, data), " Right parameter to '&&'") ; return new Boolean (vall&&val2 ) ; } public Object visit (ASTEQNode node. Object data) throws VisitorException { int vail = fetchlnt (node . jjtGetChild ( 0) .jj tAccept (this, data), "Left parameter to '=='"); int val2 = fetchlnt (node . jjtGetChild(l) .jjtAccept (this , data), "Right parameter to '=='") ■ return new Boolean (vall==val2) ; } public Object visit (ASTNENode node. Object data) throws VisitorException { int vail = fetchlnt (node. j jtGetChild(O) .jjtAccept (this, data), "Left parameter to '!='"); int val2 = fetchlnt (node. j jtGetChild(l) .jjtAccept (this, data), "Right parameter to '! = '"),- return new Boolean (vail !=val2) ; } public Object visit (ASTLTNode node, Object data) throws VisitorException { int vail = fetchlnt (node. jjtGetChild(O) .jjtAccept (this, data), "Left parameter to '<'"),- int val2 = fetchlnt (node . jjtGetChild (1) . jjtAccept (this, data), "Right parameter to '<'"); return new Boolean (vall<val2 ) ; } public Object visit (ASTGTNode node, Object data) throws VisitorException { int vail •= fetchlnt (node . jj tGetChild( 0) . jj tAccept (this , data), "Left parameter to '>'"); int val2 = fetchlnt (node. jjtGetChild (1) .jj tAccept { this, data), "Right parameter to '>'"); return new Boolea (vall>val2 ) ; } public Object visit (ASTLENode node, Object data) throws VisitorException { int vail = fetchlnt (node. jjtGetChild(O) . jjtAccept (this, data), "Left parameter to '<='"); int val2 = fetchlnt (node . jjtGetChild( 1) . jj tAccept (this, data), "Right parameter to '<='") ,- return new Boolean (vall<=val2 ) ; } public Object visit (ASTGENode node, Object data) throws VisitorException { int vail = fetchlnt (node. j jtGetChild(O) .jjtAccept (this, data), "Left parameter to '>='") ; int val2 = fetchlnt (node. jj tGetChild( 1) . jjtAccept (this, data), "Right parameter to '>='"); return new Boolean (vall>=val2 ) ; } public Object visit (ASTAddNode node, Object data) throws VisitorException { int vail = fetchlnt (node. jjtGetChild(O) .jjtAccept (this, data), "Left parameter to '+'"); int val2 = fetchlnt (node . jjtGetChild(l) . jjtAccept (this, data), "Right parameter to '+'"); return new Integer (vall+val2) ; } public Object visit (ASTSubtractNode node, Object data) throws VisitorException { int vail = fetchlnt (node. jjtGetChild(O) .jjtAccept (this, data), "Left parameter to '-'"); int val2 = fetchlnt (node. jjtGetChild(l) .jjtAccept (this, data), "Right parameter to '-'"); return new Integer (vall-val2) ,- } public Object visit (ASTMulNode node, Object data) throws VisitorException { int vail = fetchlnt (node. jjtGetChild(O) .jjtAccept (this, data), "Left parameter to '*< « ); int val2 = fetchlnt (node . jjtGetChild (1) . jjtAccept (this , data), "Right parameter to '*'"); return new Integer (vail*val2 ) ; } public Object visit (ASTDivNode node. Object data) throws VisitorException { int vail = fetchlnt (node. jjtGetChild (0) . jjtAccept (this , data), "Left parameter to '/'"); int val2 = fetchlnt (node. jtGetChild(l) . jjtAccept (this, data), "Right parameter to '/'"); if (val2 == 0) throw new VisitorException (m_filename, "Division by zero error"); return new Integer (vall/val2 ) ; } public Object visit (ASTModNode node, Object data) throws VisitorException { int vail = fetchlnt (node. jjtGetChild(O) . jjtAccept (this, data), "Left parameter to '%'"),- int val2 = fetchlnt (node. jjtGetChild(l) . jtAccept (this , data), "Right parameter to '%'"); if (val2 == 0) throw new VisitorException (m_filename, "Modulo by zero error") ; return new Integer (vall%val2 ) ,- } public Object visit (ASTNotNode node. Object data) throws VisitorException { boolean vail = fetchBool (node. j jtGetChild(O) . jjtAccept (this , data), " Parameter to '!'"); return new Boolean(!vail) ; } public Object visit (ASTId node. Object data) throws VisitorException { Object objval = m_symtab. get (node .name) ,- if (objval == null) throw new VisitorException(m_filename, "usage of ' " + node.name + before declaration" ) ; if (objval instanceof Boolean) return (Boolean) objval; else if (objval instanceof Integer) return (Integer) objval; else return (String) objval; } public Object visit (ASTIntConstNode node, Object data) throws VisitorException { return new Integer (node.val) ; } public Object visit (ASTBooleanNode node, Object data) throws VisitorException { if (node.name. equals ( "true" ) ) return new Boolean (true) ; else return new Boolean (false) ; } public Object visit (ASTStrConstNode node, Object data) throws VisitorException C return new String (node.name) ; } public Object visit (ASTBlock node, Object data) throws VisitorException { data = node. childrenAccept (this, data); return data; } public Object visit (ASTStatementExpression node, Object data) throws VisitorException { data = node. childrenAccept (this, data); return data; } public Object visit (ASTSemiColon node, Object data) throws VisitorException { return null; } public Object visit (ASTIfStatement node, Object data) throws VisitorException { boolean vail = fetchBool (node. jjtGetChild(O) .jjtAccept (this, data) "Expression in 'if "); if (vail) node. jjtGetChild(1) .jjtAccept (this, data) ■ else if (node, jjtGetNumChildrenO == 3) node. jjtGetChild (2) .jjtAccept (this, data) ; return null; } public Object visit (ASTWhileStatement node, Object data) throws VisitorException { boolean vail; do { vail = fetchBool(node. jjtGetChild(O) .jjtAccept (this, data), "Expression in 'while'"); if (vail) node. jjtGetChild(1) . jj tAccept (this , data) ; else break; } while (true) ; return null; } public Object visit (ASTDebugStatement node. Object data) throws VisitorException { //remove entire command from final version if (node. type == STRING_LITERAL) { //remove quotes around string (better method avail?) String val = node.name . replace ('"' , ' ').trim(); System. out .println( "Debug: " + node.name); return null; } Object symret = m_symtab. get (node. name) ; if (symret == null) System. out.println( "Debug: (" + node.name + ") = *undefined*" ) else System. out .println( "Debug: (" + node.name + ") = " + symret); return null; } public Object visit (ASTFindExpression node, Object data) throws VisitorException { StringTokenizer t = new StringTokenizer (m_preface + node.name, "["),- String out, variable; Object ob val; out = t .nextToken ("["); while (t .hasMoreTokens ( ) ) { variable = .nextToken ("]"); objval = m_symtab.get (variable) ; if (objval == null) throw new VisitorException (m_filename, "usage of '" + variable + "' before declaration") ,- if ( ! (objval instanceof Integer) ) throw new VisitorException (m_filename, "expression '" + variable + "' in 'find' is not int"); // why isn't "]" consumed in t .nextToken () ? out = out + "[" + objval. toString () ,- out = out + t .nextToken ("["); } return tempFind(out) ; } public Object visit (ASTCountExpression node, Object data) throws VisitorException { StringTokenizer t = new StringTokenizer (m_preface + node.name, " [ " ) ; String out, variable; Object objval; out = t .nextToken ("["); while ( t . hasMoreTokens 0 ) { variable = t .nextToken ("]"); objval = m_symtab. get (variable) ,- if (objval == null) throw new VisitorException (m_filename, "usage of '" + variable + "' before declaration" ) ,- if (! (objval instanceof Integer)) throw new VisitorException (m__filename, "expression '" + variable + "' in 'count' is not int"); // why isn't "]" consumed in t . nextToken () ? out = out + "[" + objval. toStringO ; out = out + t.nextToken ( " [" ) ; ) return tempCount (out) ; } public Object visit (ASTFindWriteStatement node, Object data) throws VisitorException { data = node. childrenAccept (this, data); return data; } public Object visit (ASTClassPrefaceStatement node, Object data) throws VisitorException { m_preface = node.name + "."; return null; } public Object visit (ASTWriteStatement node, Object data) throws VisitorException { String val; String newformat; //remove quotes around string (better method avail?) newformat = node . format . replace ( ' " ' , ' ' ) . trim( ) ,- if (node. type == STRING_LITERAL) C //remove quotes around string (better method avail?) val = node.name. replace ('"' , ' ' ).trim(); tempFormatter (val, newformat) ,- return null; } Object objval = m_symtab.get (node .name) ; if (objval == null) throw new VisitorException (m_filename, "usage of '" + node. name + before declaration"),- if (objval instanceof Boolean) val = ( (Boolean) objval) .toStringO ; else if (objval instanceof Integer) val = ( (Integer) objval) .toStringO ,- else val = (String) objval ; tempFormatter (val, newformat); return null; } public Object visit (ASTRulerExpression node, Object data) throws VisitorException { String val = tempRuler (node.name) ; return val ; ) public Object visit (ASTExceptionStatement node, Object data) throws VisitorException { data = node. childrenAccept (this, data); return data; } public Object visit (ASTTableStatement node, Object data) throws VisitorException { System. out .printIn ( "Debug: *table* not implemented"); return null ; }. public Object visit (ASTTableElement node, Object data) throws VisitorException { data = node. childrenAccept (this, data) ,- return data; } public Object visit (ASTLookupExpression node. Object data) throws VisitorException { System. out.println("Debug: *lookup* not implemented" ) ; return new StringO; } public Object visit (ASTStringLengthExpression node, Object data) throws VisitorException { Object objval = m_symtab. get (node .name) ; if (objval == null) throw new VisitorException (m_filename, "usage of '" + node.name + "' before declaration"); if ( ! (objval instanceof String) ) throw new VisitorException (m_filename, "Parameter to ' stringlength' must be a string" ) ,- int val = ( (String) objval) . length( ) ; return new Integer (val) ; } public Object visit (ASTStringEqualExpression node, Object data) throws VisitorException { Object objvall = m_symtab. get (node .name) ; if (objvall == null) throw new VisitorException (m_filename, "usage of '" + node. name + "' before declaration"); if ( ! (objvall instanceof String) ) throw new VisitorException (m_filename, "First parameter to 'stringequal' must be a string"); Object objval2 = m_symtab. get (node. format) ; if (objval2 == null) throw new VisitorException (m_filename, "usage of '" + node. format + "' before declaration"); if ( ! (objval2 instanceof String) ) throw new VisitorException (m_filename, "Second parameter to 'stringequal' must be a string"); boolean val = ( (String) objvall) .equals ( (String) objval2) ; return new Boolean (val ) ; } public Object visit (ASTMidStringExpression node. Object data) throws VisitorException { String val; Object objval = m_symtab. get (node. name) ; if (objval == null) throw new VisitorException (m_filename, "usage of ' " + node. name + " ' before declaration" ) ; if ( ! (objval instanceof String) ) throw new VisitorException (m_filename, "Parameter to 'midstring' must be a string"); int lastpos = ( (String) objval) .length () ,- int beginpos = node.val - 1; if (beginpos < 0) beginpos = 0; if (beginpos > lastpos) beginpos = lastpos; int endpos = node . type + beginpos ; if (endpos < 0) endpos = 0; if (endpos > lastpos) endpos = lastpos; val = ( (String) objval) . substring (beginpos, endpos) ; return val; } public Object visit (ASTToIntegerExpression node, Object data) throws VisitorException { Integer val; Object objval = m_symtab. get (node .name) ; if (objval == null) throw new VisitorException (m_filename, "usage of '" + node.name + "' before declaration" ) ; if ( ! (objval instanceof String) ) throw new VisitorException (m_filename, "Parameter to 'tointeger' must be a string"); try { val = new Integer ( (String) objval) ; } catch (NumberFormatException e) { // return 0 if string does not contain a number val = new Integer ( 0 ) ; } return val ,- } public Object visit (ASTMajorVerExpression node, Object data) throws VisitorException C return new Integer (0); } public Object visit (ASTMinorVerExpression node, Object data) throws VisitorException { return new Integer (1); } public Object visit (ASTTimeExpression node, Object data) throws VisitorException { Date todaysdate = new Date ( ) ,- return new String (todaysdate . toString ()) ; } package com.uhc . iframework.runtime.mapping; import com.uhc . iframework. FailureCodes; import com.uhc . iframework.runtime . queuing . QueuingController; import com.uhc . iframework.runtime .utility. logging.LogController; ** This class is responsible for using the attributes passed in by the Map Interpreter to construct the final message. It also determines the target system in the constructor. This class then creates the message by appending each attribute to a string buffer until the user tells the writer to send the message to the appropriate queue . <p> Called operations: <code> <ul> <li>Formatter : : format ( .. ) <li>LogController: :log( .. ) <li>QueueingController : :depositMessage ( ..) <li>QueueingController: : getlnstance ( ) </ul> </code> ©date 30 July 1998 ©version 2.0 ©author Andersen Consulting - Copyright 1998 */ class Writer { /** Reference to LogController used for logging. */ private LogController m_logger = LogController .getlnstance (); ; /** Represents the destination legacy system for the message. */ private Byte m_targetSystem; /** Container that holds the formatted message. */ private StringBuffer m_message = null; /** Transaction ID. */ private String m_transactionID = null; /** Reference to QueuingController. */ private QueuingController m_queuingController = QueuingController .getlnstance () ,- ,- /** Starting index of transactionlD found within legacy message header. */ private static int TRANSACTION_ID_BEGIN = 0 ; /** Ending index of transactionlD found within legacy message header. */ private static int TRANSACTION_ID_END = 41; /** Reference to Formatter object. */ private Formatter m_formatter = null; Constructor. Target legacy system is set. Transaction ID is parsed from legacy system message header. ©param target Identifies which legacy system system the message will forwarded to. ©param header Legacy system message header, ©exception WriterException WriterException is thrown if parameters are null or if an invalid target legacy system was specified. */ public Writer (Byte target, String header) throws WriterException { if (target == null) { m_logger. log( "The target system is null.", LogController .ERROR3 ) ; throw new WriterException ( "Target system is null"); } if (header == null) { m_logger. log( "The header is null.", LogController. ERR0R3 ) ; throw new WriterException ( "Legacy system message header is null"); } m__logger.log ("The header is.- "+header, LogController.DEBUG3 ) ; if (! target. equals (Searcher. PRIME_RETVAL) && ! target . equals (Searcher OSMOS_RETVAL) ) { m_logger. log ( "Invalid target system" , LogController .ERROR3 ) ; throw new WriterException (" Invalid target system" ) ; } m_transactionID = getTransactionID (header) ; m_targetSystem = target; m_message = new StringBuffer () ,- m_message. append(header) ; m_formatter = new Formatter ( ) ; } Default constructor. */ private Writer () {} Parses the legacy system message header for the transaction ID. ©param header Header for legacy system. ©return Transaction ID as parsed from legacy system message header. */ private String getTransactionID (String header) { return header . substring (TRANSACTION_ID_BEGIN, TRANSACTION_ID_END) ; } Appends the formatted string returned by the Formatter object to the legacy system message. ©param value String value to be formatted and appended to the legacy system message. ©param format Format specifier, ©exception FormatException */ public final void add (String value, String format) throws FormatException { m_message. append (m_formatter. format (value, format) ) ; } Based on the legacy system target, a key corresponding to the appropriate outgoing queue is retrieved from QueuingController. <code>depositMessage ( ) </code> is called on QueuingController with the transaction ID, destination queue key, and legacy system message as parameters. ©return <b>true</b> if attempt to deposit legacy system message on outgoing queue was successful, ©exception WriterException WriterException is thrown if a return value of <b>false</b> was received from QueuingController on attempt to deposit legacy system message. */ public boolean sendMsgO throws WriterException { boolean isDeposited = false; byte destQueue = QueuingController .UNKNOWN_SYSTEM; if (m_targetSystem. equals (Searcher. PRIME_RETVAL) ) destQueue = QueuingController. PRIME,- else if (m_targetSystem. equals (SearcherCOSMOS_RETVAL) ) destQueue = QueuingController COSMOS ; isDeposited = m_queuingController .depositMessage (m_transactionID, destQueue, m_message. toString 0 ) ; if (! isDeposited) { m_logger. log ( "Unable to deposit message. Transaction ID was: "+m_transactionID+" , Destination queue was: "+destQueue+" , Final message was: "+m_message . toString ( ) , LogController . ERROR3 ) ; throw new WriterException (FailureCodes. getFailureCode (FailureCodes .MAJOR_RECOVERABLE) + "Unable to deposit message."); } return isDeposited; } This method performs finalization on the Writer Object */ public void finalize () { m_logger. log ( "Writer is about to get garbage collected.", LogController.DEBUG3) ; } ) package com.uhc . iframework. runtime.mapping; ** This class represents an exception thrown by the Writer. <p> Called operations: <cσde> <ul> <li>None </ul> </code> ©date 1 July 1998 ©version 2.0 ©author Andersen Consulting - Copyright 1998 */ public class WriterException extends Exception { public WriterException (String detailMessage) { super (detailMessage) ; } // Forces user to enter a reason, private WriterException () {} } options { OPTIMIZE_TOKEN_MANAGER=false; MULTI=true; VISITOR=true; VISITOR_EXCEPTION= "VisitorException"; } PARSER_BEGIN (MapParser) package com. uhc . iframework. runtime .mapping; public class MapParser { } PARSER_END (MapParser) SKIP : /* WHITE SPACE */ { " \t" ' "\n" "\r" "\f" <"//" (-["\n", "\r"] )* ("\n" I "\r" I "\r\n")> <••/*" (-["*"])* "*" (-["/"] (-["*"])* "*")* "/"> } TOKEN : /* Types */ { < INT: "int" > I < BOOL: "boolean" > I < STRING: "string" > ) TOKEN : /* LITERALS */ { < INTEGER_LITERAL : (<DIGIT>)+ > I < STRING_LITERAL : " \ " " ( (~["\"", "\\", "\n","\r"]) I ("\\" ( ["n", "t", "b", "r" , "f ", "\\", " ' " , "\""] I [ " o " - " 7 " ] ( [ " 0 " - " 7 " ] ) ? I [ " 0 " - " 3 " ] [ " 0 " - " 7 " ] [ " 0 " - " 7 " ] ) ) )* < BOOLEAN_LITERAL : ("true" "false") > /* * Program structuring syntax follows. */ SimpleNode CompilationUnit ( ) : { String name; } { ( VarDeclaration () " ,- " I Statement ( ) )* <E0F> { return jjtThis; } } void VarDeclaration ( ) : { Token t; } { ( "boolean" { jjtThis. type = BOOL; } I "int" { jjtThis. type = INT; } I "string" { jjtThis. type = STRING; } ) t = <IDENTIFIER> { jjtThis. name = t. image; jjtThis. line = t .beginLine; jjtThis. column t .beginColumn; } } /* * Expression syntax follows. */ void ExpressionO #void: {} { LOOKAHEAD( PrimaryExpression () "=" ) Assignment ( ) I ConditionalOrExpression( ) } void Assignment () fAssignment (2 ) : {} { PrimaryExpression ( ) "=" ExpressionO } void ConditionalOrExpression( ) #void : {} { ConditionalAndExpression ( ) ( "||" ConditionalAndExpression () #OrNode(2) )* } void ConditionalAndExpression ( ) #void : { ) { EqualityExpression( ) ( "&&" EqualityExpression () #AndNode(2) )* } void EqualityExpressionO #void : {} { RelationalExpression ( ) ( "==" RelationalExpression () #EQNode(2) I "!=" RelationalExpression ( ) #NENode(2) )* } void RelationalExpression ( ) #void : {} { AdditiveExpression ( ) ( "<" AdditiveExpression () #LTNode(2) I ">" AdditiveExpression #GTNode(2) I "<=" AdditiveExpression () #LENode(2) I ">=" AdditiveExpression () #GENode(2) )* } void AdditiveExpression ( ) #void : {} { MultiplicativeExpression( ) ( "+" MultiplicativeExpression( ) #AddNode(2) I "-" MultiplicativeExpressionO #SubtractNode (2 ) )* } void MultiplicativeExpressionO #void : {} { UnaryExpression ( ) ( " * " UnaryExpression ( ) #MulNode (2 ) I "/" UnaryExpression ( ) #DivNode(2) I " % " UnaryExpression ( ) #ModNode (2 ) )* } void UnaryExpression ( ) #void : { } { "!" UnaryExpression( ) #NotNode(l) I SearcherExpression ( ) I RulerExpression ( ) i LookupExpression ( ) I UtilityExpression ( ) SystemExpression ( ) I PrimaryExpression ( ) ) void PrimaryExpression ( ) #void : { String name; } { Literal ( ) I IdO I " ( " Expression () " ) " ) void Id() : ( Token t; } { t = <IDENTIFIER> { jjtThis. name = t. image; jjtThis. line = t.beginLine; jjtThis .column = t .beginColumn; } } void Literal ( ) #void : { Token t; } { ( t=<INTEGER_LITERAL> { jjtThis.val = Integer.parselnt (t. image) ; jjtThis. line = t .beginLine; jj tThis .column = t .beginColumn; } ) #IntConstNode BooleanLiteral ( ) StringLiteral ( ) } void BooleanLiteral ( ) ..void : {Token t,-} { (t = <BOOLEAN_LITERAL> {jjtThis .name = t. image; jjtThis. line = t.beginLine; jjtThis .column t . beginColumn; } ) #BooleanNode } void StringLiteral () #void : { Token t; ) { ( t=<STRING_LITERAL> { jjtThis.name = t. image; jjtThis. line = t.beginLine; jjtThis . column t .beginColumn; } ) #StrConstNode } /* * Statement syntax follows. */ void Statement ( ) #void : {} { Semicolon ( ) j LOOKAHEAD(2) LabeledStatement ( ) I Block () I StatementExpression ( ) j IfStatement ( ) j WhileStatement () j DebugStatement 0 " ; " j TableStatement ( ) I ClassPrefaceStatement 0 " ; " j WriteStatement ( ) " ; " j FindWriteStatement 0 " ; " j ExceptionStatement ( ) " ; " } void Semicolon ( ) : {} { } void LabeledStatement ( ) #void : {} { <IDENTIFIER> " : " Statement ( ) ) void Block () : {} { " { " ( Statement ( ) ) * " } " } void StatementExpression ( ) : /* * The last expansion of this production accepts more than the legal * SPL expansions for StatementExpression. */ { } { Assignment () " ; " } void IfStatement ( ) : /* * The disambiguating algorithm of JavaCC automatically binds dangling * else's to the innermost if statement. The LOOKAHEAD specification * is to tell JavaCC that we know what we are doing. */ { Token t; } { t = "if" "(" ExpressionO ")" Statement () [ LOOKAHEAD(l) "else" Statement () ] { jjtThis. line = t.beginLine; jj tThis . column = t .beginColumn; } } void WhileStatement ( ) : { Token t; } { t = "while" "(" ExpressionO ")" Statement () { jjtThis. line = t.beginLine; jjtThis .column = t .beginColumn; } } void DebugStatement ( ) : { Token t; } { LOOKAHEAD ( 3 ) "debug" "(" t = <IDENTIFIER> ")" { jjtThis.name = t. image; jjtThis. type = IDENTIFIER; jjtThis. line = t.beginLine; jjtThis . column = t .beginColumn; } I "debug" "(" t = <STRING_LITERAL> ")" { jjtThis. name = t. image; jjtThis. type = STRING_LITERAL; jjtThis. line = t.beginLine; jj tThis . column = t .beginColumn; } } void SearcherExpression ( ) #void : { Token t; } { ( "find" "(" t = <OBJ_IDENTIFIER> ")" { jjtThis.parmO = t. image; jjtThis. line = t.beginLine; j j tThis . column = t .beginColumn; } ) #FindExpression I ( "count" "(" t = <COUNT_OBJ_IDENTIFIER> ")" { jjtThis.name = t. image; jjtThis. line = t.beginLine; jjtThis. column = t .beginColumn; } ) #CountExpression } void FindWriteStatement ( ) : { Token t, u; ) { "findwrite" "(" t = <OBJ_IDENTIFIER> "," u = <STRING_LITERAL> ")" { jjtThis.name = t. image; jj tThis . format = u. image; jjtThis. line = t.beginLine; jjtThis .column = t .beginColumn; } } void ClassPrefaceStatement ( ) : { Token t; } { "classpreface" "(" t = <PREFACE_IDENTIFIER> ")" { jjtThis.name = t. image; jjtThis. line = t.beginLine; jjtThis. column = t .beginColumn; } } void WriteStatement ( ) : { Token t, u; } { LOOKAHEAD (3) "write" "(" t = <IDENTIFIER> "," u = <STRING_LITERAL> ")" { jjtThis.name = t. image; jjtThis. type = IDENTIFIER; jjtThis. format = u. image; jjtThis. line = t.beginLine; jj tThis . column t .beginColumn; } I "write" "(" t = <STRING_LITERAL> "," u = <STRING_LITERAL> ")" { jjtThis. name = t. image; jjtThis. type = STRING_LITERA ; jjtThis. format = u. image; jjtThis. line = t.beginLine; jjtThis. column t .beginColumn; } } void RulerExpression ( ) : { Token t; } £ ( "ruler" "(" t = <IDENTIFIER> ")" { jjtThis.name = t. image; jjtThis. line = t.beginLine; jjtThis .column = t .beginColumn; } ) } void ExceptionStatement ( ) : { Token t; } { ( "exception" "(" t = <STRING_LITERAL> ")" { jjtThis.name = t. image; jjtThis. line = t.beginLine; jjtThis .column = t .beginColumn; } ) } void TableStatement ( ) : { Token t, u; } { ( "table" t = <IDENTIFIER> "{" (TableElement () ) * "default" "," u = <STRING_LITERAL> " ; " { jjtThis.name = t. image; jj tThis . format = u. image; jjtThis. line = t.beginLine; j tThis . column = t .beginColumn; } ) } void TableElement ( ) : { Token t, u; } { ( t = <STRING_LITERAL> " , " u = <STRING_LITERAL> " ; " { j tThis.name = t. image; jjtThis . format = u. image; jjtThis. line = t.beginLine; jj tThis . column = t .beginColumn; } ) } void LookupExpression( ) : { Token t, u; } { LOOKAHEAD (5 ) "lookup" "(" t = <IDENTIFIER> "," u = <IDENTIFIER> ")" { jjtThis.name = t. image; jjtThis. type = IDENTIFIER; jjtThis. format = u. image; jjtThis. line = t.beginLine; jj tThis . column = t .beginColumn; } I "lookup" "(" t = <IDENTIFIER> "," u = <STRING_LITERAL> ")" { jjtThis. ame = t. image; jjtThis. type = STRING_LITERAL; jjtThis. format = u. image; jjtThis. line = t.beginLine,- jjtThis. column = t .beginColumn; } } void UtilityExpression ( ) #void : { Token t, u, v; } { ( "stringlength" "(" (t=<IDENTIFIER> | t=<STRING_LITERAL>) ")" { jjtThis.name = t. image; j tThis. line = t.beginLine; jtThis. column = t .beginColumn; } ) #StringLengthExpression I ( "stringequal" "(" ( t=<IDENTIFIER> | t=<STRING_LITERAL>) "," (u=<IDENTIFIER> I U=<STRING_LITERAL>) ")" { jjtThis.name = t. image; jj tThis . format = u. image; jjtThis. line = t.beginLine; jtThis .column = t .beginColumn; ) ) fStringEqualExpression I ( "midstring" "(" (t=<IDENTIFIER> | t=<STRING_LITERAL>) "," (u = <INTEGER_LITERAL> | u = <IDENTIFIER>) "," (v = <INTEGER_LITERAL> | v = <IDENTIFIER>) ")" { jjtThis.name = "midstring" ,- jj tThis .parmO = t. image; jjtThis .parml = u. image; jjtThis .parm2 = v. image; jjtThis. line = t.beginLine; jj tThis . column = t .beginColumn; } ) #MidStringExpression I ( "tointeger" "(" (t=<IDENTIFIER> | t=<STRING_LITERAL>) ")" { jjtThis.name = t. image; jjtThis. line = t.beginLine; jjtThis. column = t .beginColumn; } ) #ToIntegerExpression } void SystemExpression( ) ..void : { } { ( "majorver" "(" ")" ) #MajorVerExpression ( "minorver" "(" ")" ) #MinorVerExpression ( "time" "(" ")" ) #TimeExpression TOKEN : /* IDENTIFIERS */ { < IDENTIFIER: <LETTER> (<LETTER> | <DIGIT>) * > I < PREFACE_IDENTIFIER: (<IDENTIFIER> "/")* <IDENTIFIER> "." > < OBJ_IDENTIFIER: ( (<IDENTIFIER> "/")* (<IDENTIFIER> ("[" (<IDENTIFIER> | <INTEGER_LITERAL>) " ] " ) ? " . " ) * (<IDENTIFIER> ( " [ " (<IDENTIFIER>|<INTEGER_LITERAL>) "]")?))? ":" <IDENTIFIER> > I < COUNT_OBJ_IDENTIFIER: <IDENTIFIER> ("/" <IDENTIFIER>) * ( ("[" (<IDENTIFIER>|<INTEGER_LITERAL>) "]")? ("." <IDENTIFIER>) * )* ("[") ("]") > I < ..LETTER: [ "a"-"z", "A"-"Z" ] > I < #DIGIT: [ "0"-"9" ] > I < #PUNCTUATION: [ "[", "]", ".", ":", "/" ] > Object Mapping Commands Concepts About Object Mapping Statements Variable Declarations Statements Expressions Operators Examples Sample .map file About Object Mapping This help file describes the commands used to create mapping files between an object model and a legacy message. Variable Declarations Variables can be defined as one of three types: int <identif i er>; string <j den lfier>; boolean <iderιtifier>; Examples: int tempval; boolean exists4; Statements Execution control: if . . . else whil e Object Model manipulation: classpreface ( ) a_ssignments Map output: wri te ( ) findwrj te ( ) exception ( ) Data lookup: r.able Expressions Object Model manipulation: £.5 lid ( ) count ! i <iα -ιti fi c-r <cia; ss iden .tifi ,er> <cbi identi fier <cou: 'it obj iden ti fieri-' Data lookup: ruler ; } loo kιo_( ) String manipulation: strinαlenqch ( ) stringequal ( ) raids- rin ( ) ~ J nteger () Utilities: m." orvei" ( ) miriorver ( ) Operators Arithmetic: - + (addition) - (subtraction) * (multiplication) / (division) % (modulus) Relational: == (equal) !== (not equal) < (less than) > (greater than) <= (less than or equal) >~ (greater than or equal) Logical: & & ( logical AND) 1 1 ( logical OR) ! ( logical NOT ) Sample .map file classpreface (algebra/boolean. ) ; table xor { "00", "1"; "01", "0"; "10", "0"; "11", "1"; default, "X"; } string regl; string reg2; string xor__operands; string xor_result; regl = find (cpu. registers [0] : value) ; reg2 = find(cpu. registers [1] : alue) ; if (stringequal (regl, "0") && stringequal (reg2, "0") ) xor_operands = "00"; else if (stringequal (regl, "0") && stringequal (reg2, "1") ) xor_operands = "01"; else if (stringequal (regl, "1") && stringequal (reg2, "0") ) xor_operands = "10"; else if (stringequal (regl, "1") && stringequal (reg2, "1") ) xor_operands = "11"; else xor_operands = "*" ; xor_result = lookup (xor, xor_operands) ; write (xor result, "si" ) ; If... else statement See Also This statement modifies the flow of control, depending on the value of the <expression>. If the value is true, then the first set of statements is executed. Otherwise the second set (if it exists) is executed. Usage: if (<expression>) { <stateιr.en >; } else { <stateιr.ent>; } Returns: (none, statements don't return a value) Example: int i; if (i == 0) { write ("zero", "s4"); } else { write ( "some", "s4"); } While statement See Also This statement allows a block of statements to be repeated as long as <expression> evaluates to true. Usage: while (<expressiαn>) { <statc.ir.3n:,>; } Returns: (none, statements don't return a value) Example: int i ; i = 4; while (i > 0) { write ("some", "s4"); i = i - 1; } Classpreface statement See Also This statement allows the find, findwrite, and count statements to use an abbreviated object identifier. Once the classpreface has been set, subsequent Object Model manipulation statements will use it. Usage: classpreface (<class identifiers ) ; Returns: (none, statements don't return a value) Example: string s; classpreface (VendorSpecific/case . ) ; // the following find() command now returns // VendorSpecific/case .member : address s = find (member : address ) ; Write statement See Also This statement will append a formatted string to a buffer maintained by the map interpreter. The buffer is initially empty when interpretation of the map begins. Usage: write (<identifier , <string literal>) ; write ( s~ring ii ~ eral , <string literal>) ; Returns: (none, statements don't return a value) Example: string msg; msg = "Hello world!"; write (msg, "sl5") ; write ("Goodbye!", "+sl5") ; Assignments See Also Values can only be assigned to <identifiers> that have already been declared and whose types match. Usage: <identi≤ier> = <string literal>; <identifier> = <integer lι eral>; <i enti_:ier_> = 'bcolean li ~ eral>; Example: (Legal assignments) string s; s = "Meef"; int i; i = 123; boolean b; b = true; (Illegal assignments) string s; s = 123; int i; i = false; boolean b; b = "Hello world!"; Findwrite statement See Also This statement combines the functionality of the findO expression and the write () statement into a single instruction. Usage: findwrite (<obj identifier>, <string literal>) ; Returns: (none, statements don't return a value) Example: findwrite (case. member [0] : firstName, "slO") ; Exception statement See Also This statement causes the map interpreter to append a detailed error message to a collection of interpretation errors. Usage: exception (< string literal>) ; Returns: (none, statements don't return a value) Example: exception ( "Critical Element: Exclude Management Lookup Failed"); Table statement, Lookup expression See Also The combination of these commands allow a key value to select from possible result values. Usage: table <identifier> { <string literal> , <string literal>; default, <s ring litcral>; } lookup (--.iden i fier> / <s':ring literal-^) ; lookup (<identifier>, <jdentifier>) ; Returns: table : (none, statements don ' t return a value ) 1 ookup : st j rig Example: table states { "GA", "Georgia"; "IL", "Illinois"; default, "Colorado"; } string s; s = lookup (states, "GA"); Find expression See Also This expression returns the value of a particular <obi identifier within an object model as a string. Usage: find ( <obj identifier>) ; Returns: stri ng Example: string firstName; firstName = find (case.member [0] : firstName) Count expression See Also This expression returns the number of objects within an occurrence of a particular <count obj identifier as an integer. Usage: count (<count obj identifier.*-) ; Returns: Example: int i; i = count (case .members []) ; i = count (case .member [0] . dependents [ ] Ruler expression See Also This statement calls a hard-coded rule within the Integration Framework. These rules are compiled into the Integration Framework, and this statement calls the rule at the appropriate position in the map. Usage: ruler ( . s^ ng_^i e al>) ; Returns: string Example: string s; s = ruler ("NetAssetValue") ; write (s, "s8") ; Stringlength expression See Also This expression returns the number of characters contained within either a <strinq literal> or a string represented by an <identifier>. Usage: stringlength (<string literal>) ; stringlength (<identifier>) ; Returns: int Example: int len; len = stringlength ("Hello World!"); string msg; msg = "Meef ! "; len = stringlength (msg) ; Stringequal expression See Also This expression returns a boolean value indicating whether the strings represented by the two arguments are the same. Usage: stringequal (<string literal>, <string literal>) ; stringequal (<s ring literal >, <idsntif ieι>) ; stringequal (< identi ier}', strιr l σ_li αrαl>) ; stringequal (<icic-ntificr>, ia r. ifiex>) ; Returns: boolean Example: string si; string s2; boolean result; si = " eef"; s2 = " urf"; result = stringequal (si, s2) ; Midstring expression See Also This expression returns a subset of the set of characters comprising the string l_.tera_> or initial iden ~ ifisr> argument. Usage: midstring (<s ring literal>, <in eger literal>, <integer literal>) ; midstring (<identifier>, <integer Iiteral>, <inteqer literal>) ; midstring (<string li eral>, <integer literal>, <identifier>) ; midstring ( <i entifier>, integer literal>,<identifi3r>) ; midstring (<s _r ir.g li cral>, <identifier > < integer literal>) ; midstring (<identificr>, <identifier.--, '"integer litexal>) ; midstring (<s ring literal>, <idontifie >, <identifier>) ; midstring ( _ ___t__^9 ' i'^I\ ^_®-^' <identifier ) ; Returns: string Example: int startpos; int len; string substring; startpos = 2; len = 3; substring = midstring ( "Hello World! ", startpos, len) ; Tointeger expression See Also This expression returns the ' alue represented by a <strinq iiteral> or <identifier> as an integer. Usage: tointeger (--string literal>) ; tointeger ( <identi ier ) ; Returns: int Example: int value; value = tointeger ("512") ; Majorver expression See Also This expression returns the major version number of the grammar used to interpret the map. Usage: maj orver ( ) ; Returns: lot Example: int majorVer; majorVer = majorver(); Minorver expression See Also This expression returns the minor version number of the grammar used to interpret the map. Usage: minorver ( ) ; Returns: int Example: int minorVer; minorVer = minorverQ; Time expression See Also This expression returns the current date and time as a string. Usage: t ime ( ) ; Returns: st ing Example: string currentDate; currentDate = time();

Claims: CLAIMS 1. A method for translating to and from an hierarchical information system, comprising: identifying a non-hierarchical information system containing information stored in a non-hierarchical manner; developing a translation map that identifies organizational and content based rules for translating the non-hierarchical information into an hierarchical information system; and translating the non-hierarchical information for storage into the hierarchical information system according to the rules for translating. 2. A computerized method for translating to and from an hierarchical information system, comprising: identifying a non-hierarchical information system containing information stored in a non-hierarchical manner; developing a translation map that identifies organizational and content based rules for translating the non-hierarchical information into an hierarchical information system; and translating the non-hierarchical information for storage into the hierarchical information system according to the rules for translating. 3. A system for translating to and from an hierarchical information system, comprising: means for identifying a non-hierarchical information system containing information stored in a non-hierarchical manner; means for developing a translation map that identifies organizational and content based rules for translating the non-hierarchical information into an hierarchical information system; and means for translating the non-hierarchical information for storage into the hierarchical information system according to the rules for translating. 4. A system for translating to and from an hierarchical information system, comprising: a first computer system having a memory for storing information in an hierarchical information system; an interface coupled to the first computer system, the interface having means for identifying a non-hierarchical information system containing information stored in a non-hierarchical manner, developing a translation map that identifies organizational and content based rules for translating the non- hierarchical information into an hierarchical information system, and translating the non-hierarchical information for storage into the hierarchical information system according to the rules for translating; and a second computer system coupled to the interface, the second computer system having a memory for storing information in a non- hierarchical information system. 5. A method for translating to and from an hierarchical information system, comprising: translating data from an object model into a legacy message. 6. The method of claim 5, wherein said translating comprises: reading first data from said object model; translating said first data into second data; writing said second data into said legacy message. 7. A method for translating to and from an hierarchical information system, comprising: translating data from a legacy message model into an object. 8. The method of claim 7, wherein said translating comprises: reading first data from said legacy message; translating said first data into second data; writing said second data into said object model. 9. A method for translating to and from an hierarchical information system, comprising: identifying an hierarchical information system containing information stored in an hierarchical manner; developing a translation map that identifies organizational and content based rules for translating the hierarchical information into an non- hierarchical information system; and translating the hierarchical information for storage into the non- hierarchical information system according to the rules for translating. 10. A computerized method for translating to and from an hierarchical information system, comprising: identifying an hierarchical information system containing information stored in an hierarchical manner; developing a translation map that identifies organizational and content based rules for translating the hierarchical information into an non- hierarchical information system; and translating the hierarchical information for storage into the non- hierarchical information system according to the rules for translating. 11. A system for translating to and from an hierarchical information system, comprising: means for identifying an hierarchical information system containing information stored in an hierarchical manner; means for developing a translation map that identifies organizational and content based rules for translating the hierarchical information into a non-hierarchical information system; and means for translating the hierarchical information for storage into the non-hierarchical information system according to the rules for translating. 12. A system for translating to and from an hierarchical information system, comprising: a first computer system having a memory for storing information in a non-hierarchical information system; an interface coupled to the first computer system, the interface having means for identifying an hierarchical information system containing information stored in an hierarchical manner, developing a translation map that identifies organizational and content based rules for translating the hierarchical information into a non-hierarchical information system, and translating the hierarchical information for storage into the non-hierarchical information system according to the rules for translating; and a second computer system coupled to the interface, the second computer system having a memory for storing information in an hierarchical information system.

Inventors: HUDGONS MORRISHA, JOSHI DHANANJAY M, MILLEKER WILLIAM N, PHILLIPS JAY, HUDGONS, MORRISHA, JOSHI, DHANANJAY, M., MILLEKER, WILLIAM, N., PHILLIPS, JAY
Applicants: ANDERSEN CONSULTING LLP, ANDERSEN CONSULTING L.L.P.
Application year: 2000
Main classification: G06F9
IPC codes: G06F17