WO1998035305A1 - Method and apparatus for web site management - Google Patents

Method and apparatus for web site management Download PDF

Info

Publication number
WO1998035305A1
WO1998035305A1 PCT/US1998/001897 US9801897W WO9835305A1 WO 1998035305 A1 WO1998035305 A1 WO 1998035305A1 US 9801897 W US9801897 W US 9801897W WO 9835305 A1 WO9835305 A1 WO 9835305A1
Authority
WO
WIPO (PCT)
Prior art keywords
int
public
return
new
code
Prior art date
Application number
PCT/US1998/001897
Other languages
French (fr)
Inventor
Maria F. Fernandez
Daniela D. Florescu
Jaewoo Kang
Alon Y. Levy
Dan Suciu
Original Assignee
At & T Corp.
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by At & T Corp. filed Critical At & T Corp.
Publication of WO1998035305A1 publication Critical patent/WO1998035305A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • G06F16/972Access to data in other repository systems, e.g. legacy data or dynamic Web page generation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y10TECHNICAL SUBJECTS COVERED BY FORMER USPC
    • Y10STECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y10S707/00Data processing: database and file management or data structures
    • Y10S707/99931Database or file accessing
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y10TECHNICAL SUBJECTS COVERED BY FORMER USPC
    • Y10STECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y10S707/00Data processing: database and file management or data structures
    • Y10S707/99931Database or file accessing
    • Y10S707/99932Access augmentation or optimizing
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y10TECHNICAL SUBJECTS COVERED BY FORMER USPC
    • Y10STECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y10S707/00Data processing: database and file management or data structures
    • Y10S707/99931Database or file accessing
    • Y10S707/99933Query processing, i.e. searching
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y10TECHNICAL SUBJECTS COVERED BY FORMER USPC
    • Y10STECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y10S707/00Data processing: database and file management or data structures
    • Y10S707/99931Database or file accessing
    • Y10S707/99933Query processing, i.e. searching
    • Y10S707/99934Query formulation, input preparation, or translation
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y10TECHNICAL SUBJECTS COVERED BY FORMER USPC
    • Y10STECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y10S707/00Data processing: database and file management or data structures
    • Y10S707/99931Database or file accessing
    • Y10S707/99933Query processing, i.e. searching
    • Y10S707/99936Pattern matching access
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y10TECHNICAL SUBJECTS COVERED BY FORMER USPC
    • Y10STECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y10S707/00Data processing: database and file management or data structures
    • Y10S707/99941Database schema or data structure
    • Y10S707/99944Object-oriented database structure
    • Y10S707/99945Object-oriented database structure processing
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y10TECHNICAL SUBJECTS COVERED BY FORMER USPC
    • Y10STECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y10S707/00Data processing: database and file management or data structures
    • Y10S707/99951File or database maintenance
    • Y10S707/99952Coherency, e.g. same view to multiple users
    • Y10S707/99953Recoverability

Definitions

  • the application also includes an Appendix, containing computer program segments, that is herein incorporated by reference .
  • the invention relates to web site management. More particularly, the invention relates to creating and maintaining a web site using a query language.
  • Creating and maintaining large web sites is a tedious and time consuming task.
  • a site designer must simultaneously preform at least three tasks: (1) choosing what information will be available at the site; (2) organizing that information in individual pages or in graphs of linked pages; and (3) specifying the visual pages using a graphical presentation language such as Hypertext Markup Language (HTML) .
  • HTML Hypertext Markup Language
  • a web site comprises hundreds or even thousands of individual HTML pages ("web page") . If a web site manager wants to modify the visual presentation of information at a web site, the manager must access each individual web page one at a time and make the desired changes.
  • a web site manager might want different presentations for a web site depending on the viewer or the type of browser used. For example, access to AT&T's website might be different for internal AT&T users than external users. Another example would be that users might use different browsers such as Netscape Navigator, available from Netscape Communications, Inc., the Internet Explorer, availaoxe from Microsoft Corp, and so forth, thereby necessitating different versions of a webpage optimized for use w th the browser. As a result, a web site manager would "ave to create and maintain multiple copies of each wee cage, which would add to the ted ousness associated with maintaining the web site.
  • CNN's web site When a user enters the Universal Resource Locator (URL) or Internet address for CNN' s web site into a browser, an initial web page is presented to the user. This web page is referred to as the "root" web page.
  • CNN's root web page provides tne user with headlines of current domestic and world news. If a user wants to read an abstract of an article, the full text of the article, or related articles, the user simply clicks on the appropriate hypertext link to view the web page having the desired information ("linked web page").
  • CNN's web site also provides pictures and graphics along with some of its articles. The telecommunications technology allowing some users access to CNN's web site, however, is older and relatively slow.
  • CNN offers a text-only view of its root web page to increase the speed in which the root web page is downloaded to the user's browser.
  • CNN's web site makes this feature available only for CNN' s root web page, and not its linked web pages.
  • One reason for this is that each individual web page would have to be accessed by the CNN web site manager, and all HTML commands to display image and graphic files would have to be manually removed.
  • each web page would have to be stored twice, once with the image and graphic HTML commands, and once without these commands. Both options are unacceptable to many web site managers.
  • conventional web site management programs have been created to generate a web page using a query language rather than actually writing specific HTML commands for every web page, and storing these commands in separate files. Thus, when a web site manager needs to modify the web site, he merely modifies the query statements used in generating the web pages.
  • a method and apparatus for managing a web-site are provided.
  • An information definition query is received for defining an integrated view of non-uniform information retrieved from a multiple sources across a network, and stored in multiple formats.
  • An integrated view is created according to the information definition query.
  • a site definition query is received for defining a site view for the non-uniform information at the website.
  • the site view is created according to the site definition query.
  • the non-uniform information is then presented on the web-site, typically in the form of a HTML document .
  • FIG. 1 a web site management system in accordance with one embodiment of the invention.
  • FIG. 2 is a block diagram of a server implementing the functionality of STRUDEL m accordance with one embodiment of the invention.
  • FIG. 3 is a block-flow diagram m accordance with one embodiment of the invention.
  • FIG. 4 illustrates a traversal for a query m accordance with one embodiment of the invention.
  • the present invention includes a method and apparatus which applies concepts from data base management systems to the process of building web sites.
  • a web site manager can separate the logical view of information available at a web site, the structure of that information m linked pages, and the graphical presentation of pages in HTML.
  • the site builder defines independently the data that will be available at the site. This process may require creating an integrated view of data from multiple (external) sources.
  • the site builder defines the structure of the web site. The structure is defined as a view over the underlying information, and different versions of the site can be defined by specifying multiple views.
  • the graphical representation of tne pages in the web site is specified.
  • FIG. 1 a web site management system in accordance with one embodiment of the invention.
  • This embodiment of the invention is referred to hereinafter as "STRUDEL".
  • terminal station 10 is connected to a server 12 implementing the functionality for STRUDEL ("STRUDEL Server 12") .
  • STRUDEL Server 12 implementing the functionality for STRUDEL
  • Server 12 is connected to WWW 14, which includes web servers 16 which are connected to web page 18 and RDB/OODB 20, respectively.
  • Terminal station 10 includes a personal computer having a microprocessor and means for storing data and/or software such as random access memory and/or a hard disk drive, and which is capable of communicating with a network.
  • the client computer is capable of providing output for display to a user, for example through a video display. Such output may take the form of at least one of textual, graphic, animation, video, audio, or virtual object media.
  • the client computer is also capable of accepting input from a user. Such input may be provided by means such as a keyboard, a mouse, a telephone touch pad, a television remote control, and so on.
  • STRUDEL Server 12 includes a server computer having a microprocessor and means for storing data and/or software such as random access memory and/or a hard disk drive, and which is capable of communicating with a network.
  • a server computer is similar to a client computer, but is generally more powerful than a client in that it has greater processing power or larger amounts of static or dynamic memory.
  • FIG. 2 is a block diagram of a server implementing STRUDEL in accordance with one embodiment of the invention.
  • Server 12 communicates with WWW 14 through a communications link.
  • Server 12 comprises a main memory module 24, a central processing unit (CPU) 26, a query processor module 28, a bus adapter 30, a HTML generator module 32, a site definition module 34, and a mediator module 36, each of which is connected to a CPU/memory bus 22 and an Input/Output (I/O) bus 38 via bus adapter 30 as shown in FIG. 2.
  • server 12 contains multiple modules 24, a central processing unit (CPU) 26, a query processor module 28, a bus adapter 30, a HTML generator module 32, a site definition module 34, and a mediator module 36, each of which is connected to a CPU/memory bus 22 and an Input/Output (I/O) bus 38 via bus adapter 30 as shown in FIG. 2.
  • server 12 contains multiple modules
  • I/O controllers 40 as well as keyboard 42, a monitor 44, a STRUDEL data repository 46, and a packet network interface 48, each of which is connected to I/O bus 38 via I/O controllers 40.
  • the overall functioning of server 12 is controlled by CPU 26, which operates under the control of executed computer program instructions that are stored in main memory 24.
  • Main memory 24 may be any type of machine readable storage device, such as random access memory (RAM) , read only memory (ROM) , programmable read only memory (PROM), erasable programmable read only memory (EPROM) , electronically erasable programmable read only memory (EEPROM) , magnetic storage media (i.e., a magnetic disk) , or optical storage media (i.e., a CD-ROM) .
  • server 12 may contain various combinations of machine readable storage devices through other I/O controllers, which are accessible by CPU 26, and which are capable of storing a combination of computer program instructions and data.
  • CPU 26 includes any processor of sufficient processing power to perform the STRUDEL functionality found in server 12. Examples of CPUs suitable to practice the invention includes the INTEL family of processors, such as the Pentium®, Pentium Pro®, and
  • Packet network interface 48 is used for communications between server 12 and a packet network, such as a Transmission Control Protocol/Internet Protocol
  • TCP/IP Transmission Control Protocol/IP Network
  • Internet such as the Internet, and WWW 14.
  • Interfaces to other packet networks using different protocols such as X.25 are also possible.
  • I/O controllers 40 are used to control the flow of information between server 12 and a number of devices or networks such as keyboard 42, monitor 44, STRUDEL data repository 46, and packet network interface 48.
  • Bus adapter 30 is used for transferring data back and forth between CPU/memory bus 22 and I/O bus 38.
  • Modules 28, 32, 34 and 36 implement the main STRUDEL functionality for server 12. It is noted that each module 28, 32, 34, and 36 is shown as a separate functional module in FIG. 2. The functionality of each of modules 28, 32, 34, and 36 may be implemented in hardware, software, or a combination of hardware and software, using well-known signal processing techniques. The operation of Server 12, and the functioning of modules 28, 32, 34 and 36, will be described in further detail below with reference to FIG 3.
  • FIG. 3 is a block-flow diagram in accordance with one embodiment of the present invention. As shown m
  • STRUDEL models the data at different levels as graphs. That is, the data in the external sources, the data in the integrated view and the web site itself are modeled as graphs.
  • a graph model is appropriate since site data may be derived from multiple sources, such as existing data base systems and HTML files. Consequently, a query language is used for: (1) defining the integrated view of the data; and (2) defining the structure of web sites.
  • the query language should be capable of constructing graphs.
  • the query processor should be able to answer queries that involve accessing different data sources. Although the sources of data are modeled as containing graphs, there may not be a uniform representation of graphs. Hence, the query processor needs to adhere to possible limitations on access to data in the graphs,, and should be able to exploit additional querying capabilities that an external source may have.
  • a query language and query processor suitable for use with this embodiment of the invention will be discussed in more detail later.
  • STRUDEL data at every level of the system is viewed uniformly as a graph.
  • data is stored in a STRUDEL data repository or in external sources, such as RDB/OODB 20 and HTML page 18, at the bottom most level.
  • External sources may have a variety of formats, but each is translated into the graph data model by a wrapper 50.
  • a wrapper acts as a translator from one data model to another.
  • An example of a wrapper suitable for use by STRUDEL is discussed in a paper by Y. Papakonstantmou et al. titled "A query translation scheme for rapid implementation of wrappers", Int'l Conf. on Deductive and Object-Oriented Databases, 1995, which is incorporated by reference herein.
  • This embodiment of the invention utilizes a graph model similar to that of an object exchange model (OEM) , which is described in an article authored by Y. Papakonstantmou et al. titled “Object Exchange across heterogeneous information sources,” published in Proceedings IEEE International Conference on Data Engineering, March 1995, which is incorporated by reference herein.
  • a data graph contains objects connected by directed edges labeled with string valued attribute names.
  • Objects are either nodes, carrying a unique objected identifier (OID) , or are atomic values, such as integers, strings, files and so forth.
  • This embodiment of the invention also provides named collections of objects, i.e., sets of OIDs. These names and collections of objects, however, can also be represented as a wide sub tree.
  • the central data repository for this embodiment of the invention is the data graph.
  • a data graph describes the logical structure of all the information available at that site.
  • STRUDEL obtains a data graph using a mediator module 36.
  • Mediator module 36 integrates information from the various external sources into a single data graph accessible by the STRUDEL system.
  • An example of a mediator capable of working with the STRUDEL system includes the mediator disclosed m United States Patent Number 5,600,831 ("Levy Patent”), issued on February 4, 1997, and which is incorporated by reference herein.
  • a site builder can define one or more site graphs.
  • STRUDEL generates a site graph using a site definition module 34.
  • Each site graph represents the logical structure of the information displayed at the site (i.e. , a node for every web page and attributes describing the information m the page and links between pages) .
  • STRUDEL uses a HTML generator module 32 to construct a browsable HTML graph from the site graph.
  • the HTML generator creates a web page for every node m the site graph, using the values of the attributes of the node .
  • the STRUDEL system can be illustrated using the following example.
  • a web site manager uses terminal station 10 to access server 12.
  • the web site manager To create a new web site, or to define a new domain of information to display at an existing web site, the web site manager generates a query statement ("information definition query") defining the scope of information to be displayed at the definition web site.
  • STRUDEL uses a proprietary query language referred to as Site Transformation Und Query Language (StruQL), which is discussed in more detail later.
  • the information definition query statement is processed by query processor 28, which passes on the processed query statement to Mediator module 36.
  • Query processor 28 processes the query statement, and m some instances, optimizes the query statement to perform a better search.
  • Mediator module 36 accesses STRUDEL data repository 46 to search for information in accordance with the information definition query statement.
  • Mediator module 36 also accesses the Internet and WWW 14 to search, for example, external sources such as RDB/OODB 20 and/or HTML pages 18 for the specified information.
  • external sources such as RDB/OODB 20 and/or HTML pages 18 for the specified information.
  • Mediator module 36 would be robust enough to work within any limitations on access to data in the external source graphs, and should be able to exploit additional querying capabilities that an external source may have.
  • Mediator module 36 then creates an integrated view of all the data that will be available at the site found in the multiple external sources and STRUDEL data repository 46. This integrated view is stored as a data graph in accordance with the techniques discussed m more detail m the Levy Patent .
  • the web site manager generates a query defining the actual structure of the web site ("site definition query") .
  • the structure is defined as a structural view over the integrated view, .e., a node for every web page and attributes describing the information m the page and links between pages. Different versions of the web site can be defined by specifying multiple structural views.
  • the site definition query is processed by query processor 28, and is passed on to site definition module 34.
  • a site graph is created for each structural view.
  • HTML generator module 32 constructs a browsable HTML graph in accordance with each site graph. HTML generator 32 creates a web page for every node in the site graph, using the values of the attributes of the node.
  • a web site manager wants to create a web site having all Post Script papers directly accessible from home/root pages.
  • the web site manager would construct an information definition query (described in more detail below) which is possessed by query processor 28, and passed to mediator module 36.
  • mediator module 36 would create a data graph with this information.
  • the web site manager would want each PostScript paper presented in the following format: Title, Author, Cite, and Abstract, with links to related articles.
  • the web site manager would construct the appropriate site definition query, which is processed by query processor 28, and passed to site definition 34.
  • Site definition 34 would create the appropriate site graph. HTML generator module 32 would then create a web page for every node in the site graph, using the values of the attributes of the node.
  • STRUDEL needs to query and/or to transform graphs:
  • STRUDEL' s design provides an interface for ad-hoc queries over a web site.
  • a query and transformation language referred to as StruQL is used at all three levels.
  • StruQL' s core fragment is described next.
  • a StruQL query has the form:
  • HomePages is a collection, "Paper” is an edge label, and isPostScript is a predicate testing whether node q is a PostScript file.
  • the condition p "Paper " q means that there exits an edge labeled " Paper” from p to g.
  • the query constructs a new collection, PostSc ⁇ ptPages , consisting of all answers.
  • each condition C ⁇ ,...,Ca in a where clause either (1) tests collection membership, e.g., HomePages (p) , or (2) is a regular path expression, e.g., p "Paper " q, or (3) is a built-in or external predicate applied to nodes or edges, e.g., isPostScript (q) , x > y, or (4) is a boolean combination of the above.
  • a condition of the form "x R y" means that there exists a path from node x to node y that matches the regular path expression R .
  • Regular path expressions are more general than regular expressions, because they permit predicates on edges and nodes.
  • isName * is a regular path expression denoting any sequence of labels such that each satisfies the isMame predicate.
  • true denotes any edge label, and true * any path; we abbreviate the latter with *.
  • Predl ; Pred2 matches any edge, node pair whose edge satisfies Predl and whose node satisfies Pred2.
  • Pred is shorthand for the idiom " Pred; true ", which ignores the node value. For example,
  • Root is a collection consisting of the graph's single root node.
  • St'ruQL extends these regular-expression based selections with the creation of new graphs from existing graphs; its create, and link clauses specify new graphs.
  • the following example copies the input graph and adds a "Home" edge from each node back to the root:
  • Root (p) , p * q, q 1 q' create N (p) , N (q) , N (q' ) link N(q)l N (q'), N (q) " Home” N(p) collect NewRoot (N(p))
  • N is a Skolem function creating new object OIDs.
  • the query first finds all nodes q reachable from the root p (including p itself) and all nodes q' directly accessible from q by one link labeled 1 . For each node q and q' , it constructs new nodes N (q) and N(q'): in effect, this copies all nodes accessible form the root once.
  • the query adds a link 1 between any pair of nodes that were linked in the original graph and adds a new Home link that points to the new root. Finally, it creates an output collection NewRoot that contains the new graph' s root.
  • a similar query produces a site graph, i.e., a view of the input graph, called TextOnly, that excludes any nodes that contain image files:
  • Root (p ) , P* q, q 1 q ' , not ⁇ isImageFi l e ( q ) ) create N (p) , N (q) , N (q' ) link N(q) 1 Nfq 1 ) collect TextOnlyRoot ⁇ ⁇ S (p) )
  • StruQL A distinguishing feature of StruQL is that its semantics can be described in two stages.
  • the query stage depends only on the where clause and produces all possible bindings of variables to values that satisfy all conditions in the clause; its result is a relation with one attribute for each variable.
  • the construction stage constructs a new graph from this relation, based on the create, link, collect clauses. These details are explained next .
  • every StruQL query has a well-defined meaning.
  • the query below returns the complement of a graph, i.e., the result graph contains an edge labeled 1 between two nodes if and only if no such label exists between the corresponding nodes in the input graph:
  • the active-domain semantics is unsatisfactory because it depends on how we define the active domain; the semantics changes if, for example, the active domain is computed only for the accessible part of the graph.
  • the situation is similar to the domain independence issue in the relational calculus: there it is solved by considering range-restricted queries, which are guaranteed to be domain independent, i.e., their semantics do not change if the active domain is artificially changed.
  • StruQL' s regular path expressions require graph traversal and, therefore, the computation of transitive closure.
  • the ability to compute the transitive closure of an input graph does not imply the ability to compute the transitive closure of an arbitrary binary or 2n-ary relation.
  • StruQL can express transitive closure of an arbitrary relation as the composition of two queries. For example, consider the tree-encoding of a binary relation R (A,B) with attributes A and B, as shown below. All nodes reachable from "x" can be calculated with two StruQL queries. The first constructs the graph corresponding to the relation R(A,B), and the second uses the regular expression * to find all nodes accessioie from the root. Input is a keyword that specifies the input to a query.
  • evaluation strategies are non-trivial, because although data in external sources is modeled as data graphs, the external sources may not support queries that traverse arbitrary paths through the data.
  • evaluation strategies are desired that can: 0
  • STRUDEL data graphs can be created by integrating information from external sources.
  • a simple strategy is to materialize external sources as data graphs and evaluate queries on the 5 materialized graphs.
  • a better strategy is to delay fetching of external data by pushing queries to the external sources.
  • Indexes may be available for data graph 0 materialized in the data repository and for the external sources. STRUDEL' s query processor should use these indexes whenever possible.
  • Handle limited capabilities The ability to traverse 5 edges forward and/or backward depends on the capability of a data source. In some externals, links may be traversed only in one direction. For example, the AT&T employee database requires certain attribute values such as last name or phone number, in order to extract any 0 information. In STRUDEL' s data model, this translates into certain edges being traversable in one direction.
  • StruQL' s abstract syntax
  • automata that compute regular path expressions
  • a physical query plan that 5 . incorporates the capabilities of the data source.
  • the first regular expression can be rewritten into an equivalent expression:
  • the resulting query is equivalent to the original, but it traverses each edge "A" accessible from the root once.
  • NDFA Non-Deterministic Finite Automaton
  • the operators at the physical level are the same as those found in relational query plans (see FIG. 4) .
  • the physical plans may have cycles.
  • the first two plans in FIG. 4 correspond to the left-to-right traversal of the automaton: they differ only in the fact that the first has a direct join while the second has a join.
  • the third execution plan corresponds to starting the automata in the state _: this could be advantageous if, for example, there is fast access to the collection C2.
  • the plan branches, searching for a C edge to Z on one hand, and for a backwards path to X on CI on the other hand. At the end it has to join the two results based on _.
  • the present invention uses an algebra for querying semi-structured data. Regular expressions are considered as atomic operations in this algebra (as part of the tree pa tterns in the scan operator) . This results in optimized queries at the select-project-join level.
  • the present invention also optimizes inside regular expressions so that STRUDEL' s execution plans are more fine grained, and generally have cycles.
  • Link_INT e new ink( ⁇ l, s2 , new UnaryBoolExprEps ()) ; return mem(e) ;
  • Link_INT e new Link (si, s2, b); return mem(e) ; ⁇ public void add(State_INT si, State_INT s2) ⁇
  • Link_INT e new Link(sl,s2, new UnaryBoolExprEps ()) ; w.addElement (e) ;
  • EdgeSet s new EdgeSet ( ) ;
  • State_INT a2 s .element (i) . getOutputState () ;
  • State_INT bl s .element (j ) .getlnputState () ;
  • EdgeSet epsStars makeEpsStars (Inks) ;
  • the user acknowledges and agrees to keep the code confidential and use the code solely for non-commercial research.
  • the user further acknowledges and agrees th at * the code is not an official product of AT&T Corp. , and is provided
  • AUTOMATA is a set of (state, edge, state) triples
  • Automata_INT extends Conjunct ⁇ public State_INT getlnputState ( ) ; public State_INT getOutputState () ; public Link_INT[] getLinks () ; public void elimEpsEdges ( ) ; public String toStringLong ( ) ; ⁇
  • HashSet cother boolean returnExp
  • ⁇ cother. add (this) ; return this; ⁇ public BoolExpr_INT gentleSeparate (HashSet cMemc, HashSet cXCc, HashS et cXYc,
  • the user acknowledges and agrees to keep the code confidential and use the code solely for non-commercial research.
  • the user further acknowledges and agrees th at * the code is not an official product of AT&T Corp., and is provided
  • StrudelError . checkArgCount (a. length, 2, ( (Symbol)p) .getName ()) ; else if (Strudel.isRelOp(p) )
  • StrudelError. checkArgCount (a. length, 2, ( (Symbol)p) .getName ()) ; else if (( (Symbol)p) .getName () .equals ( "Value” ) )
  • String s2 ( (StringDataValue) table [1] ) .
  • HashSet cother, boolean returnExp) ⁇ ValueExpr_INT [ ] nargs new ValueExpr_IN [args. length] ; try ⁇ if (pred. equals (Strudel. opEQ) ) ⁇ if ( ! returnExp) ⁇ if (args [0] instanceof ValueExprVar & args[l] instanceof Value ExprVar ) cXYc. add (this) ; else if( (args[0] instanceof ValueExprVar & args[l] instanceof V alueExprConst)
  • ValueExprVar sl new ValueExprVar (Strudel. symtab . genSym (Type . typeNode) ) ;
  • BoolExpr_INT extends Expr_INT ⁇ public String toStringO; public DataValue Eval (Binding b) ; public BoolExpr_INT gentleSeparate (HashSet cMemc, HashSet cXYc, Hash Set cXCc,
  • HashSet cother, boolean returnExp public BoolExpr_INT separate (HashSet cMemc, HashSet cXYc, HashSet cX
  • the user acknowledges and agrees to keep the code confidential and use the code solely for non-commercial research.
  • the user further acknowledges and agrees th at * the code is not an official product of AT&T Corp., and is provided
  • the user acknowledges and agrees to keep the code confidential and use the code solely for non-commercial research.
  • the user further acknowledges and agrees th at * the code is not an official product of AT&T Corp., and is provided
  • Expr_INT extends Conjunct ⁇ public Expr_INT[] getSubExprs () ; public DataValue Eval (Binding b) ; public String getName 0 ; ⁇
  • Link_INT extends Consume_INT ⁇ public State_INT getlnputState 0 ; public State_INT getOutputState () ; public UnaryBoolExpr_INT getLabel ( ) ; public boolean backEdge ⁇ ) ,-
  • StreamTokenizer stl new StreamTokenizer (new FileReader (args [0] ))
  • StreamTokenizer st2 new StreamTokenizer (new FileReader (args [1] )) ;
  • TT_EOF break out2; ⁇ ⁇ ⁇
  • MOAQL supports node, regular path, unary bool, collection, and boole an expressions. */ /*
  • HashSet set new HashSet ( ) ; set. add (var) ; return set ; ⁇ public String toOid (Binding b) ⁇ return b . getBinding ( (Symbol) var) . getUniqueOid O ; ⁇ public DataObject toObject (Binding b, StoredDataGraph g) ⁇ return b. getBinding ( (Symbol) var) ; ⁇ public String toDot ( ) ⁇ return "OldGraphNode” ; ⁇ ⁇
  • NodeExpr_INT extends Expr_INT ⁇ public String toStringO; public String toDot ( ) ; public String toOid(Binding b) ; public DataValue Eval (Binding b) ; public DataObject toObject (Binding b, StoredDataGraph g) ; ⁇
  • Nodes ⁇ and ⁇ em links ⁇ refer to the nodes and edges in a data g raph. */ /* We call the values of nodes [ [contents] ] and the values of
  • */ /* of a leaf node is an atomic value, called a [[DataValue]],
  • SGfile new PrintStrea (new FileOutputStream(Environment .getEnv ( "G S"))); printGraphSchema (SGfile) ;
  • Link_INT 1 ( (Link_INT) ( iter .nextElement () ) ) ;
  • NodeExpr_INT from l . getlnputState ( ) . getSymbol ( ) ;
  • NodeExpr_INT to l . getOutputState ( ) . getSymbol ( ) ; nodes . add( from. toDot ( ) ) ; nodes . ad ( to . toDot () ) ,-
  • Link_INT [ ] 1 new Link_INT [11. length+12. length+4] ;
  • a [[Rpe]] is a regular expression over pairs of (link attributes or
  • a [[Symbol]] has a name and a type.
  • the user acknowledges and agrees to keep the code confidential and use the code solely for non-commercial research.
  • the user further acknowledges and agrees th at * the code is not an official product of AT&T Corp., and is provided
  • Type.java> package Automata; import COM.objectspace. jgl .* ; import java.util.*; public class Type ⁇ static TypeNode typeNode new TypeNode ( ) static TypeLink typeLink new TypeLink ( ) static TypePath typePath new TypePath ( ) static TypeSkol typeSkol new TypeSkol ( ) static TypeColl typeColl new TypeColl 0 static TypePred typePred new TypePred ( ) static TypeString typeString new TypeString ( ) static Typelnt typelnt new Typelnt ( ) ; static TypeFloat typeFloat new TypeFloat ( ) ; static TypeBool typeBool new TypeBool ( ) ; static TypeAny typeAny new TypeAny () ; •
  • TypeBool implements Type_INT ⁇ public String getTypeO ⁇ return "TypeBool"; ⁇ ⁇ /*
  • TypeColl implements Type_INT ⁇ public String getType ( ) ⁇ return "TypeColl"; ⁇ ⁇ /*
  • TypeError String name, Type_INT expected, Type_INT found
  • ⁇ error "Type error for " + name + " : Expected " + expected. getT ype() + ". Found " + found. getTypeO + " ⁇ n”;
  • TypeFloat implements Type_INT ⁇ public String getTypeO ⁇ return "TypeFloat"; ⁇ ⁇ /*
  • Typelnt implements Type_INT ⁇ public String getTypeO ⁇ return "Typelnt"; ⁇ ⁇ /*
  • TypeLink implements Type_INT ⁇ public String getTypeO ⁇ return "TypeLink"; ⁇ ⁇ /*
  • the types are: nodes, links, paths, skolem functions,
  • TypeNode implements Type_INT ⁇ public String getTypeO ⁇ return "TypeNode"; ⁇ ⁇ /*
  • TypePath implements Type_INT ⁇ public String getTypeO ⁇ return "TypePath"; ⁇ ⁇ /*
  • TypePred implements Type_INT ⁇ public String getTypeO ⁇ return "TypePred"; ⁇ ⁇ /*

Abstract

A method and apparatus for managing a web-site. An information definition query is received for defining an integrated view of non-uniform information retrieved from multiple sources across a network, and stored in multiple formats. An integrated view is created according to the information definition query. A site definition query is received for defining a site view for the non-uniform information at the web-site. The site view is created according to the site definition query. The non-uniform information is then presented on the web-site, typically in the form of a HTML document.

Description

METHOD AND APPARATUS FOR WEB SITE MANAGEMENT
CROSS-REFERENCES TO RELATED APPLICATIONS
This application claims the benefit of U.S.
Provisional Application No. 60/036898, filed February 6,
1997, entitled "STRUDEL: A Web Site Management System."
The application also includes an Appendix, containing computer program segments, that is herein incorporated by reference .
FIELD OF THE INVENTION
The invention relates to web site management. More particularly, the invention relates to creating and maintaining a web site using a query language.
BACKGROUND OF THE INVENTION
Due to the popularity of the Internet and World Wide Web (WWW) , a growing number of companies are creating web sites having a tremendous amount of information. For example, Cab__.e News Network (CNN) nas its own web site at "http:Wwww.cnn.com" with current news and events in the United States and around the world. Similarly, AT&T Research has its own web site at "http:Wwww.research.att.com" posting information on AT&T employees, such as their fields of research, publications, current projects, ana so forth.
Creating and maintaining large web sites, however, is a tedious and time consuming task. A site designer must simultaneously preform at least three tasks: (1) choosing what information will be available at the site; (2) organizing that information in individual pages or in graphs of linked pages; and (3) specifying the visual pages using a graphical presentation language such as Hypertext Markup Language (HTML) . Furthermore, since there is no separation between the physical organization of the information at a web site and a logical view prepared for the information, changing or restructuring a site become an unwieldy task. Typically, a web site comprises hundreds or even thousands of individual HTML pages ("web page") . If a web site manager wants to modify the visual presentation of information at a web site, the manager must access each individual web page one at a time and make the desired changes. This requires a tremendous amount of work. In addition, a web site manager might want different presentations for a web site depending on the viewer or the type of browser used. For example, access to AT&T's website might be different for internal AT&T users than external users. Another example would be that users might use different browsers such as Netscape Navigator, available from Netscape Communications, Inc., the Internet Explorer, availaoxe from Microsoft Corp, and so forth, thereby necessitating different versions of a webpage optimized for use w th the browser. As a result, a web site manager would "ave to create and maintain multiple copies of each wee cage, which would add to the ted ousness associated with maintaining the web site.
The difficulties in maintaining a web site are demonstrated by CNN's web site. When a user enters the Universal Resource Locator (URL) or Internet address for CNN' s web site into a browser, an initial web page is presented to the user. This web page is referred to as the "root" web page. CNN's root web page provides tne user with headlines of current domestic and world news. If a user wants to read an abstract of an article, the full text of the article, or related articles, the user simply clicks on the appropriate hypertext link to view the web page having the desired information ("linked web page"). CNN's web site also provides pictures and graphics along with some of its articles. The telecommunications technology allowing some users access to CNN's web site, however, is older and relatively slow.
Thus, CNN offers a text-only view of its root web page to increase the speed in which the root web page is downloaded to the user's browser. CNN's web site, however, makes this feature available only for CNN' s root web page, and not its linked web pages. One reason for this is that each individual web page would have to be accessed by the CNN web site manager, and all HTML commands to display image and graphic files would have to be manually removed. Moreover, each web page would have to be stored twice, once with the image and graphic HTML commands, and once without these commands. Both options are unacceptable to many web site managers. In an attempt to solve the above problems, conventional web site management programs have been created to generate a web page using a query language rather than actually writing specific HTML commands for every web page, and storing these commands in separate files. Thus, when a web site manager needs to modify the web site, he merely modifies the query statements used in generating the web pages.
These conventional programs, however, are unsatisfactory for several reasons. First, these programs rely upon a programming language which is relatively complex, thereby trading one efficiency for another, namely, the tediousness of writing HTML commands for every web page for the difficulty of writing code using a complex programming language affecting all web pages. Second, these conventional programs require that all information or data presented by the web pages come from a single uniform data source such as a relational data base (RDB) or object-oriented data base (OODB) .
These programs are not capable of using information from multiple external sources stored in a variety of formats, as is the case with the information made available on such popular Wide Area Networks (WAN) as the Internet. This severely limits the robustness of the web site management program by limiting the domain of information from which the web site might draw to ultimately present to a user.
In view of the foregoing, it can be appreciated that a substantial need exists for a method and apparatus for creating and maintaining large web sites efficiently and effectively.
SUMMARY OF THE INVENTION
A method and apparatus for managing a web-site are provided. An information definition query is received for defining an integrated view of non-uniform information retrieved from a multiple sources across a network, and stored in multiple formats. An integrated view is created according to the information definition query. A site definition query is received for defining a site view for the non-uniform information at the website. The site view is created according to the site definition query. The non-uniform information is then presented on the web-site, typically in the form of a HTML document .
With these and other advantages and features of the invention that will become hereinafter apparent, the nature of the invention may be more clearly understood by reference to the following detailed description of the invention, the appended claims and to the several drawings attached herein.
BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 a web site management system in accordance with one embodiment of the invention. FIG. 2 is a block diagram of a server implementing the functionality of STRUDEL m accordance with one embodiment of the invention.
FIG. 3 is a block-flow diagram m accordance with one embodiment of the invention. FIG. 4 illustrates a traversal for a query m accordance with one embodiment of the invention.
DETAILED DESCRIPTION
The present invention includes a method and apparatus which applies concepts from data base management systems to the process of building web sites. In accordance with one embodiment of the present invention, a web site manager can separate the logical view of information available at a web site, the structure of that information m linked pages, and the graphical presentation of pages in HTML. First, the site builder defines independently the data that will be available at the site. This process may require creating an integrated view of data from multiple (external) sources. Second, the site builder defines the structure of the web site. The structure is defined as a view over the underlying information, and different versions of the site can be defined by specifying multiple views. Finally, the graphical representation of tne pages in the web site is specified.
Referring now m detail to the drawings wherein like parts are designated by like references numerals throughout, there is illustrated in FIG. 1 a web site management system in accordance with one embodiment of the invention. This embodiment of the invention is referred to hereinafter as "STRUDEL". As shown in FIG. 1, terminal station 10 is connected to a server 12 implementing the functionality for STRUDEL ("STRUDEL Server 12") . It is worthy to note that although the functionality for STRUDEL is implemented on the server side of a client-server model m this embodiment of the invention, this functionality could also be implemented on the client side, or on any general purpose computer having a microprocessor of sufficient processing speed, and memory. Server 12 is connected to WWW 14, which includes web servers 16 which are connected to web page 18 and RDB/OODB 20, respectively.
Terminal station 10 includes a personal computer having a microprocessor and means for storing data and/or software such as random access memory and/or a hard disk drive, and which is capable of communicating with a network. The client computer is capable of providing output for display to a user, for example through a video display. Such output may take the form of at least one of textual, graphic, animation, video, audio, or virtual object media. The client computer is also capable of accepting input from a user. Such input may be provided by means such as a keyboard, a mouse, a telephone touch pad, a television remote control, and so on.
STRUDEL Server 12 includes a server computer having a microprocessor and means for storing data and/or software such as random access memory and/or a hard disk drive, and which is capable of communicating with a network. Typically, a server computer is similar to a client computer, but is generally more powerful than a client in that it has greater processing power or larger amounts of static or dynamic memory.
FIG. 2 is a block diagram of a server implementing STRUDEL in accordance with one embodiment of the invention. Server 12 communicates with WWW 14 through a communications link. Server 12 comprises a main memory module 24, a central processing unit (CPU) 26, a query processor module 28, a bus adapter 30, a HTML generator module 32, a site definition module 34, and a mediator module 36, each of which is connected to a CPU/memory bus 22 and an Input/Output (I/O) bus 38 via bus adapter 30 as shown in FIG. 2. Further, server 12 contains multiple
I/O controllers 40, as well as keyboard 42, a monitor 44, a STRUDEL data repository 46, and a packet network interface 48, each of which is connected to I/O bus 38 via I/O controllers 40. The overall functioning of server 12 is controlled by CPU 26, which operates under the control of executed computer program instructions that are stored in main memory 24. Main memory 24 may be any type of machine readable storage device, such as random access memory (RAM) , read only memory (ROM) , programmable read only memory (PROM), erasable programmable read only memory (EPROM) , electronically erasable programmable read only memory (EEPROM) , magnetic storage media (i.e., a magnetic disk) , or optical storage media (i.e., a CD-ROM) . Further, server 12 may contain various combinations of machine readable storage devices through other I/O controllers, which are accessible by CPU 26, and which are capable of storing a combination of computer program instructions and data.
CPU 26 includes any processor of sufficient processing power to perform the STRUDEL functionality found in server 12. Examples of CPUs suitable to practice the invention includes the INTEL family of processors, such as the Pentium®, Pentium Pro®, and
Pentium II® microprocessors.
Packet network interface 48 is used for communications between server 12 and a packet network, such as a Transmission Control Protocol/Internet Protocol
(TCP/IP) Network such as the Internet, and WWW 14.
Interfaces to other packet networks using different protocols such as X.25 are also possible.
I/O controllers 40 are used to control the flow of information between server 12 and a number of devices or networks such as keyboard 42, monitor 44, STRUDEL data repository 46, and packet network interface 48.
Bus adapter 30 is used for transferring data back and forth between CPU/memory bus 22 and I/O bus 38. Modules 28, 32, 34 and 36 implement the main STRUDEL functionality for server 12. It is noted that each module 28, 32, 34, and 36 is shown as a separate functional module in FIG. 2. The functionality of each of modules 28, 32, 34, and 36 may be implemented in hardware, software, or a combination of hardware and software, using well-known signal processing techniques. The operation of Server 12, and the functioning of modules 28, 32, 34 and 36, will be described in further detail below with reference to FIG 3. FIG. 3 is a block-flow diagram in accordance with one embodiment of the present invention. As shown m
FIG. 3, STRUDEL models the data at different levels as graphs. That is, the data in the external sources, the data in the integrated view and the web site itself are modeled as graphs. A graph model is appropriate since site data may be derived from multiple sources, such as existing data base systems and HTML files. Consequently, a query language is used for: (1) defining the integrated view of the data; and (2) defining the structure of web sites. The query language should be capable of constructing graphs. Further, the query processor should be able to answer queries that involve accessing different data sources. Although the sources of data are modeled as containing graphs, there may not be a uniform representation of graphs. Hence, the query processor needs to adhere to possible limitations on access to data in the graphs,, and should be able to exploit additional querying capabilities that an external source may have. A query language and query processor suitable for use with this embodiment of the invention will be discussed in more detail later.
In STRUDEL, data at every level of the system is viewed uniformly as a graph. Referring again to FIG. 3, data is stored in a STRUDEL data repository or in external sources, such as RDB/OODB 20 and HTML page 18, at the bottom most level. External sources may have a variety of formats, but each is translated into the graph data model by a wrapper 50. A wrapper acts as a translator from one data model to another. An example of a wrapper suitable for use by STRUDEL is discussed in a paper by Y. Papakonstantmou et al. titled "A query translation scheme for rapid implementation of wrappers", Int'l Conf. on Deductive and Object-Oriented Databases, 1995, which is incorporated by reference herein.
This embodiment of the invention utilizes a graph model similar to that of an object exchange model (OEM) , which is described in an article authored by Y. Papakonstantmou et al. titled "Object Exchange across heterogeneous information sources," published in Proceedings IEEE International Conference on Data Engineering, March 1995, which is incorporated by reference herein. A data graph contains objects connected by directed edges labeled with string valued attribute names. Objects are either nodes, carrying a unique objected identifier (OID) , or are atomic values, such as integers, strings, files and so forth. This embodiment of the invention also provides named collections of objects, i.e., sets of OIDs. These names and collections of objects, however, can also be represented as a wide sub tree. The central data repository for this embodiment of the invention is the data graph. A data graph describes the logical structure of all the information available at that site. STRUDEL obtains a data graph using a mediator module 36. Mediator module 36 integrates information from the various external sources into a single data graph accessible by the STRUDEL system. An example of a mediator capable of working with the STRUDEL system includes the mediator disclosed m United States Patent Number 5,600,831 ("Levy Patent"), issued on February 4, 1997, and which is incorporated by reference herein.
Once the data graph is established, a site builder can define one or more site graphs. STRUDEL generates a site graph using a site definition module 34. Each site graph represents the logical structure of the information displayed at the site (i.e. , a node for every web page and attributes describing the information m the page and links between pages) . There can be several site graphs, because one site may offer several views of its data, with each site graph corresponding to one view.
Once the data graph and site graph are generated for a web site, STRUDEL uses a HTML generator module 32 to construct a browsable HTML graph from the site graph. The HTML generator creates a web page for every node m the site graph, using the values of the attributes of the node .
The STRUDEL system can be illustrated using the following example. A web site manager uses terminal station 10 to access server 12. To create a new web site, or to define a new domain of information to display at an existing web site, the web site manager generates a query statement ("information definition query") defining the scope of information to be displayed at the definition web site. STRUDEL uses a proprietary query language referred to as Site Transformation Und Query Language (StruQL), which is discussed in more detail later. The information definition query statement is processed by query processor 28, which passes on the processed query statement to Mediator module 36. Query processor 28 processes the query statement, and m some instances, optimizes the query statement to perform a better search.
Mediator module 36 accesses STRUDEL data repository 46 to search for information in accordance with the information definition query statement. Mediator module 36 also accesses the Internet and WWW 14 to search, for example, external sources such as RDB/OODB 20 and/or HTML pages 18 for the specified information. To augment this search, Mediator module 36 would be robust enough to work within any limitations on access to data in the external source graphs, and should be able to exploit additional querying capabilities that an external source may have. Mediator module 36 then creates an integrated view of all the data that will be available at the site found in the multiple external sources and STRUDEL data repository 46. This integrated view is stored as a data graph in accordance with the techniques discussed m more detail m the Levy Patent .
Once Mediator module 36 creates the data graph, the web site manager generates a query defining the actual structure of the web site ("site definition query") . The structure is defined as a structural view over the integrated view, .e., a node for every web page and attributes describing the information m the page and links between pages. Different versions of the web site can be defined by specifying multiple structural views. The site definition query is processed by query processor 28, and is passed on to site definition module 34. A site graph is created for each structural view.
Once tne data graph and site graph (s) are created, HTML generator module 32 constructs a browsable HTML graph in accordance with each site graph. HTML generator 32 creates a web page for every node in the site graph, using the values of the attributes of the node.
Thus, for example, assume that a web site manager wants to create a web site having all Post Script papers directly accessible from home/root pages. The web site manager would construct an information definition query (described in more detail below) which is possessed by query processor 28, and passed to mediator module 36. Mediator module 36 would create a data graph with this information. Also assume that the web site manager would want each PostScript paper presented in the following format: Title, Author, Cite, and Abstract, with links to related articles. The web site manager would construct the appropriate site definition query, which is processed by query processor 28, and passed to site definition 34.
Site definition 34 would create the appropriate site graph. HTML generator module 32 would then create a web page for every node in the site graph, using the values of the attributes of the node.
The Query Language
STRUDEL needs to query and/or to transform graphs:
(1) at the in tegra tion level, when data from different external sources is integrated into the data graph, and
(2) at the si te-graph defini ti on level, when site graphs are constructed from a data graph. In addition, STRUDEL' s design provides an interface for ad-hoc queries over a web site. A query and transformation language referred to as StruQL is used at all three levels.
StruQL' s core fragment is described next. A StruQL query has the form:
where Cι r . . . , Ck,
[create Ni, ... ,Nn]
[link Li, ... ,LP]
[collect Gi, ... ,Gq]
For example, the following query returns all
PostScript papers directly accessible from home pages:
where HomePages (p) , p "Paper" q, isPos tScript (q) collect PostScript Pages (q)
Here HomePages is a collection, "Paper" is an edge label, and isPostScript is a predicate testing whether node q is a PostScript file. The condition p "Paper " q means that there exits an edge labeled " Paper" from p to g. The query constructs a new collection, PostScπptPages , consisting of all answers.
In the general syntax, each condition Cι,...,Ca in a where clause either (1) tests collection membership, e.g., HomePages (p) , or (2) is a regular path expression, e.g., p "Paper " q, or (3) is a built-in or external predicate applied to nodes or edges, e.g., isPostScript (q) , x > y, or (4) is a boolean combination of the above. A condition of the form "x R y" means that there exists a path from node x to node y that matches the regular path expression R . Regular path expressions are more general than regular expressions, because they permit predicates on edges and nodes. For example " isName * " is a regular path expression denoting any sequence of labels such that each satisfies the isMame predicate. In particular, true denotes any edge label, and true * any path; we abbreviate the latter with *. Other operators include path concatenation and alternation; the grammar for regular path expression is: R::= Pred \ Pred; Pred \ R . R | (R | R) | R * . The expression
" Predl ; Pred2 " matches any edge, node pair whose edge satisfies Predl and whose node satisfies Pred2. Pred is shorthand for the idiom " Pred; true ", which ignores the node value. For example,
where Root ( p ) , p (true ; not (HomePa ge) ) *q collect Resul t (q)
returns all nodes q accessible from paths that begin at the root and that do not go through any HomePage . This assumes that Root is a collection consisting of the graph's single root node.
St'ruQL extends these regular-expression based selections with the creation of new graphs from existing graphs; its create, and link clauses specify new graphs. The following example copies the input graph and adds a "Home" edge from each node back to the root:
where Root (p) , p * q, q 1 q' create N (p) , N (q) , N (q' ) link N(q)l N (q'), N (q) " Home" N(p) collect NewRoot (N(p))
N is a Skolem function creating new object OIDs. The query first finds all nodes q reachable from the root p (including p itself) and all nodes q' directly accessible from q by one link labeled 1 . For each node q and q' , it constructs new nodes N (q) and N(q'): in effect, this copies all nodes accessible form the root once. The query adds a link 1 between any pair of nodes that were linked in the original graph and adds a new Home link that points to the new root. Finally, it creates an output collection NewRoot that contains the new graph' s root.
A similar query produces a site graph, i.e., a view of the input graph, called TextOnly, that excludes any nodes that contain image files:
where Root (p ) , P* q, q 1 q' , not { isImageFi l e ( q ) ) create N (p) , N (q) , N (q' ) link N(q) 1 Nfq1) collect TextOnlyRoot { ¥S (p) )
Other constructs are also possible for supporting regular path expressions.
A distinguishing feature of StruQL is that its semantics can be described in two stages. The query stage depends only on the where clause and produces all possible bindings of variables to values that satisfy all conditions in the clause; its result is a relation with one attribute for each variable. The construction stage constructs a new graph from this relation, based on the create, link, collect clauses. These details are explained next .
An active-domain semantics is adopted for StruQL. For a data graph G, let 0 be the set of all OIDs and L the set of all labels in G. Let V be the set of all node and edge variables in a query. The meaning of the where- clause is the set of assignments ? : V ? 0 ? L that satisfy all conditions in the where clause. Each assignment maps node variables to 0 and edge variables to L. The meaning of the create-link-collect clauses is as follows. For each row in the relation, first construct all new node OIDs, as specified in the create clause. Assuming the latter is create Nχ,...,Nn, each Ni is a Skolem function applied to node OIDs and/or label values. By convention, when a Skolem function is applied to the same inputs, it returns the same node OID. Next, construct the new edges, as described in the link clause. Two semantic conditions are imposed on StruQL' s queries: first each node mentioned in link or collect is either mentioned in create or is a node in the data graph. Second, edges can only be added from new nodes to new or existing nodes; existing nodes are immutable and cannot have edges added to them. Thus, link f (x) "A" f (y) and link f (x) "A "y are legal, but link x "A" f (y) is not, because the latter would alter the old graph. The semantic of the collect clause is fairly straightforward. Under the active-domain semantics for StruQL, every StruQL query has a well-defined meaning. For example, the query below returns the complement of a graph, i.e., the result graph contains an edge labeled 1 between two nodes if and only if no such label exists between the corresponding nodes in the input graph:
where not (p 1 q) create f (p) , f (q)
The active-domain semantics, however, is unsatisfactory because it depends on how we define the active domain; the semantics changes if, for example, the active domain is computed only for the accessible part of the graph. The situation is similar to the domain independence issue in the relational calculus: there it is solved by considering range-restricted queries, which are guaranteed to be domain independent, i.e., their semantics do not change if the active domain is artificially changed.
StruQL' s regular path expressions require graph traversal and, therefore, the computation of transitive closure. The ability to compute the transitive closure of an input graph does not imply the ability to compute the transitive closure of an arbitrary binary or 2n-ary relation. StruQL can express transitive closure of an arbitrary relation as the composition of two queries. For example, consider the tree-encoding of a binary relation R (A,B) with attributes A and B, as shown below. All nodes reachable from "x" can be calculated with two StruQL queries. The first constructs the graph corresponding to the relation R(A,B), and the second uses the regular expression * to find all nodes accessioie from the root. Input is a keyword that specifies the input to a query. mput (where Root ( r ) , r "t up " si , r "tup " s2, si "A" xl, si "B" yl s2 "A" x2, s2, "B" y2 yXx2 create H ( yl ) , N (x2) link N(yl) "bogus" N(x2) collect New Root (N("x"))) where New Root (x) , x * N (y) collect Resul t (y)
StruQL has the same expressive power as first order logic extended with transitive closure, FO + TC. That is, considering a two-sorted (with sorts Old and Label ) , first order vocabulary = {E, Ci, ..., Ck}, where E (Old, Label , Old) is the edge relation and Ci (Old), . . . X ( Oιd) are the collections, then a boolean query over this vocabulary is expressible in pure StruQL (i.e., without external predicates) if and only if it is expressible in FO + TC. The query stage of StruQL can also construct a new output graph. This feature is more powerful than conventional query languages.
An evaluation strategy based on StruQL' s active- domain semantics is prohibitively inefficient, because the semantics constructs an intermediate relation whose size may be much larger than that of the input graph. In general, such a strategy is also unnecessary, because transformation queries typically require at most one traversal of the input graph and may not require the com putation of an intermediate relation at all. Assuming that all data m materialized in data graphs, query evaluation strategies could be applied for other semi- structured languages to StruQL ana use optimization techniques ..hat minimize or eliminate graph traversal. STRUDEL data, however, may be stored in external sources, and therefore, evaluation strategies that adhere to limitations of external sources and can use the query capabilities of the sources whenever possible we desired.
5. Identifying such evaluation strategies is non-trivial, because although data in external sources is modeled as data graphs, the external sources may not support queries that traverse arbitrary paths through the data. In particular, evaluation strategies are desired that can: 0
Push queries to external sources. STRUDEL data graphs can be created by integrating information from external sources. A simple strategy is to materialize external sources as data graphs and evaluate queries on the 5 materialized graphs. A better strategy is to delay fetching of external data by pushing queries to the external sources.
Exploit indexes. Indexes may be available for data graph 0 materialized in the data repository and for the external sources. STRUDEL' s query processor should use these indexes whenever possible.
Handle limited capabilities. The ability to traverse 5 edges forward and/or backward depends on the capability of a data source. In some externals, links may be traversed only in one direction. For example, the AT&T employee database requires certain attribute values such as last name or phone number, in order to extract any 0 information. In STRUDEL' s data model, this translates into certain edges being traversable in one direction.
To address all these requirements, it is advantageous to apply different optimization strategies to different representation of a query, so that at each level different kinds of optimizations can be expressed.
Three representations are used: (1) StruQL' s abstract syntax, (2) automata that compute regular path expressions, and (3) a physical query plan that 5. incorporates the capabilities of the data source.
Examples of optimizations at each level, are shown which essentially rewrite a query into an equivalent representation at the same level and/or translate the query into the representation at the next level. It is 0 possible to combine such isolated optimization strategies using the techniques discussed in an Ph.D. thesis authored by Daniela D. Floresen titled "Design and Implementation of the Flora Object Oriented Query Optimizer", Institut National de Rechershe and 5 Informatique (INRIA), 1996, which is incorporated by reference herein.
Abstract syntax level. At this level, source-to-source transformations are applied to reduce the number of edges 0 that must be traversed in the input graph. This is accomplished by finding common prefixes in multiple regular path expressions. For example, consider where Root (p) , p ( "A " . "B ") * . "A "q, 5 p "A"."C"."D" r
The first regular expression can be rewritten into an equivalent expression:
0 where .Root (p ) , p "A " . ( "B " . "A ") *q, p "A " . "C " . "D " r
Next, two node variables, x and y are introduced: 5 where Root (p ) , p "A " x , x ( "B " . "A ") *q p "A " y, y "C" . "D " r
Finally, if g and r are "independent", meaning that none of the clauses in link creates an edge between them, then x and y node variables can be collapsed into a single variable z, and results in:
where Root (p) , p "A " z , z ( "B " . "A ") *q,
The resulting query is equivalent to the original, but it traverses each edge "A" accessible from the root once.
Automation level. At this level, each regular expression is translated into a generalized Non-Deterministic Finite Automaton (NDFA) . There is one automaton for each condition in the where clause. The simplest way to execute an automaton is to traverse it from its input state to its output state (s), but more complex traversals are also considered, which start at some arbitrary state (s), resulting in alternative physical execution plans. FIG. 4 illustrates a traversal for the following query:
where CI (x) ,x (AB) +y, yCZ , C2 (y) , z>4 .
Physical execution plan. The operators at the physical level are the same as those found in relational query plans (see FIG. 4) . The physical plans, however, may have cycles. The first two plans in FIG. 4 correspond to the left-to-right traversal of the automaton: they differ only in the fact that the first has a direct join while the second has a join. The third execution plan corresponds to starting the automata in the state _: this could be advantageous if, for example, there is fast access to the collection C2. Then the plan branches, searching for a C edge to Z on one hand, and for a backwards path to X on CI on the other hand. At the end it has to join the two results based on _.
The present invention uses an algebra for querying semi-structured data. Regular expressions are considered as atomic operations in this algebra (as part of the tree pa tterns in the scan operator) . This results in optimized queries at the select-project-join level. The present invention also optimizes inside regular expressions so that STRUDEL' s execution plans are more fine grained, and generally have cycles. Although a preferred embodiment is specifically illustrated and described herein, it will be appreciated that modifications and variations of the present invention are covered by the above teachings and within the purview of the appended claims without departing from the spirit and intended scope of the invention. For example, although STRUDEL is implemented on the server side in the embodiment of the invention, STRUDEL could be implemented on the client side and still fall within the scope of the invention. Further, although this embodiment of the invention presents information at a web site using HMTL, any graphical presentation language falls within the scope of the invention. * Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp. , and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code . */
/* An [[Automata]] represents a path definition.
*/ /*
*/ /*
*/ /* <Automata. java>=
*/ package Automata; import COM.objectspace. jgl . *; import java.util.*; import java.io.*; import DataRepository. * ; import java . lang . * ; import Querylnterpretor . * ; class EdgeSet { public java.util .Vector w;
public EdgeSet ( ) { w = new va.util .Vector () ; } private boolean mem( ink_INT e) { for (int i=0; i<w.size(); i++) if (e. equals ( ( ink_INT) w.elementAt (i) ) ) return true; return false; } public boolean member ( State_INT si, State_INT s2) {
Link_INT e = new ink(εl, s2 , new UnaryBoolExprEps ()) ; return mem(e) ;
} public boolean member ( State_INT si, State_INT s2, UnaryBoolExpr_INT b ) {
Link_INT e = new Link (si, s2, b); return mem(e) ; } public void add(State_INT si, State_INT s2) {
Link_INT e = new Link(sl,s2, new UnaryBoolExprEps ()) ; w.addElement (e) ;
} public void add ( State_INT si, State_INT s2, UnaryBoolExpr_INT b) { Link_INT e = new Link(sl,s2, b) ; . addElement (e) ; } public void insert (State_INT si, State_INT s2) { if (! (member (si, s2))) add(sl,s2); } public void insert (State_INT si, State_INT s2 , UnaryBoolExpr_INT b) { if (! (member (si, s2, b) ) ) add (si, s2,b) ;
} public Link_INT element (int i) ( return (Link_INT) w.elementAt (i) ; } public int sizeO { return w.sizeO;}
public class Automata implements Automata_INT { private State_INT in, out; private Link_INT [ ] Inks ,- public Automata (State_INT i, State_INT o, Link_INT[] 1) { in = i; out = o; Inks = 1; } public State_INT getlnputState ( ) { return in; } public State_INT getOutputState ( ) { return out; } public Link_INT[] getLinks ( ) { return Inks; }
//return true if it is an automata of the form x->l->y (just a triple ) public boolean isSimple(){ if (getStateSet ( ) . size ( ) >2 ) return false; else return true; } public String toString(){ return " [ " +in+" ->"+out+" ] " ; } public String toStringLong( ) {
String s = " " ; s += "Automaton: \n" ; s += "Input State: "+in. toString( ) +" \n" ; s += "Output State: "+out . toString( ) +" \n" ; s += "Links: \n"; for (int i=0; i<lnks . length; i++) { s += Inks [i] . toStringO ;
} return s; } public Automata (Automata_INT aut, NodeExpr_INT inNode, NodeExpr_INT o utNode)
{ int j = 0;
State_INT autin = aut . getlnputState ( ) ; State_INT autout = aut . getOutputState ( ) ; Link_INT [ ] autlnks = aut . getLinks ( ) ; in = new State (inNode) ; out = new State ( outNode ) ;" Inks = new Link_INT[autlnks. length + 2] ; lnks[j++] = new Link(in, autin, new UnaryBoolExprEps ()) ; for (int i=0; ioutlnks. length; i++) lnks[j++] = autlnks[i]; lnks[j++] = new Link(autout, out, new UnaryBoolExprEps ()) ;
} public HashSet getVars ( ) {
HashSet set= new HashSet ( ) ; for (int i=0; i<lnks. length; i++) set = set. union(Inks [i] .getVars ()) ; return set;
} public HashSet getUnionStates ( ) {
//return the set of states S in the automata such that
// S has more than one incommming edge
HashSet answer, temps; temps = new HashSet ( ) ; answer = new HashSet ( ) ; for (int i=0; i<Inks. length; i++) { if (temps.count (Inks [i] . getOutputState ( ) ) > 0) answer . add ( Inks [i] . getOutputState ( ) ) ; temps . add(Inks [i] .getOutputState ( ) ) ; } return answer; } public HashSet getLinkSet ( ) {
//return the set of Link (!!) of an Automata
HashSet answer=new HashSet ( ) ; for (int i=0; i<Inks. length; i++) answer . dd (Inks [i] ) ; return answer; } public HashSet getStateSet ( ) {
//return the set of State (!!) of an Automata
HashSet answer=new HashSet ( ) ; for (int i=0; i<Inks. length; i++) { answer. add(Inks [i] . getlnputState ( ) ) ; answer . add(Inks [i] . getOutputState ( ) ) ; } return answer;
/★★★★★A****************************************************** / /* Dan's epsilon elimination stuff */ /* compute the transitive closure of epsilon edges */ private EdgeSet makeEpsStars (Link_IN [] Inks) {
EdgeSet s = new EdgeSet ( ) ;
State_INT a,b;
/* Compute epsilon-paths of length 0 and 1 */ for (int i = 0; i < Inks. length; i++) if (Inks [i] .getLabel ( ) instanceof UnaryBoolExprEps)
{ a = Inks [i] .getlnputState () ; b = lnks[i] . getOutputState ( ) ; s. insert (a, a) ; s. insert (a, b) ; s. insert (b,b) ;
}
/* Compose s with itself until no more change */ boolean change; do { change = false; int n = s.sizeO; /* increases from one interation to another */ for (int i=0; i<n; i++) for(int j=0; j<n; j++)
{ State_INT al = s. elemen (i) .getlnputState () ;
State_INT a2 = s .element (i) . getOutputState () ;
State_INT bl = s .element (j ) .getlnputState () ;
State_INT b2 = s . element ( ) . getOutputState ( ) ; if (a2==bl && (! (s.member (al, b2)))) { change = true; s.add(al, b2) ; }
} } while (change) ; return s; }
/* now compute the new edges: for every a -> Eps* -> a' -> Label -> b insert a new edge a -> Label -> b */ private EdgeSet makeNewLnks (EdgeSet epsStar, Link_INT[] Inks) { EdgeSet s = new EdgeSet ( ) ; for (int i=0; i<epsStar.size ( ) ; i++)
{ State_INT al = epsStar. elemen (i) . getlnputState ( ) ; State_INT a2 = epsStar . element ( i ) . getOutputState ( ) ; for (int j=0; <Inks . length; j++) {
State_INT bl = Inks [j ] .getlnputState () ; State_INT b2 = Inks [j ] . getOutputState ( ) ; if (a2 == bl && ! (Inks [ ] .getLabel ( ) instanceof UnaryBoolExpr Eps)) { s.insert(al, b2, Inks [j] .getLabel ()) ; }
} } return s; }
/* compute the accessible part of the new set of edges */ private void computeAccessible (State_INT s, EdgeSet newLnks) { if (s.getAccO) return; s . setAcc (true) ; for (int i=0; i<newLnks . size ( ) ; i++) if (newLnks. element (i) .getlnputState ( ) == s) computeAccessible (newLnks . element (i ) . getOutputState ( ) , newLnks )
}
/* compute the new termial states: i.e. those states x for which x -> Eps* -> out, where out it the original terminal state */ private State_INT[] findTerminalStates (EdgeSet epsStar, State_INT out ) { java.util.Vector w = new java.util.Vector () ; for (int i=0; i<epsStar . size ( ) ; i++) if (epsStar. element (i) -getOutputState () ==out && epsStar .element (i ) . getlnputState ( ) . getAcc ( ) ) w. addElement (epsStar .element (i) . getlnputState ( ) ) ; int n = w.sizet ) ;
/* if (n == 0) throw new Exception();
*/
State_INT[] res = new State_INT[n] ; for (int i=0; i<n; i++) res[i] = (State_INT) w.elementAt (i) ; return res; }
/* finally compute the new output state (if not unique, need to add n ew epsilon edges), and update the Inks field */ private void computeLnksOut ( State_IN [ ] newOuts, EdgeSet newLnks) {
/* must return a single output state; if more than one, create a fresh one and draw eps-edges */ if (newOuts. length > 1) { out = new State (out. getSymbol ()) ; out . setAcc (true) ; for (int i=0; i<newOuts. length; i++) newLnks . insert (newOuts [i ] , out, new UnaryBoolExprEps ( ) ) ; } else { newOuts [0] . changeSymbol (out . getSymbol ( ) ) ; out = newOuts [0] ,- }
/* eliminate the non-accessible part */ java.util .Vector w = new java.util.Vector () ; for (int i=0; i<newLnks . size ( ) ; i++) if (newLnks. element (i) .getlnputState 0.getAcc () ) /* if input sta te is accessible, so is the ou tput state */
{ w. addElement (newLnks . element ( i ) ) ; }
/* finally, copy everything back into nks */ Inks = new Link_INT[w. size( ) ] ; for (int i=0; i<w.size(); i++) lnks[i] = (Link_INT) w.elementAt (i) ;
} public void elimEpsEdges ( ) {
EdgeSet epsStars = makeEpsStars (Inks) ; EdgeSet newLnks = makeNewLnks (epsStars, Inks) for (int i=0; i<lnks . length; i++) {
Inks [i] . getlnputState ( ) . setAcc ( false) ; lnks[i] . getOutputState ( ) .setAcc (false) ;
} computeAccessible (in, newLnks);
State_INT[] newOuts = findTerminalStates (epsStars , out) computeLnksOut (newOuts , newLnks ) ;
}
}
Copyright 1997 AT&T Labs — Research
By receiving and using the code that follows, the user acknowledges and agrees to keep the code confidential and use the code solely for non-commercial research. The user further acknowledges and agrees th at * the code is not an official product of AT&T Corp. , and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ /* <Automata_INT. java>= */ package Automata; import java .util . * ; import java . io . * ; import COM.objectspace. gl. *;
/* AUTOMATA: is a set of (state, edge, state) triples
public interface Automata_INT extends Conjunct{ public State_INT getlnputState ( ) ; public State_INT getOutputState () ; public Link_INT[] getLinks () ; public void elimEpsEdges ( ) ; public String toStringLong ( ) ; }
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code . */
/* <BaseValue_INT. java>=
*/ package Automata; import COM. objectspace . jgl . * ; import java.util.*;
public interface BaseValue_INT { public String getNameO; public Type_INT getType ( ) ;
}
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for non-commercial research. The user further acknowledges and agrees th at * the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <BoolExprAnd. java>=
*/ package Automata; import COM.objectspace. jgl . *; import java.util.*; import java. io . * ; import Querylnterpretor. * ; import DataRepository. *;
public class BoolExprAnd implements BoolExpr_INT { private BoolExpr_INT bl, b2; public BoolExprAnd (BoolExpr_INT x, BoolExpr_INT y) { bl = x; b2 = y; } public String getName ( ) { return "BoolExprAnd"; } public String toString(){ return "AND ( " +bl . toString ()+"," +b2. toString ()+")"; } public BoolExpr_INT gentleSeparate (HashSet cMemc, HashSet cXCc, HashS et cXYc,
HashSet cother, boolean returnExp) { cother .add (this) ; return this; } public DataValue Eval (Binding b) { return new BoolDataValue ( ( (BoolDataValue) (bl. Eval (b) )) .booleanValu e()
&& ( (BoolDataValue) (b2.Eval (b) ) ) .booleanValue ( ) ) ; } public Ξxpr_INT [ ] getSubExprs ( ) { Expr_INT[] res = new Expr_INT[2]; res[0] = bl; res[l] = b2; return res; } public HashSet getVars ( ) { return bl . getVars ( ) . union (b2. getVars ( ) ) ; } public BoolExpr_INT separate (HashSet cMemc, HashSet cXCc, HashSet cXY c,
HashSet cother, boolean returnExp) { BoolExpr_INT si = bl . separate (cMemc, cXCc, cXYc, cother, true); BoolExpr_INT s2 = b2. separate (cMemc, cXCc, cXYc, cother, true); BoolExpr_INT n= new BoolExprAnd ( si, s2) ; if (! returnExp) cother. add (n) ,- return n;
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <BoolExprConst. java>=
*/ package Automata; import COM.objectspace. jgl. *; import java.util.*; import java.io.*; import DataRepository. * ; import QueryInterpretor. * ; *****•*******************
/* BoolExpr */
/★★it********************* / public class BoolExprConst implements BoolExpr_INT { private BoolDataValue v;//DANA public BoolExprConst (BoolDataValue x) { v = x; } public String toString () { return v. toString () ; } public String getNameO { return "BoolExprConst"; } public Expr_INT[] getSubExprs ( ) { return new Expr_INT[0]; } public HashSet getVars ( ) {return new HashSet ();} public DataValue Eval (Binding b) {return v; } public BoolExpr_INT separate (HashSet cMemc, HashSet cXCc, HashSet cXY c,
HashSet cother, boolean returnExp) { cother. add (this) ; return this; } public BoolExpr_INT gentleSeparate (HashSet cMemc, HashSet cXCc, HashS et cXYc,
HashSet cother, boolean returnExp) { cother. add (this) ; return this;
}
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <BoolExprNot . java>=
*/ package Automata; import COM.objectspace. jgl. *; import java.util.*; import java.io.*; import Querylnterpretor . * ; import DataRepository. *; public class BoolExprNot implements BoolExpr_INT { private BoolExpr_INT b; public BoolExprNot (BoolExpr_INT x) { b = x; } public DataValue Eval (Binding bl) { return new BoolDataValue ( ! ( (BoolDataValue) (b.Eval (bl) ) ) .boolea nValue ( ) ) ; } public String toString(){ return "NOT ( "+ . toString ()+")"; } public BoolExpr_INT gentleSeparate (HashSet cMemc, HashSet cXCc, HashS et cXYc,
HashSet cother, boolean returnExp) { cother . add (this) ; return this; public String getName ( ) { return "BoolExprNot"; } public Expr_INT[] getSubExprs ( ) {
Expr_INT[] res = new Expr_INT[l] ; res[0] = b; return res; } public HashSet getVars ( ) { return b. getVars ( ) ; } public BoolExpr_INT separate (HashSet cMemc, HashSet cXCc, HashSet cXY
HashSet cother, boolean returnExp) { BoolExpr_INT si = b . separate (cMemc , cXCc, cXYc, cother, true); BoolExpr_INT n= new BoolExprNot (si) ; if (! returnExp) cother. ad (n) ; return n; }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <BoolExprOr. java>=
*/ package Automata; import COM.ob ectspace. gl .* ; import java.util.*; import java . io . * ; import Querylnterpretor . * ; import DataRepository. * ;
public class BoolExprOr implements BoolExpr_INT { private BoolExpr_INT bl, b2; public BoolExprOr (BoolExpr_INT x, BoolExpr_INT y) { bl = x; b2 public String toString(){ return "OR ( " +bl . toString () + "," +b2. toString ()+")"; } public BoolExpr_INT gentleSeparate (HashSet cMemc, HashSet cXCc, HashS et cXYc,
HashSet cother, boolean returnExp) { cother .add (this) ; return this; } public DataValue Eval (Binding b) { return new BoolDataValue ( ( (BoolDataValue) (bl.Eval(b) ) ) .booleanValu e() II
( (BoolDataValue) (b2.Eval (b) ) ) .booleanValu e()); } public String getName ( ) { return "BoolExprOr"; } public Expr_INT[] getSubExprs ( ) {
Expr_INT[] res = new Expr_INT[2] ; res[0] = bl; res [1] = b2 ; return res; } public HashSet getVars () { return bl . getVars ( ) .union (b2. getVars ( ) ) ; } public BoolExpr_INT separate (HashSet cMemc, HashSet cXCc, HashSet cXY c,
HashSet cother, boolean returnExp) { BoolExpr_INT si = bl . separate (cMemc , cXCc, cXYc, cother, true); BoolExpr_INT s2 = b2. separate (cMemc, cXCc, cXYc, cother, true); BoolExpr_INT n= new BoolExprOr (si, s2) ; if (!returnExp) cother .add(n) ; return n; }
/* * Copyright 1997 AT&T Labs — Research
By receiving and using the code that follows, the user acknowledges and agrees to keep the code confidential and use the code solely for non-commercial research. The user further acknowledges and agrees th at * the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <BoolExprPred. ava>= */ package Automata; import COM.objectspace. jgl. *; import java.util.*; import java.io.*; import Querylnterpretor . * ; import DataRepository.*; import QueryParser. * ; public class BoolExprPred implements BoolExpr_INT { private Symbol_INT pred; private ValueExpr_INT args [ ] ; public BoolExprPred(Symbol_INT p) throws RuntimeException { pred = p; args = new ValueExpr_INT [0] ; } public BoolExprPred (Symbol_INT p, ValueExpr_IN [ ] a) throws RuntimeEx ception, SemanticError { if (a. length < 1)
StrudelError . checkArgCount (a. length, 2, ( (Symbol)p) .getName ()) ; else if (Strudel.isRelOp(p) )
StrudelError. checkArgCount (a. length, 2, ( (Symbol)p) .getName ()) ; else if (( (Symbol)p) .getName () .equals ( "Value" ) )
StrudelError. checkArgCount (a. length, 1, ( (Symbol )p) .getName ()) ; else // Otherwise assume Collection-membership test
StrudelError .checkArgCount (a. length, 1, ( (Symbol)p) . etName ( ) ) ; pred = p; args = a; } public static String funcToString (String fname, Expr_INT fargs[]) { String result=fname+" ( " ; for (int i=0; i<fargs .length; i++) { if(i != 0) result=result+", "; result=result+fargs [i] . toString () ; } return (result+" ) " ) ; } public String toString () { return funcToString (pred. getName () , args); } public DataValue Eval (Binding b) throws RuntimeException { DataObject[] varTable = new DataObject [args. length] ; int i ; for (i = 0; i < args. length; i++) {
ValueExpr_INT obj = args [i] ; if (obj instanceof ValueExprVar) varTable [i] = ( (ValueExprVar) obj ) . EvalNode (b) ; else varTable[i] = new LeafDataObject (obj .Eval (b) ) ; } if (pred == Strudel.predTrue) return new BoolDataValue (true) ; // Apply relational operators else if (Strudel . isRelOp (pred) ) { int comparator = CompareObject. compare (varTable [0] , varTable [1] ) ; if (comparator < 0) return new BoolDataValue (pred == Strudel. opLE | | pred == Strud el.opNE || pred == Strudel . opLT) ; else if (comparator == 0) return new BoolDataValue (pred == Strudel. opLE || pred == Strude l.opEQ || pred == Strudel. opGE) ; else return new BoolDataValue (pred == Strudel. opGE | | pred == Str udel.opNE || pred == Strudel .opGT) ; }
// Test if argument is a LeafDataObject else if (Strudel. isBuiltinPred (pred) ) { return Strudel. evalBuiltinPred (pred, varTable[0] ) ; }
// Otherwise, assume predicate is Collection name else return new BoolDataValue (varTable [0] .belongsTo(getPredName ( ) ) ) ;
// What about externally defined predicates? }
// Name matching? /* if (getPredName ( ) . equals ( "like") ) {
String sl= ( (StringDataValue) table [0] ). stringValue () ;
String s2= ( (StringDataValue) table [1] ) . stringValue ( ) ; boolean result=NameMatch.matchNames (si, s2) ; return new BoolDataValue (result) ;
}
*/ public String getPredName ( ) { return ( (Symbol)pred) .getNam ( ) ; } public String getName ( ) { return "BoolExprPred"; } public Expr_INT[] getSubExprs ( ) { return args; } public HashSet getVars () {
HashSet set= new HashSet ( ) ; for (int i=0; i<args. length; i++) set = set.union (args [i] .getVars ()) ; return set; }
// gentleSeparate is wrong -- can have builtin predicates that // take one argument but that are not collection-membership tests public BoolExpr_INT gentleSeparate (HashSet cMemc, HashSet cXCc, HashS et cXYc,
HashSet cother, boolean returnExp)
{ if (Strudel . isBuiltinPred (pred) ) cother . add ( this ) ; else if (args . length == 1 ) cMemc . add ( this ) ; else cother . add ( this ) ; return this ; } public BoolExpr_INT separate (HashSet cMemc, HashSet cXCc, HashSet cXY c,
HashSet cother, boolean returnExp) { ValueExpr_INT [ ] nargs = new ValueExpr_IN [args. length] ; try { if (pred. equals (Strudel. opEQ) ) { if ( ! returnExp) { if (args [0] instanceof ValueExprVar & args[l] instanceof Value ExprVar ) cXYc. add (this) ; else if( (args[0] instanceof ValueExprVar & args[l] instanceof V alueExprConst) |
(args[l] instanceof ValueExprVar & args[0] instanceof V alueExprConst) ) cXCc. add (this) ; else cother. add (this) ; } return (this) ; } else for (int j=0; j<args . length; j++) { if (args[j] instanceof ValueExprConst) {
ValueExprVar sl=new ValueExprVar (Strudel. symtab . genSym (Type . typeNode) ) ;
ValueExpr_INT [ ] vec = new ValueExpr_INT[2] ; nargs[j]= si; vec [0] =sl; vec [1] =args [j ] ; cXCc.addfnew BoolExprPred ( Strudel .opEQ, vec)); } else nargs [j ] =args [j ] ; } BoolExpr_INT n = new BoolExprPred (pred, nargs); if (! returnExp) { if (Strudel . isBuiltinPred (pred) ) cother. add (n) ; else if (args. length == 1) cMemc.add(n) ; else cother. add (n) ; } return n; } catch (Exception e) { throw new RuntimeException (e. toString ( ) ) ; } } }
/* * Copyright 1997 AT&T Labs -- Research * By receiving and using the code that follows, the user acknowledges and agrees to keep the code confidential and use the code solely for non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <BoolExpr_INT. java>= */ package Automata; import COM.objectspace. jgl .* ; import java.util.*; import java . io . * ; import DataRepository. * ; import QueryInterpretor . * ;
public interface BoolExpr_INT extends Expr_INT { public String toStringO; public DataValue Eval (Binding b) ; public BoolExpr_INT gentleSeparate (HashSet cMemc, HashSet cXYc, Hash Set cXCc,
HashSet cother, boolean returnExp) ; public BoolExpr_INT separate (HashSet cMemc, HashSet cXYc, HashSet cX
Cc,
HashSet cother, boolean returnExp) ;
} /*
Copyright 1997 AT&T Labs — Research
By receiving and using the code that follows, the user acknowledges and agrees to keep the code confidential and use the code solely for non-commercial research. The user further acknowledges and agrees th at * the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code . */
/* <CollExpr. java>=
*/ package Automata; import COM.objectspace. jgl .* ; import java.util.*; import java . io . * ; import Optimizer. * ; import DataRepository. * ; import Querylnterpretor . * ;
/* CollExpr */
public class CollExpr implements CollExpr_INT { private Symbol_INT col; private NodeExpr_INT arg; public CollExpr (Symbol_INT c, NodeExpr_INT a) { col = c; arg = a; } public DataValue Eval (Binding b) { return null; } public String toString () { return col . toString ()+"("+arg . toString ()+")"; } public String getName () { return "CollExpr"; } public Expr_INT [ ] getSubΞxprs ( ) {
Expr_INT[] res = new Expr_INT[l]; res[0] = arg; return res; } public HashSet getVars ( ) {return arg .getVars (); } public BuiltlnOperation toBuiltInOp(StoredDataGraph outgraph) { return new BuiltlnOperation(new CollectOperation (outgraph, getNod eExpr ( ) , getCollectionName ( ) ) ) ; } public String getCollectionName ( ) { return col . getName ( ) ; } public NodeExpr_INT getNodeExpr ( ) { return arg; }
Copyright 1997 AT&T Labs — Research
By receiving and using the code that follows, the user acknowledges and agrees to keep the code confidential and use the code solely for non-commercial research. The user further acknowledges and agrees th at * the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories * with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <CollExpr_INT. java>= */ package Automata; import COM.objectspace. jgl. *; import java.util.*; import DataRepository. * ; import Querylnterpretor . * ; public interface CollExpr_INT extends Consume_INT {
// public HashSet getVarsO;
// public String toStringO; }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <Conjunct. java>= */ package Automata; import COM.objectspace. jgl . *; import jav . lang . * ; import java.util.*; import java . io . * ; import DataRepository. *,- import Querylnterpretor. * ;
/★★★★★★a*********************************************************/
/* Conjunct: there are two types of conjuncts in Struql: automatas and boolean expressions */ /★★★★★A**********************************************************/ public interface Conjunct { public HashSet getVars ( ) ; public String toStringO; }
/*
* Copyright 1997 AT&T Labs '— Research * By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package Automata; import COM.objectspace. jgl. *; import java.util.*; import java . io . * ; import DataRepository.*; import Optimizer . * ;
// Consume_INT specifies the interface for the Link & Collect operation s,
// which consume the results of a query public interface Consume_INT { public String toStringO; public HashSet getVars ( ) ; public BuiltlnOperation toBuiltInOp(StoredDataGraph dg) ; }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <Expr_INT. java>= */ package Automata; import COM.objectspace. gl .* ; import java . lang. * ; import java.util.*; import java . io . * ; import DataRepository. * ; import Querylnterpretor . * ; /★★A*************************************************************/ /* EXPRESSIONS: there are several types of expressions in Struql*/
public interface Expr_INT extends Conjunct { public Expr_INT[] getSubExprs () ; public DataValue Eval (Binding b) ; public String getName 0 ; }
/'
* Copyright 1997 AT&T Labs -- Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <Link.java>=
*/ package Automata; import COM.objectspace. jgl. *; import java . lang. * ; import java.util.*; import java.io.*; import DataRepository. * ; import Querylnterpretor . * ; import QueryParser . * ; import Optimizer . BuiltlnOperation; public class Link implements Link_INT { private State_INT in, out; private UnaryBoolExpr_INT label; private boolean be; private Symbol labelsym = null; public String toString ( ) { return "Link:("+ in. toStringO +" "+label. toStringO +" "+out.toStr ing()+")\n"; } public Link(State_INT i, State_INT o, UnaryBoolExpr_INT 1)
{in = i; out = o; label = 1; be = false; } public Link(State_INT i, State_INT o, UnaryBoolExpr_INT 1, boolean b)
{in = i; out = o; label = 1; be = b; } public Link(NodeExpr_INT x, NodeExpr_INT y, UnaryBoolExpr_INT b) { in = new State (x) ,- out = new State (y) ; label = b; be = false; }
// Convert link labeled with unary boolean predicate 'P' to // link labeled with variable 'V and add // condition 'P(v)' to conditions. public void fix (HashSet cXCc, HashSet cMemc, HashSet cother ) { in. fix(cXCc) ; out. fix(cXCc) ; if (label instanceof UnaryBoolExprPred | | label instanceof UnaryBoolExprAnd | | label instanceof UnaryBoolExprOr | | label instanceof UnaryBoolExprNot ) { labelsym = Strudel. symtab. genSym(Type . typeLink) ; ValueExprVar v = new ValueExprVar (labelsym) ; BoolExpr_INT b=label . cleanNS (v) ; if (label instanceof UnaryBoolExprPred) cMemc.add(b) ; else cother. add (b) ; label = new UnaryBoolExprVar (labelsym) ; } } public void changeLabel (UnaryBoolExpr_INT 11) {label=ll;} public State_INT getlnputState 0 { return in; } public State_INT getOutputState ( ) { return out; } public UnaryBoolExpr_INT getLabel ( ) { return label; } public boolean backEdge () { return be; } public HashSet getVars ( ) { return in. getVars () •union (out .getVars () .union (label. getVars ( ) ) ) ; // if (labelsym != null) set. add (labelsym) ; // return set; } public BuiltlnOperation toBuiltInOp(StoredDataGraph outGraph) { Operation op; if (getVars () .isEmptyO ) { op = new UniqueLinkOperation (outGraph, in.getSymbol ( ) , out.getSym bolt), label); return new BuiltlnOperation (op) ; } else { op = new LinkOperation (outGraph, in.getSymbol () , out .getSymbol 0 , label ) ; return new BuiltlnOperatio (op) ; } } public boolean equals (Link_INT 1) { return (in == 1. getlnputState ( ) && out == 1.getOutputState () && label . equals ( 1. getLabel 0 ) ) ; }
}
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <Link_INT. java>=
*/ package Automata; import COM.objectspace. jgl. *; import java.util.*; import java.io.*;
public interface Link_INT extends Consume_INT { public State_INT getlnputState 0 ; public State_INT getOutputState () ; public UnaryBoolExpr_INT getLabel ( ) ; public boolean backEdge { ) ,-
// public String toStringO; public void changeLabel (UnaryBoolExpr_INT 1) ;
// public HashSet getVars () ; public void fix(HashSet cXCc, HashSet cMemc, HashSet cother); public boolean equals (Link_INT 1) ; }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp. , and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness * for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ _ package Automata; import java.util.*; import java.io.*; import COM.objectspace. jgl. *;
public class NameMatch { private static OrderedMap name_lib_ new OrderedMap ( ) ; static { name. .lib. .add( "chris", "Christopher" name. .lib. .add( "chuck" , "charles" ) ; name. .lib. . add ( " Charley" , " Charles " ) ; name. .lib. . add ( " Charlie" , "charles" ) ; name. .lib. . add ( " torn" , " thomas" ) ; name. _lib. . add( " tommy" , " thomas" ) ; name. _lib. .addO'jim", "james"); name. .lib .add ("bill", "william"); name_lib_.add( "billy" , "william" ) ,- name_lib_. add ( "will" , "william" ) ; name_lib_.add( "willy" , "william" ) ; name_lib_. add ( "mike" , "michael " ) ,- name_lib_. add ( "mickey" , "michael " ) ; } public static String normalize (String part) { String rdata=null; if (part != null && (rdata= (String) name_lib_. get (part) ) null) { return rdata; } return part;
public static boolean matchNames (String nl, String n2) { String namel = nl. toLowerCase () -trim() ; String name2 = n2.toLowerCase (). trim() ;
String lastl = getLastName (namel) ; String last2 = getLastName (name2) ,- String firstl = normalize (getFirstName (namel) ) ; String first2 = normalize (getFirstName (name2) ) ; String middlel = normalize (getMiddleName (namel) ) ; String middle2 = normalize (getMiddleName (name2 )) ; String secondl = normalize (getSecondName (namel) ) ; String second2 = normalize (getSecondName (name2) ) ; if (matchLast (lastl, last2)) { if (matchFirst (firstl, "first2) && matchMiddle (middlel, middle2)) return true; } if (matchFirst (firstl, second2) && matchMiddle (middlel, middle2)) return true; } if (matchFirst (secondl, first2) && matchMiddle (middlel , middle2)) return true; } } return false;
} public static boolean matchFirst (String parti, String part2) { if (parti != null && part2 != null) { if ( (parti, length () == 2 && parti .charAt (1) == '.' && parti. charA t ( 0 ) == part2. charAt (0) ) | |
(part2. length () == 2 && part2.charAt (1) == '.' && parti. charA t(0) == part2. charAt (0) ) ||
(parti. length () == 1 && parti .charAt (0) == part2. charAt ( 0 ) ) |
I
(part2. length () == 1 && parti .charAt (0) == part2. charAt ( 0 ) ) |
I
(parti .equals (part2) ) ) { return true; } } return false; } public static boolean matchLast (String parti, String part2) { if (parti != null && part2 != null && parti .equals (part2) ) { return true; } return false;
} public static boolean matchMiddle (String parti, String part2) { if (parti != null && part2 != null) { if ( (parti . length () == 2 && partl. charAt (1) == '.' && parti. charA t ( 0 ) == part2. charAt ( 0 ) ) | |
(part2. length() == 2 && part2. charAt ( 1) == '.' && parti. charA t ( 0 ) == part2. charAt ( 0 ) ) | |
(parti. length () == 1 && parti . charAt ( 0 ) == part2. charAt ( 0 ) ) |
I
(part2. length () == 1 && parti . charAt ( 0 ) == part2. charAt ( 0 ) ) |
(parti. equals (part2) ) ) { return true; } else { return false; } } return true; } public static String getLastName (String name) { int i;
String rdata = name. trim(); if ( (i=rdata.lastIndexOf (' (') ) > 0) { rdata = rdata . substring ( 0 , i).trim(); } if ( (i=rdata.indexOf (' , ') ) > 0) { rdata = name . substring ( 0 , i).trim(); return rdata; } else { i = rdata. lastlndexOf ( ' '); if (i < 0) return null; rdata = rdata. substring (i) . trim() ; return rdata; } } public static String getFirstName (String name) { int i ;
String rdata = name. trim(); if ( (i=rdata. lastlndexOf ('(') ) > 0) { rdata = rdata. substring (0, i).trim(); } if ( (i=rdata. indexOf ( ' , ') ) > 0) { if (rdata. length () <= i+2) return null; rdata = rdata. substring(i+l) .trim() ; i = rdata. indexOf ( ' ' ) ; if (i > 0) { rdata = rdata . substring ( 0 , i).trim(); } } else { i = rdata. indexOf ( ' ' ) ; if (i < 0) return null; rdata = rdata . substring ( 0 , i).trim(); } return rdata; } public static String getMiddleName (String name) { int i ;
String rdata = name, trim(); if ( (i=rdata. lastlndexOf (' (') ) > 0) { rdata = rdata. substring (0, i).trim(); } if ( (i=rdata. indexOf (',') ) > 0) { if (rdata. length () <= i+2) return null; rdata = rdata. substring (i+1) .trim () ,- i = rdata. lastlndexOf ( ' '); if (i > 0) { rdata = rdata . substring (i ) . trim( ) ; return rdata; } else { return null; } } else { i = rdata . indexOf ( ' ' ) ; if (i > 0) { rdata = rdata. substring(i) .trim () ; i = rdata . indexOf ( ' ' ) ; if (i > 0) { rdata = rdata. substring(0, i).trim(); return rdata; } else { return null; } } else { return null; } }
public static String getSecondName ( String name) { int i ;
String rdata = name . trim() ; if ( (i=rdata. lastlndexOf ('(') ) > 0) { rdata = rdata . substring ( i+1 , rdata . lastlndexOf (')'))• trim( ) ; return rdata; } else { return null; } } public static void main (String args[]) { try {
StreamTokenizer stl = new StreamTokenizer (new FileReader (args [0] )) ; StreamTokenizer st2 = new StreamTokenizer (new FileReader (args [1] )) ;
System. out.println(args [0] +" vs. "+args[l]); stl .quoteChar O " ' ) ; st2 . quoteChar ( ' " ' ) ; int c ;
HashSet setl = new HashSet ( ) ; HashSet set2 = new HashSet ( ) ; outl: while (true) { c=stl . nextToken ( ) ; switch (c) { case ' " ' : setl . add(stl . sval) ; break; case StreamTokenizer. TT_EOF: break outl; } } out2 : while (true) { c=st2.nextToken( ) ; switch (c) { case ' " ' : set2. add (st2. sval) ; break; case StreamTokenizer. TT_EOF: break out2; } }
Enumeration el = setl . elements ( ) ; while (el.hasMoreElements ( ) ) {
String si = (String) el .nextElement () ; Enumeration e2 = set2. elements ( ) ; while (e2.hasMoreElements () ) {
String s2 = (String) e2.nextElement () ; if (matchLast (getLastName (si) , getLastName (s2) ) )
System.out.println(sl+" && "+s2+" = "+matchNames (si, s2) ) } }
System. out.println(name_lib_) ; } catch (Exception e) { e .printStackTrace ( ) ; }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <NodeExprConst . java>=
*/ package Automata; import COM.ob ectspace. jgl. *'; import java.util.*; import java'. io . * ; import DataRepository. * ; import Querylnterpretor . * ; public class NodeExprConst implements NodeExpr_INT { private DataValue d;//DANA public String toStringO { return d. toString ( ) ; } public NodeExprConst (DataValue x) { d = x; } public DataValue Eval (Binding b) {return d;} public DataValue getValue () {return d; } public String getName () { return "NodeExprConst ( "+d+" )" ; } public Expr_INT[] getSubExprs () { return new Expr_INT [ 0] ; } public HashSet getVars ( ) {return new HashSet (); } public String toOid(Binding b) { return d.toOidO; } public String toDot ( ) { return d. toString ( ) ; } public DataObject toObject (Binding b, StoredDataGraph g) { return new LeafDataObject (d) ; }
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <NodeExprSkol. java>=
*/ package Automata; import COM.objectspace. jgl. *; import java.util.*; import java. io . * ; import DataRepository. * ,- import Querylnterpretor . * ; import Util.*; public class NodeExprSkol implements NodeExpr_INT { private Symbol_INT s; private Expr_INT exprs [ ] ; public NodeExprSkol (Symbol_INT a, Expr_INT[] b) { s = a; exprs = b; } public DataValue Eval (Binding b) {
System.err.println( " Not supposed to eval skolem nodes"); return null; } public Symbol_INT getSkolemFunctionO { return s;}//DANA public int nbArgs( ) {return exprs. length; }/ /DANA public String toDot(){ return s . toString ( ) ,- } public String toStringO { return BoolExprPred. funcToString ( s . toString ( ) , exprs) ; } public String toOid(Binding b) {
String old = ( (Symbol) s) . getName ( ) ;
// encode bindings of variable arguments for (int i = 0; i < exprs . length; i++) oid += "_"+( (NodeExpr_INT) exprs [i] ) .toθid(b) ; return oid; } public DataObject toObject (Binding b, StoredDataGraph g) { String oid = toθid(b) ;
InternalDataObject o = g.getOb ect (oid) ; try { if (o == null) { o = new InternalDataObject (g, oid); g . addlnternalObj ect (o) ; o.addCollection( (StoredDataCollection) (g.getAddCollection(getSk olemFunction ( ) . getName ()))); } } catch (Exception ad) {
System. err.println(ad. toString ( ) ) ; throw new RuntimeException (ad. toString ()) ; } return o; } public boolean varSkolTest ( ) { for (int i=0; i<exprs. length; i++) if (! (exprs [i] instanceof NodeExprVar) ) return false; return true; } public Array varSkolRet ( ) {
Array result=new Array ( ) ; for (int i=0; i<exprs. length; i++) result. add( ( (NodeExprVar) (exprs [i] ) ) .getSymbol () ) ; return result; } public boolean constSkolTest ( ) { if ( (exprs. length==l) && (exprs [0] instanceof NodeExprConst)) return true; else return false; } public DataValue constSkolRet 0 { if ( (exprs. length==l) && (exprs[0] instanceof NodeExprConst)) return ( (NodeExprConst) (exprs [0] ) ) .getValueO ; else return null; } public String getName () { return "NodeExprSkol"; } public Expr_INT[] getSubExprs ( ) { return exprs; } public HashSet getVars ( ) {
HashSet set= new HashSet ( ) ; for (int i=0; i<exprs. length; i++) set = set.union (exprs [i] .getVars ()) ; return set ;
}
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* \section{Link, Node, and Boolean Expressions}
*/ /* MOAQL supports node, regular path, unary bool, collection, and boole an expressions. */ /*
*/ /*
*/ / * <NodeExprVar . j ava>=
* / package Automata; import COM. objectspace . jgl . * ; import java . lang . * ; import java .util . * ; import java . io . * ; import DataRepository. * ; import Querylnterpretor . * ;
/★★a.********************* /
/* NodeExpr */
/★★A********************* / public class NodeExprVar implements NodeExpr_INT { private Symbol_INT var; public NodeExprVar (Symbol_INT v) { var = v; } public DataValue Eval (Binding b) {return b.getBindingt (Symbol) var).ge tValue ( ) ; } public String toStringO {return var . toString (); } public String getName { ) { return "NodeExprVar"; } public Expr_INT[] getSubExpr&O { return new Expr_INT[0]; } public Symbol_INT getSymbol ( ) {return var;} public HashSet getVars ( ) {
HashSet set= new HashSet ( ) ; set. add (var) ; return set ; } public String toOid (Binding b) { return b . getBinding ( (Symbol) var) . getUniqueOid O ; } public DataObject toObject (Binding b, StoredDataGraph g) { return b. getBinding ( (Symbol) var) ; } public String toDot ( ) { return "OldGraphNode" ; } }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <NodeExpr_INT . java>=
*/ package Automata; import java.util.*; import COM.objectspace. jgl. *; import java. io . * ; import Querylnterpretor . * ; import DataRepository.*; public interface NodeExpr_INT extends Expr_INT { public String toStringO; public String toDot ( ) ; public String toOid(Binding b) ; public DataValue Eval (Binding b) ; public DataObject toObject (Binding b, StoredDataGraph g) ; }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* \input{macros}
*/ /* \section{STRUDEL Front End}
*/ /* \psfig{figure=. /frontend.ps}
*/ /* \section{Vocabulary}
*/ /* {\em Nodes} and {\em links} refer to the nodes and edges in a data g raph. */ /* We call the values of nodes [ [contents] ] and the values of
*/ /* links [[attributes]].
*/ /* The contents of an internal node is its OID; the contents
*/ /* of a leaf node is an atomic value, called a [[DataValue]],
*/ /* such as integer, boolean, file, image, etc.
*/ /*
*/ /* {\em States} and {\em arcs} refer to nodes and edges in automata, wh ich */ /* model conjunctive queries.
*/ /*
*/ /* \section{Front End}
*/ /* The front end produces
*/ /* a set of input graph names,
*/ /* a set of link symbols,
*/ /* a set of node expressions (can be variables or skolem functions) ,
*/ /* the symbol table,
*/ /* [ [Condition] ] s are of three kind:
*/ /* node expression, regular expression, node expression
*/ /* node expression, link symbol, node expression
*/ /* boolean condition
*/ /* [[Automata]] are derived from the regular expression conditions, by
*/ /* the method [ [deriveAutomata] ]
*/ /* If the query produces a new graph, i.e., it has a \texttt {CREATE}
*/ /* clause,
*/ /* the front end also produces
*/ /* the name of the output graph,
*/ /* a set of collection names,
*/ /* a list of create expressions,
*/ /* a list of link-range expressions,
*/ /* a list of node-range expressions,
*/ /* a list of link expressions, and a list of collect expressions,
*/ /* which are used by the graph-transformation interpreter.
*/ /*
* / /* <Query. java>=
* / package Automata; import COM. objectspace . gl . * ; import java.util.*; import java. io. * ; import Querylnterpretor. * ; import Optimizer . * ; import DataRepository.*; import Util.*; public class Query implements Query_INT { private String [] ig; private String og; private QueryBlock_INT qb; private cQueryBlock_INT cqb; private QEP QEPlan; private HashSet inputGraphs; private StoredDataGraph outputGraph; public Query(String [ ] i, String o, QueryBlock_INT q) { ig = i; og = o; qb = q;
QEPlan=null; cqb=null; inputGraphs=nul1 ; outputGraph=null ; } public HashSet inGraphs ( ) { inputGraphs = new HashSet ( ) ; for (int i=0; i < ig. length; i++) { try {
DataGraph g=DataRepository.getGraph(ig[i] ) ; inputGraphs . add(g) ; if (g instanceof StoredDataGraph) { inputGraphs = inputGraphs .union (( (StoredDataGraph) g) . getlmpor tedGraphs () ) ; } } catch (NotFound e) {
System. err.println(e. toStringO ) ; throw new RuntimeException () ; } } return inputGraphs; } public String outGraph () { return og; } public QueryBlock_INT bodyO { return qb; } public cQueryBlock_INT cbodyO { return cqb; } public void putlnputGraphs (HashSet set) {inputGraphs=set; } public void putOutputGraph ( StoredDataGraph graph){outputGraph=graph; } public void clean(){ cqb=new cQueryBlock( (QueryBlock) qb) ; } public void optimize () throws Exception{ try{
QEPlan=Optimizer. optimize (this) ; } catch (Exception e) {
System. err.println( "Optimizer exception: "+e. toStringO ) ; throw e; }
String QEPgraph = Environment. getEnv ( "INPUT_DIR" ) +File . separator+ou tGraph ( ) +File . separator+ "tmp" +File . separator+ "QEP" ;
System. out.println( "Query Execution Plan in: "+QEPgraph) ;
PrintStream QEPfile, SGfile; try{
QEPfile = new PrintStream(new FileOutputStream(QEPgraph) ) ;
QEPlan.print (QEPfile) ;
QEPfile. close () ; } catch (Exception e) {
System. err .println( "Exception while printing QEP: "+e. toStringO ) throw e; } /*
System. out .println( "Graph schema file name: " +Environment . getEn ( "GS") ) ; try{
SGfile=new PrintStrea (new FileOutputStream(Environment .getEnv ( "G S"))); printGraphSchema (SGfile) ;
SGfile. close ( ) ;
} catch (Exception e) {
System. err .ρrintln( "Exception while printing graph schema: "+e.to String () ) ; throw e;
}
*/ } public void run (PrintStream profile) throws Exception{ if (QEPlan == null) optimizeO;
QEPlan. run (profile) ; } public String toStringO { return "input graph: " +ig+ " \noutput graph: "+og+"\n"+qb. toString () +" \nClean automata: " +cqb. toString () ; } public void printGraphSchema (PrintStream out) { out .println ( "digraph " +outGraph () + " { " ) ; HashSet links=cqb. getLinkClausesStar ( ) ; HashSet nodes=new HashSet ( ) ; Enumeration iter=links. elements () ; while (iter .hasMoreElements ( ) ) {
Link_INT 1= ( (Link_INT) ( iter .nextElement () ) ) ;
NodeExpr_INT from=l . getlnputState ( ) . getSymbol ( ) ;
NodeExpr_INT to=l . getOutputState ( ) . getSymbol ( ) ; nodes . add( from. toDot ( ) ) ; nodes . ad ( to . toDot () ) ,-
String a=l . getLabel ( ) . toString ( ) ; out.println(from.toDot() + " -> "+to. toDot () +" [label=\ " "+a+" \ " ] ; " )
} iter=nodes . elements ( ) ; while (iter .hasMoreElements ( ) ) {
String s= ( (String) (iter.nextElement () ) ) ; out.println(s+" [style=filled,color=lightskyblue, label=\ " "+s+" V
; " ) ;
} out .printIn ( " } " ) ; out. close ( ) ;
}
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <QueryBlock. java>=
*/ package Automata; import COM.objectspace. jgl. *; import java.util.*; import java . io . * ; import Querylnterpretor . * ; import DataRepository. * ; import java.lang.*; public class QueryBlock implements QueryBlock_INT { /* select fragment */ private NodeExpr_INT [ ] nodexs; private Symbol_INT [ ] arcs ; / * not used * / private BoolExpr_INT [ ] conds; private Automata_IN [ ] automs ;
/* create & link fragment */ private NodeExpr_INT [ ] createxs ; private Link_INT[] linkexs; private CollExpr_INT[] collexs; private QueryBlock_IN [ ] subqs;
/* constructor */ public QueryBlock(NodeExpr_INT[] a, Symbol_INT [ ] b, BoolExpr_INT [ ] c, Automata_IN [ ] d,
NodeExpr_INT [ ] e, Link_INT[] f, CollExpr_INT [ ] g, QueryBlock_INT [ ] h) { nodexs = a; arcs = b; conds = c; automs = d; createxs = e; linkexs = f; collexs = g; subqs = h; }
/* the public interface */ public NodeExpr_INT [ ] nodeExprs () { return nodexs; } public Symbol_INT[] arcVars () { return arcs; } /* not used */ public BoolExpr_INT [ ] conditions () { return conds; } public Automata_IN [ ] automata ( ) { return automs; } public NodeExpr_INT [ ] createExprs 0 { return createxs;} public Link_INT[] linkExprsO { return linkexs; } public CollExpr_INT[] collExprs ( ) { return collexs; } public QueryBlock_INT [ ] subQueries ( ) { return subqs; } public String toStringO {
String s = " \nQuery Block: ["; s += " \nConditions : \n" ; for (int i=0; i<conds. length; i++) s += conds [i] .toString( ) ; s += "\nAutomatons: \n" ; for (int i=0; i<automs. length; i++) s += automs [i] . toStringLong ( ) ; s += "\nCreate Expressions: \n" ; for (int i=0; i<createxs. length; i++) s += createxs [i] . toStringO ; s += "\nLink Expressions: \n" ; for (int i=0; i<linkexs. length; i++) s += linkexs [i] .toStringt ) ; s += "\nCollect Expressions: \n" ; for (int i=0; i<collexs. length; i++) s += collexs [i] .toStringO ; s += "\nSub Queries :\n"; for (int i=0; i<subqs. length; i++) s += subqs [i] . toString ; s += "\n] \n"; return s; }
/* additional stuff */ public SymbolTable symtab; }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at * the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <QueryBlock_INT. java>= */ package Automata; import java.util.*; import COM. ob ectspace . jgl . * ; import java . io . * ; public interface QueryBlock_INT { /* select fragment */ public NodeExpr_INT [ ] nodeExprs ( ) ; public Symbol_INT[] arcVars () ; public BoolExpr_IN [ ] conditions () ; public Automata_IN [ ] automata ();
/* create & link fragment */ public NodeExpr_IN [ ] createExprs ( ) ; public Link_INT [ ] linkExprs ( ) ; public CollExpr_INT [ ] collExprs ( ) ; public String toStringO; public QueryBlock_IN [ ] subQueries ( ) ;
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <Query_INT. java>= */
/it*************************************************************** / /* QUERY: has a tree structure */ package Automata; import java.util . * ; import COM. objectspace . jgl . * ,- import java.io.*; public interface Query_INT { public HashSet inGraphs ( ) ; public String outGraph () ; public void clean() ; /* has to be called BEFORE toDispalyO */ public String toStringO; public QueryBlock_INT bodyO; /* public HashSet getVars () ; */ }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <RpeAlt. java>=
*/ package Automata; import java.util.*; import COM.ob ectspace. gl .* ; public class RpeAlt implements Rpe_INT { private Rpe_INT rl, r2; /* Rpe I Rpe */ RpeAlt (Rpe_INT rl, Rpe_INT r2) { this.rl = rl; this.r2 = r2 ; } public Automata_INT toAutomata () {
{ Automata_INT al = rl . toAutomata () , a2 = r2. toAutomata ( ) ; State_INT inl=al . getlnputState ( ) , outl=al . getOutputState ( ) , in2=a2.getlnputState ( ) , out2=a2.getOutputState ( ) ; Link_INT[] 11 = al . getLinks () , 12 = a2. getLinks () ;
Link_INT [ ] 1 = new Link_INT [11. length+12. length+4] ; State_INT in = new State ( ) , out = new State ( ) ;
int j=0; l[j++] = new Link(in, inl, new UnaryBoolExprEps () ) for (int i=0; i<ll .length; i++) l[j++] = 11 [i] ; l[j++] = new Link(outl, out, new UnaryBoolExprEps () )
l[j++] = new Link(in, in2, new UnaryBoolExprEps ()) ; for (int i=0; i<12. length; i++) l[j++] = 12 [i] ; l[j++] = new Link(out2, out, new UnaryBoolExprEps ()) ; return new Automata (in, out, 1) ; } }
} /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Here there is an error that I don't understant. Dana.
*/ /*
*/ /*
*/ /*
*/ /* <RpeAtomic. java>=
*/ package Automata; import java.util.*; import COM.objectspace. jgl .* ; public class RpeAtomic implements Rpe_INT { private UnaryBoolExpr_INT pi, p2;
RpeAtomic (UnaryBoolExpr_INT pi) { this.pl = pi; this.p2 = new Unary BoolExprTrue ( ) ; }
RpeAtomic (UnaryBoolExpr_INT pi, UnaryBoolExpr_INT p2) { this.pl = p 1; this.p2 = p2 ; } public Automata_INT toAutomata () { State_INT in = new StateO; State_INT out = new State ( ) ;
Link_INT [ ] edges = new Link_IN [1] ; edges [0] = new Link (in, out , pi ) ;
/***** Here I ignore p2 : node conditiosn are not yet implement return new Automata (in, out, edges); } public UnaryBoolExpr_INT UnaryBoolExpr () { return pi; }
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/ * <RpeConcat . java>=
*/ package Automata; import java.util.*; import COM.objectspace. jgl .* ; public class RpeConcat implements Rpe_INT { private Rpe_INT rl, r2; public RpeConcat (Rpe_INT rl, Rpe_INT r2) { this.rl = rl ; this.r2 = r2; } public Automata_INT toAutomata ( ) {
{ Automata_INT al = rl . toAutomata 0 , a2 = r2. toAutomata ( ) ; State_INT inl=al . getlnputState ( ) , outl=al . getOutputState ( ) , in2=a2. getlnputState ( ) , out2=a2. getOutputState ( ) ; Link_INT[] 11 = al . getLinks () , 12 = a2.getLinks () ;
Link_INT[] 1 = new Link_INT [11. length+12. length+1] ; int j=0;
for (int i=0; i<ll. length; i++) l[j++] = ll[i]; l[j++] = new Link(outl, in2 , new UnaryBoolExprEps ()) ; for (int i=0; i<12. length; i++) l[j++] = 12 [i]; return new Automata (inl , out2, 1) ;
} }
} /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <RpePlus. java>=
*/ package Automata; import java.util.*; import COM. objectspace. jgl . * ; public class RpePlus implements Rpe_INT { private Rpe_INT rl; /* Rpe '*' */ RpePlus (Rpe_INT rl) { this.rl = rl; } public Automata_INT toAutomata ( ) { { Automata_INT al = rl . toAutomata ( ) ;
State_INT inl=al . getlnputState ( ) , outl=al . getOutputState ( ) ; Link_INT[] 11 = al .getLinks () ;
Link_INT [ ] 1 = new Link_INT [11. length+1] ; int j=0; for ( int i=0 ; i<ll . length; i++) l [j++ ] = ll [ i ] ; l [ j ++] = new Link (outl , inl , new UnaryBoolExprEps ( ) , true) ; return new Automata ( inl , outl , 1 ) ; / * here is the dif ference from star * / } } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <RpeStar. java>=
*/ package Automata; import java.util.*; import COM.objectspace. jgl . *; public class RpeStar implements Rpe_INT { private Rpe_INT rl; /* Rpe '*' */ RpeStar (Rpe_INT rl) { this.rl = rl; } public Automata_INT toAutomata () { { Automata_INT al = rl . toAutomata ( ) ;
State_INT inl=al . getlnputState ( ) , outl=al . getOutputState ( ) ; Link_INT[] 11 = al . getLinks () ;
Link_INT [ ] 1 = new Link_INT [11. length+1] ; int j=0; for(int i=0; i<ll. length; i++) l[j++] = 11 [i], l[j++] = new Link(outl, inl, new UnaryBoolExprEps () , true); return new Automata (inl , inl, 1); /* here is the difference from plus */ } }
} /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at the code is not an official product of AT&T Corp., and is provided on an "as is" basis with no warranty, either express or implied, in' eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* A [[Rpe]] is a regular expression over pairs of (link attributes or
*/ /* unary link predicates) and (node contents or unary node predicates) .
*/ /* The concatenation, alternation, and kleene-closure operators are
*/ /* implemented as subtypes of [[Rpe]]. A [[Rpe]] can expand'' itself
*/ /* into an automata, which contains only atomic labels.
*/
/*
*/
/*
*/
/*
*/
/*
*/
/* <Rpe_ -INT . java>=
*/ package Automata; import ;java .util.*; import COM. objectspace. •jgl-*;
public interface Rρe_INT { public Automata_INT toAutomata (); }
* Copyright 1997 AT&T Labs -- Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/ * <SemanticError . java>= * / package Automata; import java.util.*; import COM.objectspace. jgl. *; public class SemanticError extends StrudelError { public SemanticError (String s) { error = "Semantic error: " + s; } }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code . */
/* <State. java>=
*/ package Automata; import COM.objectspace. jgl. *; import java.util.*; import java.io.*; import QueryParser . * ; public class State implements State_INT { private NodeExpr_INT s; private boolean ace; public State () { s = new NodeExprVar (Strudel . symtab . genSym ( ype. typeN ode)); } public State ( Symbol_INT x) { s = new NodeExprVar (x) ; } public State (NodeExpr_INT x) { s = x; } public String toString () { return "State ( "+s . toString ()+")"; } public void fi (HashSet cXCc) throws RuntimeException { NodeExprVar si;
ValueExpr_IN [ ] al = new ValueExpr_IN [2 ] ; ValueExprConst a2 ; try { if(s instanceof NodeExprConst) { si = new NodeExprVar (Strudel. symtab. genSym (Type. typeNode) ) ; al [0] = new ValueExprVar (si . getSymbol () ) ; a2= new ValueExprConst ( ( (NodeExprConst) s) .getValueO ) ; al[l]=a2; cXCc.add(new BoolExprPred (Strudel .opEQ, al)); s=sl; } } catch (Exception e) {
System. err.println(e. toStringO ) ; throw new RuntimeException (e. toStringO ) ; } } public void changeSymbol (NodeExpr_INT si) { s=sl; } public NodeExpr_INT getSymbol ( ) { return s; } public HashSet getVars ( ) {return s.getVarsO;}
//DANA public Symbol getVar () throws RuntimeException{ HashSet vars=getVars ( ) ; if (vars.sizeO !=1) throw new RuntimeException ("Sorry not implemented yet!"); Enumeration iter=vars .elements ( ) ; while ( iter . hasMoreElements ( ) ) return ( ( Symbol ) (iter . nextElement 0 ) ) ; return null; } public boolean getAcc 0 { return ace; } public void setAcc (boolean b) { ace = b; }
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <State_INT. java>= */ package Automata; import java.util.*; import java.io.*; import COM.objectspace. jgl. *; public interface State_INT { public NodeExpr_INT getSymbol ( ) ; public void changeSymbol (NodeExpr_INT s) ; public HashSet getVars ( ) ; public void fix(HashSet cXCc) ; public String toStringO; public boolean getAcc(); /* accessibility flag: used in elimination of eps-edges */
public void setAcc (boolean b) ; /* set accessibility flag */ }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp. , and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <StrudelError. java>= */ package Automata; import java.util . * ; import COM.objectspace. jgl . *;
/★★★A************************************************************/ /* Exceptions */ public class StrudelError extends Exception { public String error; public static void checkArgCount (int n, int exp, String s) throws Se manticError { if (exp != n) throw new SemanticError(s+" \nlnvalid argument count. Expected "+ Integer. toString(exp) +" . Found "+Integer. toString (n) ) ;
} } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness * for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* \subsection{Symbols}
*/ /* A [[Symbol]] has a name and a type.
*/ /*
*/ /* <Symbol. java>=
*/ package Automata; import java.util.*; import COM.objectspace. jgl . *; public class Symbol implements Symbol_INT { private String n; private Type_INT t; private boolean gend; public Symbol (String x) { n = x; t = new TypeAnyO ; gend = false; } public Symbol (String x, Type_INT y) { n = x; t = y; gend = false; } public Symbol (String x, Type_INT y, boolean b) { n = x; t = y; gend b; } public String toStringO {return n; } public String getName () { return n; } public Type_INT getType () { return t; } public void setType (Type_INT tNew) { t = tNew; } public boolean isGenerated( ) { return gend; } public boolean isNod Variable ( ) { return true;} //DANA public boolean isArcVariable( ) { return true;} //DANA public void expect (Type_INT type) throws TypeError { if (type == Type. typeAny) return; else if (t == Type.typeAny) { t = type; return; } else if (t == type) return; else throw new TypeError(n, type, t) ; } }
Copyright 1997 AT&T Labs — Research
By receiving and using the code that follows, the user acknowledges and agrees to keep the code confidential and use the code solely for non-commercial research. The user further acknowledges and agrees th at * the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness * for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <SymbolTable. java>=
*/ package Automata; import COM.objectspace. jgl . *; import jav .util . * ; import QueryParser . * ; import Util . * ; public class SymbolTable extends Hashtable { static int symid = 0; Symbol sym; public SymbolTable () { super (); },- /* String -> Symbol map */
/* generate a unique symbol */ public Symbol genSym (Type_INT t) { symid += 1; return new Symbol ("S" + Integer. toString (symid) , t, true); } public Symbol install (String name) { sym = (Symbol) super. get (name) ; if (sym == null) {
// System. err.println( "Installing "+name) ; sym = new Symbol (name, Type. typeAny) ; super .put (name, sym); } return sym; } public Symbol install (String name, Type_INT type) throws ParseError { try { sym = (Symbol) super. get (name) ; if (sym == null) { sym = new Symbol (name, type); super.put (name, sym); return sym; } else { sy . expect (type) ; return sym; } } catch (TypeError e) {
System. out.println(e. error) ; throw new ParseError ( ) ; } } public void insert (Symbol sym) throws AlreadyDefined { String name = sym. getName ( ) ; if ( super. containsKey (name) ) throw new AlreadyDefined (name) ; else super.put (name, sym); } public Symbol lookup (String name) throws NotFound { Symbol sym = (Symbol) super .get (name) ; if (sym == null) throw new NotFound (name) else return sym }
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp. , and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <Symbol_INT. java>= */ package Automata; import java.util.*; import COM.objectspace. jgl . *; public interface Symbol_INT extends BaseValue_INT { public String getName (); public String toString ( ) ; public Type_INT getType(); public void setType (Tyρe_INT tNew); public void expect (Type_INT t) throws TypeError; /* forces this type on the symbol */ public boolean isGeneratedO ; }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories * with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <Type.java>= package Automata; import COM.objectspace. jgl .* ; import java.util.*; public class Type { static TypeNode typeNode new TypeNode ( ) static TypeLink typeLink new TypeLink ( ) static TypePath typePath new TypePath ( ) static TypeSkol typeSkol new TypeSkol ( ) static TypeColl typeColl new TypeColl 0 static TypePred typePred new TypePred ( ) static TypeString typeString new TypeString ( ) static Typelnt typelnt new Typelnt ( ) ; static TypeFloat typeFloat new TypeFloat ( ) ; static TypeBool typeBool new TypeBool ( ) ; static TypeAny typeAny new TypeAny () ; •
}
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <TypeAny. java>=
*/ package Automata; import java .util . * ,- import COM.objectspace. jgl. *; public class TypeAny implements Type_INT { public String getTypeO { return "TypeAny"; } } * Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code . */
/* <TypeBool. java>=
*/ package Automata; import java.util.*; import COM.objectspace. jgl. *; public class TypeBool implements Type_INT { public String getTypeO { return "TypeBool"; } } /*
* Copyright 1997 AT&T Labs -- Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code . */
/* <TypeColl. java>=
*/ package Automata; import java.util.*; import COM.objectspace. gl . *; public class TypeColl implements Type_INT { public String getType ( ) { return "TypeColl"; } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided * on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* -cTypeError. java>= */ package Automata; import ava.util.*; import COM.objectspace. jgl. *; public class TypeError extends StrudelError {
TypeError (String name, Type_INT expected, Type_INT found) { error = "Type error for " + name + " : Expected " + expected. getT ype() + ". Found " + found. getTypeO + "\n";
} } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <TypeFloat. java>=
*/ package Automata; import java.util.*; import COM.objectspace. jgl .* ; public class TypeFloat implements Type_INT { public String getTypeO { return "TypeFloat"; } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding * but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code . */
/* <TypeInt .java>=
*/ package Automata; import java.util.*; import COM.objectspace. jgl. *; public class Typelnt implements Type_INT { public String getTypeO { return "Typelnt"; } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <TypeLink. java>=
*/ package Automata; import java.util.*; import COM.objectspace. gl. * ; public class TypeLink implements Type_INT { public String getTypeO { return "TypeLink"; } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code . */ /* \subsection{Types}
*/ /*
*/ /* Types refer to the types we can associate to the individual Struql
*/ /* tokens. The types are: nodes, links, paths, skolem functions,
*/ /* collection names, predicate names, strings, integers and floats. We
*/ /* use types by associating them to symbols: when a symbol is found a
*/ /* second time in an Struql query, we check that it has the same
*/ /* type. Sometimes we don't know the type of an identifier: then we cal 1 */ /* it TypeAny. In time, TypeAny evolves to some known type: this
*/ /* evolution is ireversible. We also use types by associating them to
*/ /* datavalues : these can only be strings, integers, or floats.
*/ /*
*/ /*
*/ /*
*/ /* <TypeNode . java>=
*/ package Automata; import java.util.*; import COM.objectspace. gl .* ; public class TypeNode implements Type_INT { public String getTypeO { return "TypeNode"; } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <TypePath. java>= */ package Automata; import java.util.*; import COM.objectspace. jgl . *; public class TypePath implements Type_INT { public String getTypeO { return "TypePath"; } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringemen .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <TypePred. java>=
*/ package Automata; import java.util.*; import COM.objectspace. jgl . *; public class TypePred implements Type_INT { public String getTypeO { return "TypePred"; } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code . */
/* <TypeSkol. java>=
*/ package Automata; import java.util.*; import COM.objectspace. jgl . *; public class TypeSkol implements Type_INT { public String getTypeO "{ return "TypeSkol"; } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <TypeString. java>=
*/ package Automata; import java.util.*; import COM.objectspace. jgl . *; public class TypeString implements Type_INT { public String getTypeO { return "TypeString"; } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <Type_INT. java>= */ package Automata; import java.util . * ; import COM.objectspace. jgl .* ; public interface Type_INT { public String getType ( ) ; } * Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* \section{Untyped Expressions}
*/ /* These are transient values, which exists only during parsing. The
*/ /*
*/ /*
*/
*/ /*
*/ /* <UExprDataValue . java>=
*/ package Automata; import COM.objectspace. jgl .* ; import java.util.*; import DataRepository.*; public class UExprDataValue implements UExpr_INT { private DataValue v; public UExprDataValue (DataValue u) { v = u; } public NodeExpr_INT toNodeExpr ( ) { return new NodeExprConst (v) ; } public BoolExρr_INT toBoolExpr ( ) throws RuntimeException { if ( !v.getTypeO .equals ( "bool" ) )
{throw new RuntimeException (v. toString () +v.getType ()); } return new BoolExprConst ( (BoolDataValue) v) ; } public UnaryBoolExpr_INT toUnaryBoolExpr (boolean topLevel) { if ( (v.getTypeO .equals ( "bool" ) && (v. equals (BoolDataValue. RUE) ) ) ) return new UnaryBoolExprTrue ( ) ; else return new UnaryBoolExprConst (v) ; }
public CollExpr_INT toCollExprO throws RuntimeException { throw new RuntimeException (v. toString 0 +v. getType () ) ;
} public ValueExpr_INT toValueExpr ( ) { return new ValueExprConst (v) ; } public Rpe_INT toRpe (boolean topLevel) { return new RpeAtomic (new UnaryBoolExprConst (v) ) ; } }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <UExprFunctionCall . java>=
*/ package Automata; import java.util.*; import COM.objectspace. jgl. * ; import DataRepository.*; import QueryParser . * ; public class UExprFunctionCall implements UExpr_INT { private Symbol_INT f; private UExpr_INT args [ ] ; public UExprFunctionCall (Symbol_INT x) { f = x; args = new UExpr_INT [0] ; } public UExprFunctionCall (Symbol_INT x, UExpr_INT a) { f = x; args = new UExpr_INT [1] ; args[0] = a; } public UExprFunctionCall (Symbol_INT x, UExpr_INT a, UExpr_INT b) { f = x; args = new UExpr_INT[2] ; args[0] = a; args[l] = b; } public UExprFunctionCall (Symbol_INT x, UExpr_INT[] a) { f = x; args = a; } public NodeExpr_INT toNodeExpr ( ) throws TypeError, SemanticError { NodeExpr_INT a [ ] ; f . expect (Type . typeSkol ) ; a = new NodeExpr_INT[args. length] ; for (int i=0; i<args. length; i++) a [i] = args [i] . toNodeExpr ( ) ; return new NodeExprSkol ( f , a); } public BoolExpr_INT toBoolExprO throws TypeError, SemanticError { BoolExpr_INT r = new BoolExprConst (new BoolDataValue (false) ) ; if (f == Strudel.opOR) {
StrudelError. checkArgCount (args. length, 2, "Operator OR"); return new BoolExprOr (args [0] .toBoolExprO , args [1] . toBoolExpr () )
} else if (f == Strudel.opAND) {
StrudelError. checkArgCount (args. length, 2, "Operator AND"); return new BoolExprAnd (args [0] .toBoolExpr () , args [1] . toBoolExpr ( ) );
} else if (f == Strudel .opNOT) {
StrudelError. checkArgCount (args. length, 1, "Operator NOT"); return new BoolExprNot (args [0] . toBoolExpr () ) ; } else if (f == Strudel. opIN) {
StrudelError. checkArgCount (args. length, 2, "Operator IN");
UExpr_INT v = args [0] ;
UExprSet s = (UExprSet) args[l]; for (int i=0; i<s .args. length; i++) {
ValueExpr_INT [ ] a2 = new ValueExpr_INT [2] ; a2[0] = v.toValueExprO ; a2 [1] = s . args [i] . toValueExpr ( ) ; r = new BoolExprOr (r, new BoolExprPred (Strudel .opEQ, a2)); } } else if (Strudel . isBuiltinPred (f) ) {
ValueExpr_INT [ ] a = new ValueExpr_INT[l] ;
StrudelError. checkArgCount (args. length, 1, "Builtin predicate"); a[0] = args [0] .toValueExpr () ; r = new BoolExprPred(f , a) ,- } else {
ValueExpr_INT [ ] a = new ValueExpr_INT [args. length] ,- for (int i=0; i<args . length; i++) a [ i ] = args [i] . toValueExpr ( ) ; return new BoolExprPred ( f , a) ; } return r; } public UnaryBoolExpr_INT toUnaryBoolExpr (boolean topLevel) throws Typ eError, SemanticError { if (f == Strudel. opOR | | f == Strudel.opAND) {
StrudelError .checkArgCount (args. length, 2, "Relational operator") if (f == Strudel. opOR) return new UnaryBoolExprOr (args [0] .toUnaryBoolExpr (false) , argsfl] .toUnaryBoolExpr (false) ) ; else if (f == Strudel.opAND) return new UnaryBoolExprAnd (args [0] .toUnaryBoolExpr (false) , args [1] .toUnaryBoolExpr (false) ) ; } else if (f == Strudel. opNOT) {
StrudelError . checkArgCount (args . length, 1 , "Operator NOT" ) ; return new UnaryBoolExprNot (args [0] .toUnaryBoolExpr (false) ) ; } else throw new SemanticError ( "Function calls not allowed in regular ex pressions . " ) ; return new UnaryBoolExprTrue ( ) ; } public CollExpr_INT toCollExprO throws TypeError, SemanticError { f . expect (Type . typeColl ) ;
StrudelError .checkArgCount (args. length, 1, "Only unary collections are allowed. " ) ; return new CollExpr (f, args [0] . toNodeExpr () ) ; } public ValueExpr_INT toValueExpr () throws SemanticError, TypeError { ValueExpr_INT e; if (Strudel. isArithOp (f) ) {
StrudelError. checkArgCount (args . length, 2, "Operator "+f.getName( )); if (f == Strudel. opPLUS) { e = new ValueExprPlus (args [0]. toValueExpr () , args [1] . toValueEx pr () ) ;
} else if (f == Strudel. opMINUS) { e = new ValueExprMinus (args [ 0 ] . toValueExpr ( ) , args [ 1 ] . toValueE xpr ( ) ) ;
} else if (f == Strudel. opSTAR) { e = new ValueExprTimes (args [0] .toValueExpr () , args [1] . toValueE pr ( ) ) ;
} else if (f == Strudel. opSLASH) { e = new ValueExprDiv(args [0] . toValueExpr () , args [1] . toValueExp r());
} else throw new SemanticError ( "Invalid arithmetic operator "+f.g etName ( ) ) ; } else {
ValueExpr_INT [ ] a = new ValueExpr_INT [args . length] ; for (int i=0; i<args . length; i++) a[i] = args [i] .toValueExpr () ; e = new ValueExprFunctionCall (f , a); } return e; }
public Rpe_INT toRpe (boolean topLevel) throws SemanticError, TypeErro r { if (f == Strudel .opDOT) {
StrudelError . checkArgCount (args . length, 2 , " " ) ; return new RpeConcat (args [0] .toRpe( topLevel) , args [1] . toRpe ( topLe vel));
} else if (f == Strudel . σpBAR) { StrudelError . checkArgCount (args . length, 2 , " " ) ; return new RpeAlt (args [0] . toRpe ( false) , args [1] . toRpe (f lse) ) ; } else if (f == Strudel. opCOLON) {
StrudelError . checkArgCount (args . length, 2 , " " ) ; return new RpeAtomic (args [0] .toUnaryBoolExpr (false) , args[l] .toUnaryBoolExpr (false) ) ; } else if (f == Strudel . opPLUS) {
StrudelError . checkArgCount (args . length, 1 , " " ) ; return new RpePlus (args [0] . toRpe (false) ) ; } else if (f == Strudel. opSTAR) {
StrudelError . checkArgCount (args . lengt , 1 , " " ) ; return new RpeStar (args [0] . toRpe( false) ) ; } else return new RpeAtomic (this. toUnaryBoolExpr (topLevel) ) ;
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <UExprId. java>=
*/ package Automata; import java.util. *; import COM.objectspace. jgl .* ; import QueryParser . * ; public class UExprld implements UExpr_INT { private Symbol_INT s; public UExprld (Symbol_INT x) { s = x; } public NodeExpr_INT toNodeExpr ( ) throws TypeError { s . expect (Type . typeNode) ; return new NodeExprVar (s) ; } public BoolExpr_INT toBoolExprO throws TypeError, SemanticError { s. expect (Type. typeBool) ; return new BoolExprPred ( s , new ValueExpr_INT [ 0 ] ) ; } public UnaryBoolExpr_INT toUnaryBoolExpr (boolean topLevel) throws Ty peError, SemanticError { if (topLevel) { s .expect (Type . typeLink) ; return new UnaryBoolExprVar (s) ; } else { ε. expect (Type. typeBool) ; return new UnaryBoolExprPred(s) ; } } public CollExpr_INT toCollΞxpr ( ) throws SemanticError { throw new SemanticError ( "Expected \"(\" after "+s. getName () ) ; } public ValueExpr_INT toValueExpr ( ) { return new ValueExprVar ( s ) ; } public Rpe_INT toRpe (boolean topLevel) { if (s == Strudel.predTrue) return new RpeAtomic (new UnaryBoolExpr True 0 ) ; if (topLevel) return new RpeAtomic (new UnaryBoolExprVar (s) ) ; return new RpeAtomic (new UnaryBoolExprPred (s) ) ; } } **********************************★****★***********************★*
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <UExprSet. java>=
*/ package Automata; import java .util . * ; import COM.objectspace. jgl. *;
/*
Used only in expressions like "x IN {a, b, c, d} " to store the set {a, b, c, d}.
Never converted directly to a typed expression. */ public class UExprSet implements UExpr_INT { public UExpr_INT args[]; public UExprSet (UExpr_INT a[]) {args = a;} public NodeExpr_INT toNodeExpr 0 { return null;} public BoolExpr_INT toBoolExprO { return null;} public UnaryBoolExpr_INT toUnaryBoolExpr (boolean b) { return null;} public CollExpr_INT toCollExpr() { return null;} public ValueExpr_INT toValueExpr () { return null;} public Rpe_INT toRpe (boolean topLevel) { return null;}
/★★♦★★★★A*********************************************************/
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <UExpr_INT. java>= */ package Automata; import java.util.*; import COM.objectspace. jgl. *; public interface UExpr_INT { public NodeExpr_INT toNodeExpr () throws SemanticError, TypeError,- public BoolExpr_INT toBoolExprO throws SemanticError, TypeError; public UnaryBoolExpr_INT toUnaryBoolExpr (boolean topLevel) throws Se manticError, TypeError; public CollExpr_INT toCollExprO throws SemanticError, TypeError; public ValueExρr_INT toValueExpr 0 throws SemanticError, TypeError; public Rpe_INT toRpe (boolean topLevel) throws SemanticError, TypeErr or; }
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and * improvements to the code.
*/ /* <UnaryBoolExprAnd. java>=
*/ package Automata; import COM.objectspace. jgl. *; import java.util.*; import java. io . * ; import DataRepository. * ; import Querylnterpretor . * ; import java . lang . * ; public class UnaryBoolExprAnd implements UnaryBoolExpr_INT { private UnaryBoolExpr_INT bl, b2 ; public UnaryBoolExprAnd (UnaryBoolExpr_INT x, UnaryBoolExpr_INT y) { b 1 = x; b2 = y; } public DataValue Eval (Binding b) { return new BoolDataValue
( ( (BoolDataValue) (bl.Eval(b) ) ) .booleanValueO &&
( (BoolDataValue) (b2.Eval (b) ) ) .booleanValue ( ) ) ; } public String toStringO { return "And ( "+bl . toString ()+"," +b2. toString ()+")"; } public String getName () { return "UnaryBoolExprAnd"; } public Expr_INT[] getSubExprs () {
Expr_INT[] res = new Expr_INT [2] ; res [ 0 ] = bl ; res [1] = b2; return res; } public BoolExpr_INT cleanNS (ValueExprVar v) { return new BoolExprAnd (bl . cleanNS (v) , b2. cleanNS (v) ) ; } public HashSet getVars ( ) { return bl . getVars ( ) .union (b2. getVars () ) ; } public boolean equals (UnaryBoolExpr_INT b) { if ( ! (b instanceof UnaryBoolExprAnd)) return false; UnaryBoolExprAnd c = (UnaryBoolExprAnd) b; return (bl. equals (c.bl) && b2.equals (c.b2) ) ;
} * Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <UnaryBoolExprConst . java>=
*/ package Automata; import COM.objectspace. jgl .* ; import java. lang. * ; import java.uti1. * ; import java.io.*; import DataRepository.*; import Querylnterpretor. * ; import QueryParser. * ;
/A***********************/ /* UnaryBoolExpr */
public class UnaryBoolExprConst implements UnaryBoolExpr_INT { private DataValue v; public UnaryBoolExprConst (DataValue vi) {v = vi;} public DataValue Eval (Binding b) {
System. out.println ( "Alon wasn't sure what to do here, and doesn't r eally think you should be here: doing eval to a UnaryBoolExprConst."); return v; } public String toStringO {return v. toStringO ; } public BoolExpr_INT cleanNS (ValueExprVar vl) { ValueExpr_INT args[]= new ValueExpr_IN [2] ; try { args [0] =vl; args[l]=new ValueExprConst (v) ; return (new BoolExprPred(Strudel. opEQ, args)); } catch (Exception e) { throw new RuntimeException (e. toStringO ) ; }
} public DataValue getValue ( ) { return v; } public String getName 0 { return "UnaryBoolExprConst"; } public Expr_INT[] getSubExprs () { return new Expr_INT[0] public HashSet getVars ( ) {return new HashSet ( ) ; } public boolean equals (UnaryBoolExpr_INT x) { if ( ! (x instanceof UnaryBoolExprConst)) return false; UnaryBoolExprConst c = (UnaryBoolExprConst) x; return (v.equals (c.v) ) ;
}
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code . */
/* <UnaryBoolExprEps . ava>=
*/ package Automata; import COM.objectspace. jgl. *; import java.util.*; import java.io. * ; import DataRepository.*; import Querylnterpretor. * ;
public class UnaryBoolExprEps implements UnaryBoolExpr_INT { public String getName 0 { return "UnaryBoolExprEps"; } public Expr_INT[] getSubExprs () { return new Expr_INT[0] ; } public BoolExpr_INT cleanNS (ValueExprVar vl) { return new BoolExprConst (new BoolDataValue (true) ); } public String toStringO { return "Epsilon";} public DataValue Eval (Binding b) {return new BoolDataValue (true) ; } public HashSet getVars ( ) {return new HashSet (); } public boolean equals (UnaiyBoolExpr_INT x) ( if ( ! (x instanceof UnaryBoolExprEps)) return false; return (true) ;
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <UnaryBoolExprNot. java>=
*/ package Automata; import COM. ob ectspace . jgl . * ; import java.lang.*; import java.util.*; import java.io.*; import DataRepository. * ,- import Querylnterpretor. * ;
public class UnaryBoolExprNot implements UnaryBoolExpr_INT { private UnaryBoolExpr_INT b; public UnaryBoolExprNot (UnaryBoolExpr_INT x) { b = x; } public String toStringO { return "Not ( "+b. toString ()+")"; } public DataValue Eval (Binding bl) {return new BoolDataValue
( ! ( (BoolDataValue) (b.Eval (bl) ) ) .booleanValue() ) ,- }
public BoolExpr_INT cleanNS (ValueExprVar v) { return new BoolExprNot (b. cleanNS (v) ) ; } public String getName () { return "UnaryBoolExprNot" public Expr_INT [ ] getSubExprs ( ) { Expr_INT[] res = new Expr_INT[l] ; res[0] = b; return res; } public HashSet getVars ( ) { return b.getVars ( ) ; } public boolean equals (UnaryBoolExpr_INT x) { if ( ! (x instanceof UnaryBoolExprNot)) return false; UnaryBoolExprNot c = (UnaryBoolExprNot) x; return (b. equals (c.b) ) ;
}
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/ * <UnaryBoolExprOr . java>=
*/ package Automata; import COM.objectspace. gl. *; import java.util.*; import java. io . * ; import Querylnterpretor . * ; import DataRepository. * ; import java.lang.*;
public class UnaryBoolExprOr implements UnaryBoolExpr_INT { private UnaryBoolExpr_INT bl, b2 ; public UnaryBoolExprOr (UnaryBoolExpr_INT x, UnaryBoolExpr_INT y) { bl = x; b2 = y; } public String toStringO { return "Or ( " +bl . toString ()+"," +b2. toString ()+")"; } public BoolExpr_INT cleanNS (ValueExprVar v) { return new BoolExprOr (bl . cleanNS (v) , b2. cleanNS (v) ) ; } public DataValue Eval (Binding b) { return new BoolDataValue
{ ( (BoolDataValue) (bl .Eval (b) ) ) .booleanValue ( )
II
( (BoolDataValue) (b2. Eval (b) ) ) .booleanValue ( ) ) ;
} public String getName () { return "UnaryBoolExprOr"; } public Expr_INT[] getSubExprs 0 {
Expr_INT[] res = new Expr_INT[2]; res[0] = bl; res[l] = b2; return res; } public HashSet getVars () { return bl . getVars ( ) .union (b2. getVars ( ) ) ; } public boolean equals (UnaryBoolExpr_INT b) { if ( ! (b instanceof UnaryBoolExprOr) ) return false; UnaryBoolExprOr c = (UnaryBoolExprOr) b; return (bl. equals (c.bl) && b2.equals (c.b2) ) ;
}
/*
* Copyright 1997 AT&T Labs -- Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <UnaryBoolExprPred. java>=
*/ package Automata; import COM.objectspace. gl. *; import java. io . * ,- import java.util.*; import DataRepository.*; import Querylnterpretor . * ; public class UnaryBoolExprPred implements UnaryBoolExpr_INT { private Symbol_INT p; public UnaryBoolExprPred(Symbol_INT pi) {p = pi;} public String getName () { return "UnaryBoolExprPred" ; } public Expr_INT[] getSubExprs ( ) { return new Expr_INT[0] ; } public String toStringO { return p. toStringO ; } public DataValue Eval (Binding b) {
System. out .println( "Alon doesn't think you should be here. You need an explicit variable name in order to evaluate this, and you don't hav e one . " ) ; return null; } public BoolExpr_INT cleanNS (ValueExprVar v) { ValueExpr_INT [ ] args = new ValueExpr_INT [l] ; try { args [ 0 ] =v; return new BoolExprPred (p, args) ; } catch (Exception e) { throw new RuntimeException (e. toString ( )) ; } } public HashSet getVars () {return new HashSet (); }
public boolean equals (UnaryBoolExpr_INT x) { if ( ! (x instanceof UnaryBoolExprPred) ) return false; UnaryBoolExprPred c = (UnaryBoolExprPred) x; return (p == c.p);
}
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <UnaryBoolExprTrue. java>=
*/ package Automata; import java.util.*; import COM.objectspace. jgl . *; import java. io . * ; import DataRepository. * ; import Querylnterpretor. * ; public class UnaryBoolExprTrue implements UnaryBoolExpr_INT { public String getName () { return "UnaryBoolExprTrue"; } public Expr_INT[] getSubExprs ( ) { return new Expr_INT[0],- } public String toStringO { return "true"; } public DataValue Eval (Binding b)
{return new BoolDataValue (true) ; } public BoolExpr_INT cleanNS (ValueExprVar vl) { return new BoolExprConst (new BoolDataValue (true) ); } public HashSet getVars ( ) {return new HashSet (); }
public boolean equals (UnaryBoolExpr_INT x) { if ( ! (x instanceof UnaryBoolExprTrue)) return false; return (true) ;
}
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <UnaryBoolExprVar. java>=
*/ package Automata; import COM.objectspace. jgl . *; import java . io . * ; import java . lang . * ; import java.util.*; import DataRepository.*; import Querylnterpretor . * ; import QueryParser . * ; public class UnaryBoolExprVar implements UnaryBoolExpr_INT { private Symbol_INT p; public String toStringO {return p.getNameO;} public UnaryBoolExprVar (Symbol_INT pi) {p = pi;} public void clean(HashSet cXCx, HashSet cMemc, HashSet cother) {retur n;} public String getName () { return "UnaryBoolExprVar"; } public Expr_INT[] getSubExprs ( ) { return new Expr_INT[0] ; } public DataValue Eval (Binding b) {return b. getBinding ( (Symbol) p) .get
Value ( ) ; } public BoolExpr_INT cleanNS (ValueExprVar vl) { ValueExpr_INT args[]= new ValueExpr_INT[2] ; try { args [0 ] =vl ; args [1] =new ValueExprVar (p) ; return (new BoolExprPred ( Strudel . opEQ, args)); } catch (Exception e) { throw new RuntimeException (e. toString ( ) ) ; } } public Symbol_INT getSymbol ( ) { return p; } public HashSet getVars ( ) {
HashSet set= new HashSet ( ) ; set. add (p) ; return set ; } public boolean equals (UnaryBoolExpr_INT x) { if ( ! (x instanceof UnaryBoolExprVar) ) return false; UnaryBoolExprVar c = (UnaryBoolExprVar) x; return (c.p == p) ;
}
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <UnaryBoolExpr_INT . java>= */ package Automata; import java.util.*; import DataRepository. * ; import Querylnterpretor . * ; public interface UnaryBoolExpr_INT extends Expr_INT { public BoolExpr_INT cleanNS (ValueExprVar v) ; public String toStringO; public DataValue Eval (Binding b) ; public String getName (); public boolean equals (UnaryBoolExpr_INT b) ; }
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <ValueExprConst . java>=
*/ package Automata; import java .util.*; import java . io . * ; import COM.objectspace. jgl. *; import DataRepository. * ; import Querylnterpretor . * ;
/* ValueExpr */
public class ValueExprConst implements ValueExpr_INT { private DataValue v; public DataValue Eval (Binding b) {return v; } public ValueExprConst (DataValue x) { v = x; } public String toString ( ) {return v. toString ( ) ; } public DataValue getValue () {return v; } public String getName 0 { return v. toString 0 ; } public Expr_INT[] getSubExprs ( ) { return new Expr_IN [0] ; } public HashSet getVars () {return new HashSet (); } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/ * <ValueExprDiv. java>=
*/ package Automata; import java.util.*; import java.io.*,- import COM.objectspace. gl . *; import DataRepository. * ; import Querylnterpretor . * ; import java.lang.*; public class ValueExprDiv implements ValueExpr_INT { private ValueExpr_INT el, e2; public ValueExprDiv (ValueExpr_INT x, ValueExpr_INT y) { el = x; e2 = y; } public String getName () { return "ValueExprDiv"; } public DataValue Eval (Binding b) { DataValue dl,d2; dl = el. Eval (b) d2 = e2.Eval(b) if(dl instanceof IntDataValue && d2 instanceof IntDataValue)
{return new IntDataValue (((IntDataValue) dl ) . intValue ( ) / ( (IntD ataValue) d2 ) . intValue 0 ) ; } iffdl instanceof FloatDataValue && d2 instanceof FloatDataValue) {return new FloatDataValue (((FloatDataValue) dl) . floatValueO / ( (FI oatDataValue) d2 ) . floatValue 0 ) ; }
System. out.println( "Trying to subtract incompatible types"); return null; }
public String toStringO {return "( "+el. toStringO +" /"+e2.toStringO
' ) " ; } public Expr_INT[] getSubExprs ( ) { Expr_INT [ ] r = new Expr_IN [2 ] ; r[0] = el; r[l] = e2 ; return r; } public HashSet getVars ( ) { return el . getVars ( ) .union (e2. getVars ( ) )
}
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <ValueExprFunctionCall . j ava>=
*/ package Automata; import java.util.*; import java.io.*; import COM.objectspace. jgl. *; import Querylnterpretor. * ; import DataRepository.*; import java . lang . * ; public class ValueExprFunctionCall implements ValueExpr_INT { private Symbol_INT f; private ValueExpr_IN [ ] args; public ValueExprFunctionCall (Symbol_INT x, ValueExpr_IN [ ] y) { f = x ; args = y; } public String getName () { return "ValueExprFunctionCall"; } public String toStringO { return BoolExprPred. funcToString ( f .getName () , args); } public DataValue Eval (Binding b) {
System. out.println( "We don't have function symbols yet. Don't know how to evaluate them" ) ; return null; } public Expr_INT[] getSubExprs () { return args; } public HashSet getVars ( ) {
HashSet set= new HashSet ( ) ; for (int i=0; i<args. length; i++) set = set.union (args [i] .getVars () ) ; return set;
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <ValueExprMinus . java>=
*/ package Automata; import COM.objectspace. jgl . *; import java . lang . * ; import java.util.*; import java . io . * ; import DataRepository.*; import Querylnterpretor . * ;
public class ValueExprMinus implements ValueExpr_INT { private ValueExpr_INT el, e2; public ValueExprMinus (ValueExpr_INT x, ValueExpr_INT y) { el = x; e2 = y; } public String getName () { return "ValueExprMinus"; } public DataValue Eval (Binding b) { DataValue dl,d2; dl = el.Eval (b) d2 = e2.Eval(b) if (dl instanceof IntDataValue && d2 instanceof IntDataValue)
{return new IntDataValue (((IntDataValue) dl). intValue ( ) - ( (IntD ataValue) d2 ) . intValue ( ) ) ; } if(dl instanceof FloatDataValue && d2 instanceof FloatDataValue) {return new FloatDataValue (((FloatDataValue) dl) . floatValue() - ( (FloatDataValue) d2 ) . floatValue 0 ) ; }
System. out .println( "Trying to subtract incompatible types"); return null; } public Expr_INT[] getSubExprs () {
Expr_INT[] r = new Expr_INT[2]; r[0] = el; r[l] = e2 ; return r; } public String toStringO {return "( "+el. toStringO +" -"+e2. toString ( ) + " ) " ; } public HashSet getVars 0 { return el. getVars () .union (e2.getVars ( ) ) ; } }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code . */
/* <ValueExprPlus . java>=
*/ package Automata; import java.util.*; import COM.objectspace. gl .* ; import java . io . * ; import DataRepository.*; import Querylnterpretor . * ; import java . lang. * ; public class ValueExprPlus implements ValueExpr_INT { private ValueExpr_INT el , e2 ; public ValueExprPlus (ValueExpr_INT x, ValueExpr_INT y) { el = x; e2 = y; } public String getName ( ) { return "ValueExprPlus"; } public Expr_INT[] getSubExprs ( ) {
Expr_IN [ ] r = new Expr_INT [2 ] ; r[0] = el; r[l] = e2; return r; } public DataValue Eval (Binding b) {
DataValue dl,d2; dl = el. Eval (b) d2 = e2.Eval(b) if(dl instanceof IntDataValue && d2 instanceof IntDataValue) {return new IntDataValue (((IntDataValue) dl). intValue ( ) + ( (IntD ataValue) d2 ) . intValue ( ) ) ; } if (dl instanceof FloatDataValue && d2 instanceof FloatDataValue) {return new FloatDataValue (((FloatDataValue) dl) .floatValue() + ( (FloatDataValue) d2 ) . floatValue 0 ) ; } if(dl instanceof StringDataValue && d2 instanceof StringDataValue) {return new StringDataValue (((StringDataValue) dl) .stringValue ( ) + ( (StringDataValue) d2 ) . stringValue ( ) ) ; }
System. out. rintlnf "Trying to subtract incompatible types"); return null; }
public String toStringO {return " ( "+el . toString ( ) +"+"+e2. toString ( ) + " ) " ; } public HashSet getVars () { return el . getVars ( ) .union (e2. getVars ( ) ) ;
} }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <ValueExprTimes . ava>=
*/ package Automata; import java.util.*; import java . io . * ; import COM.objectspace. jgl . *; import DataRepository.*; import Querylnterpretor . * ; import java.lang.*; public class ValueΞxprTimes implements ValueExpr_INT { private ValueExpr_INT el , e2 ; public ValueExprTimes (ValueExpr_INT x, ValueExpr_INT y) { el = x; e2 = y; } public String getName ( ) { return "ValueExprTimes"; } public String toStringO {return "( "+el. toStringO + "*"+e2.toStringO + " ) " ; } public DataValue Eval (Binding b) { DataValue dl,d2; dl = el. Eval (b) ; d2 = e2.Eval(b) ; if(dl instanceof IntDataValue && d2 instanceof IntDataValue)
{return new IntDataValue (((IntDataValue) dl ). intValue O * ( (IntD ataValue) d2 ) . intValue 0 ) ; } if (dl instanceof FloatDataValue && d2 instanceof FloatDataValue)
{return new FloatDataValue (((FloatDataValue) dl) . floatValue () * ( (FloatDataValue) d2 ) . floatValue ( ) ) ; }
System. out.println( "Trying to subtract incompatible types"); return null; }
public Expr_INT[] getSubExprs () { Expr_INT[] r = new Expr_INT[2]; r[0] = el; r[l] = e2 ,- return r;
} public HashSet getVars () { return el . getVars ( ) .union (e2. getVars () ) ;
}
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/ * <ValueExprVar. java>=
*/ package Automata; import java.util.*; import java . io . * ; import COM.objectspace. jgl. *,- import Querylnterpretor . * ; import DataRepository. * ;
public class ValueExprVar implements ValueExpr_INT { private Symbol_INT s; public ValueExprVar (Symbol_INT x) { s = x; } public DataValue Eval (Binding b) {return b. getBinding ( (Symbol) s) .get Value () ; } public DataObject EvalNode (Binding b) {return b. getBinding ( (Symbol) ε ;} public String toString () {return s . getName (); } public Symbol_INT getSymbol () {return s;} public String getName () { return s. getName (),- } public Expr_INT[] getSubExprs 0 { return new Expr_INT[0]; } public HashSet getVars ( ) {
HashSet set= new HashSet ( ) ; set . add ( s) ; return set ; }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <ValueExpr_INT . java>= */ package Automata; import java.util.*; import COM.objectspace. jgl .* ; import java . io . * ; import DataRepository. * ; import Querylnterpretor . * ; import java . lang . * ;
public interface ValueExpr_INT extends Expr_INT { public HashSet getVars 0 ; public String toStringO; public DataValue Eval (Binding b) ; }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at the code is not an official product of AT&T Corp. , and is provided * on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <cQueryBlock. java>=
*/ package Automata; import COM.objectspace. jgl . *; import java . io . * ; import java.lang.*,- import java. til . * ; import Querylnterpretor . * ; import DataRepository.*; public class cQueryBlock implements cQueryBlock_INT { /* select fragment */ private Automata_IN [ ] caut ; private NodeExpr_IN [ ] cnodeex; private Symbol_INT[] carcv; private cQueryBlock_INT [ ] csubqs ; private HashSet cmemc; private HashSet cXCc; private HashSet cXYc; private HashSet cother; private CollExpr_IN [ ] collexs; private Link_INT[] linkexs; private Enumeration iter;
/* Constructor (called only after the automaton is complete) . */ public cQueryBlock(QueryBlock q) {
NodeExpr_INT [ ] nodexs=q.nodeExprs ( ) ; ;
Symbol_INT [ ] arcs=q.arcVars 0 ; ;
BoolExpr_INT [ ] conds=q. conditions () ; ;
Automata_INT [ ] automs=q . automata ( ) ; ;
QueryBlock_INT [ ] subqs= q. subQueries 0 ; ; collexs = q.collExprs () ; linkexs = q.linkExprs () ; cmemc= new HashSet ( ) ; cXCc= new HashSet ( ) ; cXYc= new HashSet ( ) ; cother= new HashSet { ) ,- csubqs = new cQueryBlock_INT [subqs. length] ; for (int i=0; i<conds .length; i++) conds [i] .gentleSeparate (cmemc, cXCc, cXYc, cother, false); for (int j=0; j<automs. length; j++) for (int k=0; k<automs [j ] .getLinks O .length; k++) automs [j] . getLinks () [k] .fix(cXCc, cmemc, cother) ; for (int i=0; i<subqs. length; i++) csubqs [i] = new cQueryBlock ( (QueryBlock) subqs [i] ) caut=automs; cnodeex=nodexs ; carcv=arcs ,-
} public HashSet getVars () {
/* Alon promised to implement this return new HashSet ( ) ; }
public String toStringO {
String s = "\nclean Query Block: [\n"; s += "Automatons : \n" ; for (int i=0; i<caut. length; i++) s += caut [i] . toStringLongO ; s += "Conditions: \n" ; s += "Membership conditions : \n" ; iter = cmemc . elements ( ) ; while (iter .hasMoreΞlements ( ) ) {
BoolExpr_INT oper= ( (BoolExpr_INT) (iter .nextElement ( ) ) ) ; s += oper. toString ( ) ; } s += "X=C conditions: \n" ; iter = cXCc . elements () ,- while (iter.hasMoreElements ( ) ) {
BoolExpr_INT oper= ( (BoolExpr_INT) (iter .nextElement () ) ) ; s += oper . toString ( ) ; } s += "X=Y conditions: \n" ; iter = cXYc . elements ( ) ; while (iter.hasMoreElements ( ) ) {
BoolExpr_INT oper= ( (BoolExpr_INT) ( iter.nextElement ( ) ) ) ; s += oper. toString () ; } s += "Other conditions: \n" ; iter = cother. elements () ; while (iter.hasMoreElements () ) {
BoolExpr_INT oper= ( (BoolExpr_INT) (iter .nextElement 0 ) ) ; s += oper . toString () ; }
s += "clean Sub Queries: \n"; for (int i=0; i<csubqs. length; i++) s += csubqs [i] .toStringO ; s += "] \n" ; return s; } public Automata_INT [ ] cAutomataO {return caut;} public NodeExpr_INT [ ] cNodeExprs ( ) {return cnodeex;} public Symbol_INT[] cArcVars ( ) {return carcv; } public cQueryBlock_INT [] cSubQueries () {return csubqs;} public HashSet cMemConditions ( ) {return cmemc;} public HashSet cXCConditions ( ) {return cXCc;} public HashSet cXYConditions ( ) {return cXYc;} public HashSet cOtherConditions ( ) {return cother;} public HashSet cCondition() {
HashSet answer = new HashSet ( ) ; answer = answer . union (cmemc) ; answer = answer.union (cXCc) ; answer = answer.union (cXYc) ; answer = answer. union (cother) ,- return answer; }
//DANA public HashSet getAutomata ( ) {
HashSet answer = new HashSet ( ) ; for (int i=0; i<caut. length; i++) answer. add (caut [i] ) ; return answer; } public HashSet getCollectClauses ( ) {
HashSet answer = new HashSet ( ) ; for (int i=0; i<collexs . length; i++) answer, add (collexs [i] ) ,- return answer; } public HashSet getLinkClauses ( ) {
HashSet answer = new HashSet ( ) ; for (int i=0; i<linkexs . length; i++) answer . add ( linkexs [i] ) ; return answer; } public HashSet getLinkClausesStar ( ) {
HashSet answer=getLinkClauses ( ) ; for (int i=0; i<csubqs . length; i++) answer=answer . union (csubqs [i] .getLinkClausesStar ( ) ) return answer; } public HashSet getCleanQueryBlocks ( ) {
HashSet answer = new HashSet ( ) ; for (int i=0; i<csubqs. length; i++) answer. add (csubqs [i ] ) ; return answer; }
} /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* <cQueryBlock_INT . java>= */ package Automata; import COM.objectspace. jgl .* ; import java.lang.*; import java.util.*; import java.io.*; import DataRepository. * ; import Querylnterpretor . * ;
public interface cQueryBlock_INT {
/* select fragment */ public String toStringO; public Automata_INT [ ] cAutomataO; public NodeExpr_INT [ ] cNodeExprs ( ) ; public Symbol_INT[] cArcVars ( ) ; public HashSet cMemConditions 0 ; public HashSet cXCConditions ( ) ; public HashSet cXYConditions ( ) ; public HashSet cOtherConditions ( ) ; public HashSet getVars ( ) ; public HashSet getLinkClauses ( ) ; public HashSet getLinkClausesStar ( ) ; }
@
\input{macros}
\section{STRUDEL Front End}
\psfig{figure=. /frontend.ps}
\section{Vocabulary}
{\em Nodes} and {\em links} refer to the nodes and edges in a data grap h.
We call the values of nodes [ [contents] ] and the values of links [ [attributes] ] .
The contents of an internal node is its OID; the contents of a leaf node is an atomic value, called a [ [DataValue] ] , such as integer, boolean, file, image, etc. {\em States} and {\em arcs} refer to nodes and edges in automata, which model conjunctive queries.
\section{Front End} The front end produces a set of input graph names, a set of link symbols, a set of node expressions (can be variables or skolem functions) , the symbol table, [ [Condition] ] s are of three kind: node expression, regular expression, node expression node expression, link symbol, node expression boolean condition
[[Automata]] are derived from the regular expression conditions, by the method [ [deriveAutomata] ]
If the query produces a new graph, i.e., it has a \texttt {CREATE} clause, the front end also produces the name of the output graph, a set of collection names, a list of create expressions, a list of link-range expressions, a list of node-range expressions, a list of link expressions, and a list of collect expressions, which are used by the graph-transformation interpreter. «Query. java»= package automata; import java.util.*; import java . io . * ; import COM.objectspace. jgl .* ; public class Query implements Query_INT { private String ig, og; private QueryBlock_INT qb;
public Query(String i, String o, QueryBlock_INT q) { ig = i; og qb = q; } public String inGraphO { return ig; } public String outGraph () { return og; } public QueryBlock_INT bodyO { return qb; } public void toDisplay(PrintStream out) { cQueryBlock_INT cqb; out . println ( " input graph : " +ig+ " output graph: " +og) ; qb . toDisplay (out) ; cqb=new cQueryBlock ( (QueryBlock) qb) ; out .println ( " Clean automata: " ) ; cqb. toDisplay (out ) ; } «QueryBlock. java»= package automata; import java.util.*; import java . io . * ; import COM.objectspace. jgl. *; public class QueryBlock implements QueryBlock_INT { /* select fragment */ private NodeExpr_INT [ ] nodexs; private Symbol_INT [ ] arcs ; / * not used private BoolExpr_INT [ ] conds ; private Automata_INT [ ] automs ;
/* create & link fragment */ private NodeExpr_INT [ ] createxs ; private Link_INT[] linkexs; private CollExpr_INT[] collexs; private QueryBlock_INT [ ] subqs;
/* constructor */ public QueryBlock (NodeExpr_INT[] a, Symbol_INT[] b, BoolExρr_IN [ ] c, Automata_INT [ ] d,
NodeExpr_IN [ ] e, Link_INT[] f, CollExpr_IN [ ] g, QueryBlock_INT[] h) { nodexs = a; arcs = b; conds = c; automs = d; createxs = e; linkexs = f; collexs = g; subqs = h; }
/* the public interface */ public NodeExpr_INT [ ] nodeExprs 0 { return nodexs; } public Symbol_INT[] arcVars ( ) { return arcs; } /* not used " I public BoolExpr_INT [ ] conditions 0 { return conds; } public Automata_INT [ ] automata () { return automs; } public NodeExpr_INT [ ] createExprs () { return createxs;} public Link_INT[] linkExprsO { return linkexs; } public CollExpr_INT [] collExprs () { return collexs; } public QueryBlock_INT [ ] subQueries () { return subqs; }
public void toDisplay(PrintStream out) { out.println ( "Query Block: ["); out .println ( "Conditions : " ) ; for (int i=0; i<conds. length; i++) conds [i] .toDisplay (out) ; out .println ( "Automatons : " ) ; for (int i=0; ioutoms .length; i++) automs [i] .toDisplay(out) ; - Ill - out.println ( "Create Expressions: ") ; for (int i=0; i<createxs . length; i++) createxs [i] .toDisplay(out) ; out .println ( "Link Expressions : " ) ; for (int i=0; i<linkexs. length; i++) linkexs [i] .toDisplay(out) ; out.println ( "Collect Expressions: " ) ; for (int i=0; i<collexs. length; i++) collexs [i] . toDisplay(out) ; out .println( "Sub Queries : " ) ; for (int i=0; i<subqs. length; i++) subqs [i] .toDisplay (out) ; out.printlnO'] ") ;
}
/* additional stuff */ public SymbolTable symtab;
}
«cQueryBlock. java»= package automata; import java.util.*; import COM.objectspace. jgl . *,- import java.io.*; class cQueryBlock implements cQueryBlock_INT { /* select fragment */ private Automata_INT [ ] caut ; private NodeExpr_INT [ ] cnodeex; private Symbol_INT[] carcv; private cQueryBlock_INT [ ] csubqs; private HashSet cmemc; private HashSet cXCc; private HashSet cXYc; private HashSet cother; private Enumeration iter;
/* Constructor (called only after the automaton is complete) . */ public cQueryBlock (QueryBlock q) {
NodeExρr_INT [ ] nodexs=q.nodeExprs 0 ; ; Symbol_INT [ ] arcs=q. arcVars 0 ; ; BoolExpr_INT [ ] conds=q. conditions ( ) ; ; Automata_INT [ ] automs=q. automata () ; ; QueryBlock_INT [ ] subqs= q. subQueries ( ) ; ;
cmemc= new HashSet ( ) ; cXCc= new HashSet ( ) ; cXYc= new HashSet ( ) ; cother= new HashSet ( ) ; csubqs = new cQueryBlock_INT[subqs. length] for (int i=0; i<conds . length; i++) { conds [i]. separate (cmemc , cXCc, cXYc, cother, false); } for (int j=0; j<automs . length; j++) for (int k=0; k<automs [j] .getLinks 0.length; k++) automs [j] . getLinks () [k] .fix(cXCc, cmemc, cother) ; for (int i=0; i<subqs. length; i++) { csubqs [i] = new cQueryBlock ( (QueryBlock) subqs [i] ) ;
} caut=automs ; cnodeex=nodexs; carcv=arcs;
public void toDisplay (PrintStream out) { out.println ( "clean Query Block: ["); out .println ( "Automatons : " ) ; for (int i=0; i<caut. length; i++) caut [i] .toDisplay (out) ; out .println ( "Conditions : " ) ; out .println ( "Membership conditions : " ) ; iter = cmemc. elements () ; while ( iter .hasMoreElements ( ) ) {
BoolExpr_INT oper= ( (BoolExpr_INT) (iter .nextElement 0 ) ) ; oper. toDisplay (out) ; } out.println ( "X=C conditions: ") ; iter = cXCc . elements ( ) ; while (iter .hasMoreElements ( ) ) {
BoolExpr_INT oper= ( (BoolExpr_INT) (iter .nextElement ( ) ) ) ; oper. toDisplay(out) ; } out .println ( "X=Y conditions : " ) ; iter = cXYc . elements ( ) ; while (iter.hasMoreElements 0 ) {
BoolExpr_INT oper= ( (BoolExpr_INT) (iter. nextElement 0 ) ) ; oper. toDisplay (out) ; } out .println ( "Other conditions : " ) ; iter = cother. elements () ; while (iter .hasMoreElements 0 ) {
BoolExpr_INT oper= ( (BoolExpr_INT) (iter .nextElement ( ) ) ) ; oper. toDisplay (out) ; }
out .println ( "clean Sub Queries : " ) ; for (int i=0; i<csubqs . length; i++) csubqs [i] . toDisplay (out) out .println ("]");
} public Automata_INT [ ] cAutomataO {return caut;} public NodeExpr_INT [ ] cNodeExprs ( ) {return cnodeex;} public Symbol_INT[] cArcVars () {return carcv; } public cQueryBlock_INT [ ] cSubQueries 0 {return csubqs;} public HashSet cMemConditions ( ) {return cmemc;} public HashSet cXCConditions () {return cXCc;} public HashSet cXYConditions () {return cXYc;} public HashSet cOtherConditions () {return cother;} }
@
\section{Link, Node, and Boolean Expressions}
MOAQL supports node, regular path, unary bool, collection, and boolean expressions .
«NodeExprVar . java»= package automata; import java.util.*; import java.io.*; import COM.objectspace. jgl .* ;
/* NodeExpr */ public class NodeExprVar implements NodeExρr_INT { private Symbol_INT var; public NodeExprVar ( Symbol_INT v) { var = v; } public String getName () { return "NodeExprVar"; } public Expr_INT[] getSubExprs ( ) { return new Expr_INT[0]; } public void toDisplay (PrintStream out) {out .print (var .getName ()); } public Symbol_INT getSymbol ( ) {return var;} public HashSet getVars ( ) {
HashSet set= new HashSet ( ) ; set. add (var) ; return set;} }
<<NodeExprConst . java»= package automata; import java.util.*; import java.io.*; import COM.ob ectspace. jgl. *; public class NodeExprConst implements NodeExpr_INT { private DataValue_INT d; public NodeExprConst (DataValue_INT x) { d = x; } public void toDisplay(PrintStream out) {out.print (d. getName 0 ); } public DataValue_INT getValue () {return d; } public String getName () { return "NodeExprConst"; } public Expr_INT[] getSubExprs 0 { return new Expr_INT[0]; } public HashSet getVars () {return new HashSet ();} }
«NodeExprSkol . java»= package automata; import java.util.*; import java.io.*; import COM.objectspace. jgl . *; public class NodeExprSkol implements NodeExpr_INT { private Symbol_INT s; private Expr_INT exprs [ ] ; public NodeExprSkol (Symbol_INT a, Expr_INT [ ] b) { s = a; exprs = b; } public void toDisplay(PrintStream out) { out .print (s . getName ()+"("); for (int i=0; i<exprs . length; i++) exprs [i] .toDisplay (out) ; out.printC) ") ;} public String getName () { return "NodeExprSkol"; } public Expr_INT[] getSubExprs ( ) { return exprs; } public HashSet getVars ( ) {
HashSet set= new HashSet ( ) ; for (int i=0; i<exprs. length; i++) set = set.union (exprs [i] .getVars () ) ; return set;
} }
<<BoolExprConst . java»= package automata; import java.util.*; import java.io.*; import COM. obj ectspace . jgl . * ,-
/★A**********************/
/* BoolExpr */
/A***********************/ public class BoolExprConst implements BoolExpr_INT { private DataValue_INT v; public BoolExprConst (DataValue_INT x) { v = x; } public String getName () { return "BoolExprConst"; } public Exρr_INT[] getSubExprs () { return new Expr_INT[0]; } public HashSet getVars () {return new HashSet (); } public void toDisplay (PrintStream out) { out .println ( "Bool ( "+v. getName ()+")"); } public BoolExpr_INT separate (HashSet cMemc, HashSet cXCc, HashSet cXY c,
HashSet cother, boolean returnExp) { return this; }
}
«BoolExprAnd . j ava»= package automata; import j ava . util . * ; import COM. objectspace . jgl . * ; import j ava . i o . * ; public class BoolExprAnd implements BoolExpr_INT { private BoolExpr_INT bl, b2; public BoolExprAnd (BoolExpr_INT x, BoolExpr_INT y) { bl = x; b2 = y;
} public void toDisplay (PrintStream out)*{ out .print ( "BoolAnd ( " ) ,- bl . toDisplay (out) ; b2. toDisplay (out) ; out.printlnC) " ) ;
}
public String getName ( ) { return "BoolExprAnd"; } public Expr_INT[] getSubExprs ( ) {
Expr_INT[] res = new Expr_INT[2] ; res[0] = bl; res[l] = b2; return res; } public HashSet getVars ( ) { HashSet set= new HashSet ( ) ; set . union (bl . getVars ( ) ) ; set . union (b2. getVars ( ) ) ; return set; } public BoolExpr_INT separate (HashSet cMemc, HashSet cXCc, HashSet cXYc
HashSet cother, boolean returnExp) { BoolExpr_INT si = bl . separate (cMemc , cXCc , cXYc , cother, true) ; BoolExpr_INT s2 = b2 . separate (cMemc , cXCc , cXYc , cother, true) ; BoolExpr_INT n= new BoolExprAnd ( s 1 , s2 ) ; if ( ! returnExp) cother . add (n) ; return n; } «BoolExprOr . java»= package automata; import java.util.*; import COM.objectspace. jgl .* ; import java. io . * ; public class BoolExprOr implements BoolExpr_INT { private BoolExpr_INT bl, b2; public BoolExprOr (BoolExpr_INT x, BoolExpr_INT y) { bl = x; b2 = y; } public String getName ( ) { return "BoolExprOr"; } public Expr_INT[] getSubExprs () { Expr_INT[] res = new Expr_INT[2]; res[0] = bl; res[l] = b2; return res; } public HashSet getVars ( ) { HashSet set= new HashSet ( ) ; set . add (bl . getVars ( ) ) ; set . add (b2. getVars ( ) ) ; return set; } public void toDisplay(PrintStream out) { out .print ( "BoolOr ( " ) ; bl .toDisplay (out) ; b2.toDisplay (out) ; out.printlnC) " ) ;
}
public BoolExpr_INT separate (HashSet cMemc, HashSet cXCc, HashSet cXYc
HashSet cother, boolean returnExp) { BoolExpr_INT si = bl. separate (cMemc, cXCc, cXYc, cother, true); BoolExpr_INT s2 = b2. separate (cMemc , cXCc, cXYc, cother, true); BoolExpr_INT n= new BoolExprOr (si, s2) ; if (! returnExp) cother. add (n) ; return n; }
}
«BoolExprNot . java»= package automata; import java.util.*; import COM.objectspace . jgl .* ; import java.io.*; public class BoolExprNot implements BoolExpr_INT { private BoolExpr_INT b; public BoolExprNot (BoolExpr_INT x) { b = x; } public String getName 0 { return "BoolExprNot"; } public Expr_INT[] getSubExprs 0 {
Expr_INT[] res = new Expr_INT[l] ; res[0] = b; return res; } public HashSet getVars 0 { HashSet set= new HashSet ( ) ; set . add (b. getVars ( ) ) ; return set; } public void toDisplay (PrintStream out) { out .print ( "BoolNot ( " ) ; b. toDisplay(out) ; out .println (")");
}
public BoolExpr_INT separate (HashSet cMemc, HashSet cXCc, HashSet cXYc
HashSet cother, boolean returnExp) { BoolExpr_INT si = b. separate (cMemc, cXCc, cXYc, cother, true); BoolExpr_INT n= new BoolExprNot (si) ; if (! returnExp) cother. add(n) ; return n; }
}
«BoolExprPred. java»= package automata; import java.util.*; import COM.objectspace. jgl. *; import java.io.*; public class BoolExprPred implements BoolExpr_INT { private Symbol_INT pred; private ValueExpr_INT args [ ] ; public BoolExprPred (Symbol_INT p, ValueExpr_INT [ ] a) { pred = p; args = a; } public void toDisplay(PrintStream out) { out .print ( "BoolPred( "+pred. getName () ) ,- for (int i=0; i<args. length; i++) {out.print(" arg: "); argsfi] .toDisplay (out) ; out .print (",");} out.printlnt") ") ; } public String getName () { return "BoolExprPred"; } public Expr_INT[] getSubExprs ( ) { return args; } public HashSet getVars(){
HashSet set= new HashSet ( ) ; for (int i=0; i<args. length; i++) set = set.union (args [i] .getVars () ) ; return set;
} public BoolExpr_INT separate (HashSet cMemc, HashSet cXCc, HashSet cXY c,
HashSet cother, boolean returnExp) { ValueExpr_IN [ ] nargs = new ValueExpr_IN [args .length] ; if (pred. equals (Strudel. opEQ) ) { if ( !returnExp) { if (args [0] instanceof ValueExprVar & args[l] instanceof ValueE xprVar ) cXYc. add (this) ; else if( (args[0] instanceof ValueExprVar & args[l] instanceof Val ueExprConst) |
(args[l] instanceof ValueExprVar & args[0] instanceof Value ExprConst) ) cXCc. add (this) ; else cother . add (this) ; } return ( this) ; } else for (int j=0; j<args . length; j++) { if (args[j] instanceof ValueExprConst) {
ValueExprVar sl=new ValueExprVar (Strudel . symtab. genSym (Type. typeNode) ) ;
ValueExpr_IN [ ] vec = new ValueExpr_INT [2] ; nargs [j]= si; vec [0] =sl; vec[l]=args[j] ; cXCc . add (new BoolExprPred (Strudel . opEQ, vec) ) ; } else nargs [j ] =args [j ] ; }
BoolExpr_INT n = new BoolExprPred (pred, nargs ) ; if ( ! returnExp) if (args . length == 1) cMemc . add (n) ; else cother . dd (n) ; return n; } } «UnaryBoolExprConst . java»= package automata ; import ava . util . * ; import COM.objectspace. jgl . *; import java . io . * ;
/* UnaryBoolExpr */
public class UnaryBoolExprConst implements UnaryBoolExpr_INT { private DataValue_INT v; public UnaryBoolExprCons (DataValue_INT vi) {v = vi;} public BoolExpr_INT cleanNS (ValueExprVar vl) { ValueExpr_INT args [ ] = new ValueExpr_INT [2 ] ; args [0J =vl ; args [1] =new ValueExprConst (v) ; return (new BoolExprPred {Strudel .opEQ, args));
}
public void toDisplay (PrintStream out) { out .print ( "UnaryBoolConst [ " +v. getName () + "]"); } public String getName () { return "UnaryBoolExprConst"; } public Expr_INT[] getSubExprs 0 { return new Expr_INT[0]; } public HashSet getVars () {return new HashSet (); } }
«UnaryBoolExprTrue . java»= package automata; import java.util.*; import COM.objectspace. jgl. *; import java.io.*; public class UnaryBoolExprTrue implements UnaryBoolExpr_INT { public String getName () { return "UnaryBoolExprTrue"; } public Expr_INT[] getSubExprs ( ) { return new Expr_INT[0] ; } public void toDisplay (PrintStream out) { out .print ( "UnaryBool [True] " ) ; } public BoolExpr_INT cleanNS (ValueExprVar vl) { return new BoolExprConst (new DataValueBool (true) ) ; } public HashSet getVars ( ) {return new HashSetO;} }
«UnaryBoolExprPred. java»= package automata; import java.util.*; import COM.objectspace. jgl . *; import java. io . * ; public class UnaryBoolExprPred implements UnaryBoolExpr_INT { private Symbol_INT p; public UnaryBoolExprPred (Symbol_INT pi) {p = pi;} public String getName () { return "UnaryBoolExprPred"; } public Expr_INT[] getSubExprs ( ) { return new Expr_INT [0 ] ; } public void toDisplay (PrintStream out) { out .print ( "UnaryBoolPred[ "+p.getName( )+" ] ") ; } public BoolExpr_INT cleanNS (ValueExprVar v)
{ValueExpr_INT [ ] args = new ValueExpr_INT[l] ; args[0]=v; return new BoolExprPred (p, args);} public HashSet getVars ( ) {return new HashSet (); } }
«UnaryBoolExprVar . java»= package automata; import java.util.*; import COM.objectspace. jgl. * ; import java . io . * ; public class UnaryBoolExprVar implements UnaryBoolExpr_INT { private Symbol_INT p; public UnaryBoolExprVar (Symbol_INT pi) {p = pi;} public void clean (HashSet cXCx, HashSet cMemc, HashSet cother) {retur n;} public String getName () { return "UnaryBoolExprVar"; } public Expr_INT[] getSubExprs 0 { return new Expr_INT[0]; } public void toDisplay(PrintStream out) { out .print ( "UnaryBoolVar [ " +p . getName ()+"]"); } public BoolExpr_INT cleanNS (ValueExprVar vl) { ValueExpr_INT args[]= new ValueExpr_INT[2] ; args [ 0] =vl ; args [1] =new ValueExprVar (p) ; return (new BoolExprPred ( Strudel .opEQ, args));
} public Symbol_INT getSymbol ( ) { return p; } public HashSet getVars ( ) {
HashSet set= new HashSet ( ) ; set . add (p) ; return set; } }
«UnaryBoolExprAnd . java»= package automata; import java.util . * ; import COM.objectspace. jgl. *; import java . io . * ; public class UnaryBoolExprAnd implements UnaryBoolExpr_INT { private UnaryBoolExpr_INT bl, b2; public UnaryBoolExprAnd (UnaryBoolExpr_INT x, UnaryBoolExpr_INT y) { b 1 = x; b2 = y; } public void toDisplay(PrintStream out) { out.print ( "UnaryBoolAnd [ " ) ; bl. toDisplay (out) ; b2. toDisplay(out) ; out .print ("]"); } public String getName () { return "UnaryBoolExprAnd"; } public Expr_IN [ ] getSubExprs ( ) {
Expr_INT [ ] res = new Expr_INT [2 ] ; res[0] = bl; res[l] = b2; return res ; } public BoolExpr_INT cleanNS (ValueExprVar v) { return new BoolExprAnd (bl. cleanNS (v) ,b2.cleanNS (v) ) ;
} public HashSet getVars ( ) { HashSet set= new HashSet ( ) ; set .union (bl . getVars ( ) ) ; set . union (b2. getVars ( ) ) ; return set; } }
«UnaryBoolExprOr . java»= package automata; import java.util.*; import COM. objectspace .jgl.*; import java.io.*; public class UnaryBoolExprOr implements UnaryBoolExpr_INT { private UnaryBoolExpr_INT bl, b2 ; public UnaryBoolExprOr (UnaryBoolExpr_INT x, UnaryBoolExpr_INT y) { bl = x; b2 = y; } public BoolExpr_INT cleanNS (ValueExprVar v) { return new BoolExprOr (bl . cleanNS (v) , b2. cleanNS (v) ) ;
} public String getName () { return "UnaryBoolExprOr"; } public Expr_INT[] getSubExprs ( ) { Expr_INT[] res = new Expr_INT[2]; res[0] = bl; res[l] = b2; return res; } public void toDisplay (PrintStream out) { out .print ( "UnaryBoolOr [ " ) ; bl. toDisplay(out) ; b2. toDisplay(out) ; out.print("] ") ; } public HashSet getVars ( ) { HashSet set= new HashSet ( ) ; set .union (bl . getVars 0 ) ; set .unio (b2.getVars 0 ) ; return set; } }
«UnaryBoolExprNot . java»= package automata; import java.util.*; import COM.objectspace. jgl. *,- import java . io . * ; public class UnaryBoolExprNot implements UnaryBoolExpr_INT { private UnaryBoolExpr_INT b; public UnaryBoolExprNot (UnaryBoolExpr_INT x) { b = x; } public void toDisplay(PrintStream out) { out .print ( "UnaryBoolNot [ " ) ; b. toDisplay(out) ; out.print ("] ") ; } public BoolExpr_INT cleanNS (ValueExprVar v) { return new BoolExprNot (b. cleanNS (v) ) ; } public String getName 0 { return "UnaryBoolExprNot"; } public Expr_INT[] getSubExprs () {
Expr_INT[] res = new Expr_INT[l] ; res [ 0 ] = b; return res ; } public HashSet getVars ( ) { HashSet set= new HashSet ( ) ; set .union (b. getVars 0 ) ; return set; } }
«UnaryBoolExprEps . java»= package automata,- import java.util.*; import COM.objectspace. gl . *; import java.io.*; public class UnaryBoolExprEps implements UnaryBoolExpr_INT { public String getName 0 { return "UnaryBoolExprEps"; } public Expr_INT[] getSubExprs () { return new Expr_INT[0]; } public BoolExpr_INT cleanNS (ValueExprVar vl) { return new BoolExprConst (new DataValueBool (true) ) ; } public void toDisplay(PrintStream out) { out. print ( "Epsilon" ) ,- }
public HashSet getVars () {return new HashSet (); }
«CollExpr. java»= package automata; import java.util. *,- import COM. objectspace .jgl.*; import java. io . * ; **********★*************
/* CollExpr */ ************************ public class CollExpr implements CollExpr_INT { private Symbol_INT col; private NodeExpr_INT arg; public CollExpr (Symbol_INT c, NodeExpr_INT a) { col = c; arg = a; } public void toDisplay(PrintStream out) { out.print (col. getName ( ) ) ; out.print(" ( " ) ; arg. toDisplay (out) ; out.printlnf") ") ; } public String getName () { return "CollExpr"; } public Expr_INT[] getSubExprs () { Expr_IN [ ] res = new Expr_INT [1] ; res[0] = arg; return res ; } public HashSet getVars () {return arg.getVars (); }
}
«ValueExprConst . java»= package automata; import java.util.*; import j ava . io . * ; import COM.ob ectspace. jgl. *;
/★A********************** /
/* ValueExpr */
/★A********************** / public class ValueExprConst implements ValueExpr_INT { private DataValue_INT v; public ValueExprConst (DataValue_INT x) { v = x; } public void toDisplay (PrintStream out) {out.print (v. getName ()); } public DataValue_INT getValueO {return v; } public String getName () { return v.getName(); } public Expr_INT[] getSubExprs ( ) { return new Expr_INT[0]; } public HashSet getVars () {return new HashSet ();} }
«ValueExρrVar . java»= package automata; import java.util.*; import java.io.*; import COM. objectspace . jgl . * ; public class ValueExprVar implements ValueExpr_INT { private Symbol_INT s; public ValueExprVar (Symbol_INT x) { s = x; } public void toDisplay (PrintStream out) {out.print (s. getName ()),- } public Symbol_INT getSymbol () {return s;} public String getName ( ) { return s.getNameO; } public Expr_INT[] getSubExprs ( ) { return new Expr_INT[0]; } public HashSet getVars ( ) {
HashSet set= new HashSet ( ) ; set.add (s) ; return set; }
}
«ValueExprPlus . java»= package automata,- import java.util.*; import java.io.*; import COM.objectspace. jgl. *; public class ValueExprPlus implements ValueExpr_INT { private ValueExpr_INT el, e2; public ValueExprPlus (ValueExpr_INT x, ValueExpr_INT y) { el = x; e2 = y; } public String getName 0 { return "ValueExprPlus"; } public void toDisplay(PrintStream out) {el. toDisplay (out) ; out . rint ( " + " ) ; e2.toDisplay (out) ; } public Expr_INT[] getSubExprs ( ) { Expr_INT[] r = new Expr_INT[2]; r[0] = el; r[l] = e2; return r; } public HashSet getVars ( ) { HashSet set= new HashSet ( ) ; set.union (el .getVars ( ) ) ; set.union (e2.getVars ( ) ) ; return set; } }
«ValueExprMinus . java»= package automata; import java .util . * ; import java . io . * ; import COM.objectspace. jgl .* ; public class ValueExprMinus implements ValueExpr_INT { private ValueExpr_INT el , e2 ; public ValueExprMinus (ValueExpr_INT x, ValueExpr_INT y) { el = x; e2 = y; } public String getName 0 { return "ValueExprMinus"; } public void toDisplay (PrintStream out) {el. toDisplay(out) ; out.print ( " - " ) ; e2. toDisplay (out) ;
} public Expr_INT [] getSubExprs ( ) { Expr_IN [ ] r = new Expr_INT [ 2 ] ; r [0] = el ; r [l] = e2 ; return r;
} public HashSet getVars 0 {
HashSet set= new HashSet ( ) ; set . union (el . getVars ( ) ) ; set . union (e2. getVars ( ) ) ; return set;
} }
«ValueExprTimes . java»= package automata; import java.util.*; import java . io . * ; import COM.objectspace. jgl. *; public class ValueExprTimes implements ValueExpr_INT { private ValueExpr_INT el, e2; public ValueExprTimes (ValueExpr_INT x, ValueExpr_INT y) { el = x; e2
= y; } public String getName () { return "ValueExprTimes"; } public void toDisplay (PrintStream out) {el. toDisplay(out) ; out .print ( " * " ) ; e2. toDisplay(out) ; } public Expr_INT[] getSubExprs {) {
Expr_INT[] r = new Expr_INT[2]; r[0] = el; r[l] = e2; return r; } public HashSet getVars () { HashSet set= new HashSet ( ) ; set .union (el . getVars ( ) ) ; set .union (e2. getVars ( ) ) ; return set; } }
«ValueExprDiv. java»= package automata; import java .util . * ; import java . io . * ; import COM. objectspace . jgl . * ; public class ValueExprDiv implements ValueExpr_INT { private ValueExpr_INT el, e2; public ValueExprDiv(ValueExpr_INT x, ValueExpr_INT y) { el = x; e2 = y; } public String getName () { return "ValueExprDiv"; } public void toDisplay(PrintStream out) {el. toDisplay(out) , out.printt" / "); e2. toDisplay (out) ;
} public Expr_INT [ ] getSubExprs ( ) { Expr_INT [ ] r = new Expr_INT [2 ] ; r [0] = el; r [l] = e2 ; return r; } public HashSet getVars ( ) { HashSet set= new HashSet ( ) ; set .unio (el . getVars ( ) ) ; set .unio {e2. getVars () ) ; return set; } }
«ValueExprFunctionCall . java»= package automata; import java.util.*; import java.io.*; import COM.objectspace. jgl. *; public class ValueExprFunctionCall implements ValueExpr_INT { private Symbol_INT f; private ValueExpr_INT [ ] args ; public ValueExprFunctionCall (Symbol_INT x, ValueExpr_INT [ ] y) { f = x ; args = y; } public String getName () { return "ValueExprFunctionCall"; } public void toDisplay(PrintStream out) {out .print ( f .getName ()) ; out.printp (") ; for (int i=0; i<args . length; i++) args[i] .toDisplay (out) ; out.print (") ") ; } public Expr_INT[] getSubExprs () { return args; } public HashSet getVars ( ) {
HashSet set= new HashSet ( ) ; for (int i=0; i<args .length; i++) set = set.union (args [i] .getVars ()) ; return set;
} }
@
\subsection{Symbols}
A [ [ Symbol ] ] has a name and a type .
«Symbol . j ava»= package automata; import java.util.*; import COM. objectspace . jgl . * ; public class Symbol implements Symbol_INT { private String n; private Type_INT t; private boolean i;
Symbol (String x, Type_INT y) { n = x; t = y; i = false; } Symbol (String x, Type_INT y, boolean b) { n = x; t = y; i = b; public String getName 0 { return n; } public Type_INT getTypeO { return t; } public void setType(Type_INT tNew) { t = tNew; } public boolean getlnternal ( ) { return i; } public void expect (Type_INT type) throws TypeError { if (type == Type . typeAny) return; else if (t == Type. typeAny) { t = type; return; } else if (t == type) return; else throw new TypeError (n, type, t) ; }
@
[ [DataValue] ] s are the atomic values in Struql: strings and numbers (in tegers and floats)
«DataValueInt . java»= package automata; import java.util.*; import COM.objectspace. jgl. *; public class DataValuelnt implements DataValue_INT { private int i; public DataValuelnt (int x) { i = x; } public String getName () { return Integer. toString (i) ; } public Type_INT getTypeO { return Type . typelnt ; } }
«DataValueFloat . java»= package automata; import java.util . * ; import COM.ob ectspace. jgl. *; public class DataValueFloat implements DataValue_INT { private float f; public DataValueFloat (float x) { f = x; } public String getName () { return Float. toString (f) ,- } public Type_INT getTypeO { return Type . typeFloat ; } } «DataValueString. java»= package automata; import java.util . * ; import COM.objectspace.jgl .* ; public class DataValueString implements DataValue_INT { private String s; public DataValueString(String x) { s = x; } public String getName () { return s; } public Type_INT getTypeO { return Type. typeString; } }
«DataValueBool . java»= package automata; import java.util.*; import COM.objectspace. jgl . *; public class DataValueBool implements DataValue_INT { private boolean s; public DataValueBool (boolean x) { s = x; } public String getName 0 { if (s) return "true"; else return "false", } public Type_INT getTypeO { return Type . typeBool; } }
@
\subsection{Types}
Types refer to the types we can associate to the individual Struql tokens. The types are: nodes, links, paths, skolem functions, collection names, predicate names, strings, integers and floats. We use types by associating them to symbols: when a symbol is found a second time in an Struql query, we check that it has the same type. Sometimes we don't know the type of an identifier: then we call it TypeAny. In time, TypeAny evolves to some known type: this evolution is ireversible. We also use types by associating them to datavalues: these can only be strings, integers, or floats.
«TypeNode. java»= package automata; import java.util.*; import COM.objectspace. jgl. * . public class TypeNode implements Type_INT { public String getTypeO { return "TypeNode"; } } «TypeLink . j ava»= package automata; import java .util . * ; import COM.objectspace. jgl . *; public class TypeLink implements Type_INT { public String getTypeO { return "TypeLink"; }
}
«TypePath. java»= package automata; import java .uti1. * ; import COM.objectspace. jgl. *; public class TypePath implements Type_INT { public String getTypeO { return "TypePath"; }
}
«TypeSkol . java»= package automata; import java.util.*; import COM.objectspace. jgl . *; public class TypeSkol implements Type_INT { public String getTypeO { return "TypeSkol"; } }
«TypeColl . java»= package automata ,- import java.util.*; import COM.objectspace. jgl .* ; public class TypeColl implements Type_INT { public String getTypeO { return "TypeColl"; } }
«TypePred. java»= package automata; import java.util.*; import COM.objectspace. jgl. * ; public class TypePred implements Type_INT { public String getTypeO { return "TypePred"; } }
«TypeString. java»= package automata; import java.util.*; import COM.objectspace. jgl. *,- public class TypeString implements Type_INT { public String getTypeO { return "TypeString"; }
«TypeInt . java»= package automata; import java.util.*; import COM.objectspace. gl . *; public class Typelnt implements Type_INT { public String getTypeO { return "Typelnt"; } }
«TypeFloat . java»= package automata; import java.util.*; import COM. objectspace . jgl . * ; public class TypeFloat implements Type_INT { public String getTypeO { return "TypeFloat"; . }
«TypeBool . java»= package automata; import jav . util . * ; import COM.objectspace. jgl. * ; public class TypeBool implements Type_INT { public String getTypeO { return "TypeBool"; } }
«TypeAny. java»= package automata; import java.util.*; import COM.objectspace. gl .* ; public class TypeAny implements Type_INT { public String getType ( ) { return "TypeAny"; } }
«Type . java»= package automata; import java.util.*; import COM.objectspace. jgl .* ,- public class Type { static TypeNode typeNode = new TypeNode ( ) static TypeLink typeLink = new TypeLink () static TypePath typePath = new TypePath 0 static TypeSkol typeSkol = new TypeSkol ( ) static TypeColl typeColl = new TypeColl () static TypePred typePred = new TypePred () static TypeString typeString = new TypeString () static Typelnt typelnt = new Typelnt ( ) ; static TypeFloat typeFloat = new TypeFloat ( ) ; static TypeBool typeBool = new TypeBool ( ) ; static TypeAny typeAny = new TypeAny () ;
An [[Automata]] represents a path definition. «Automata . java»= package automata; import java.util . * ; import COM.objectspace. jgl. *; import java. io . * ; public class Automata implements Automata_INT { private State_INT in, out; private Link_INT[] lnks; public Automata(State_INT i, State_INT o, Link_IN [ ] 1) { in = i; ou t = o; Inks = 1; } public State_INT getlnputState () { return in; } public State_INT getOutputState 0 { return out; } public Link_INT[] getLinks ( ) { return Inks; }
public void toDisplay (PrintStream outl) { outl .println ( "Automaton: " ) ; outl .print ( "Input State : " ) ; in. toDisplay(outl) ; outl.println ( " "); outl .print ( "Output State : " ) ; out . toDisplay(outl) ; outl .println ( " " ) ; outl .println ( "Links : " ) ; for (int i=0; i<Inks. length; i++) { lnks[i] .toDisplay (outl) ; outl.println (" "); } } public Automata (Automata_INT aut, NodeExpr„INT inNode, NodeExpr_INT outNode)
{ int j = 0;
State_INT autin = aut .getlnputState 0 ; State_INT autout = aut . getOutputState ( ) ; Link_INT [ ] autlnks = aut . getLinks ( ) ; in = new State (inNode) ; out = new State (outNode) ;
Inks = new Link_INT [autlnks. length + 2] ; lnkε[j++] = new Link(in, autin, new UnaryBoolExprEps ()) ; for (int i=0; i<autlnks. length; i++) lnks[j++] = autlnks[i]; lnks[j++] = new Link (autout, out, new UnaryBoolExprEps ()) ; } public HashSet getVars ( ) {
HashSet set= new HashSet ( ) ; for (int i=0; i<lnks. length; i++) set = set. union ( Inks [i] .getVars () ) ; return set; } }
«State . java»= package automata; import ava .util . * ; import COM.objectspace. jgl. *; import java. io . * ; public class State implements State_INT { private NodeExpr_INT s; public State () { s = new NodeExprVar (Strudel . symtab. genSym(Type, type Node)); } public State (Symbol_INT x) { s = new NodeExprVar (x) ; } public State (NodeExpr_INT x) { s = x; }
public void toDisplay (PrintStream out) { out .print ( "State ( " ) ; s . toDisplay(out) ; out.print (")") ; } public void fix (HashSet cXCc) { NodeExprVar si;
ValueExpr_INT [ ] al = new ValueExpr_INT [2] ; ValueExprConst a2 ; if (s. getName () == "NodeExprConst")
{si = new NodeExprVar (Strudel .symtab. genSy (Type. typeNode) al [ 0 ] = new ValueExprVar { si . getSymbol ( ) ) ; a2= new ValueExprConst ( ( (NodeExprConst) s) .getValueO ) ,- al[l]=a2; cXCc.add(new BoolExprPred (Strudel .opEQ, al) ) ; s=sl; } } public void changeSymbol (NodeExpr_INT si) { s=sl; } public NodeExpr_INT getSymbol ( ) { return s; } public HashSet getVars ( ) {return s . getVars (); } }
«Link. java»= package automata; import java.util.*; import COM.objectspace. jgl .* ; import java.io. *,- public class Link implements Link_INT { private State_INT in, out ; private UnaryBoolExpr_INT label ; private boolean be; public void toDisplay (PrintStream outl){ outl .print ( "Link: ( " ) ,- in. toDisplay(outl ) ; outl.printC "); label. toDisplay(outl) ; outl.printC "); out. toDisplay (outl) ; outl.printC)"); } public Link(State_INT i, State_INT o, UnaryBoolExpr_INT 1) {in = i; out = o; label = 1; be = false; } public Link(State_INT i, State_INT o, UnaryBoolExpr_INT 1, boolean b )
{in = i; out = o; label = 1; be = b; } public Link(NodeExpr_INT x, NodeExpr_INT y, UnaryBoolExpr_INT b) { in = new State (x); out = new State (y); label = b; be = false; } public void fix( HashSet cXCc, HashSet cMemc, HashSet cother ) { in. fix(cXCc) ; out. fix(cXCc) ; if (label .getName ( ) . equals ( "UnaryBoolExprPred" ) | label . getName ( ) . equals ( "UnaryBoolExprAnd" ) | label . getName ( ) . equals ( "UnaryBoolExprOr" ) | label . getName () .equals ( "UnaryBoolExprNot" ) ) {
ValueExprVar v=new ValueExprVar (Strudel .symtab. genSym (Type. typeLin k));
BoolExpr_INT b=label .cleanNS (v) ; if (label. getName ( ) .equals ( "UnaryBoolExprPred" ) ) cMemc.add(b) ; else cother. add(b) ; label=new UnaryBoolExprVar (v. getSymbol () ) ; } } public void changeLabel (UnaryBoolExpr_INT 11) {label=ll;} public State_INT getlnputState ( ) { return in; } public State_INT getOutputState () { return out; } public UnaryBoolExpr_INT getLabel ( ) { return label; } public boolean backEdgeO { return be; } public HashSet getVars ( ) {
HashSet set= new HashSet ( ) ; set .union ( in. getVars ( ) ) ; set.union (out. getVars ()) ; set .union ( label . getVars ( ) ) ; return set; }
@
\subsection{Symbol Table}
The symbol table is implemented by means of a hash table.
«AlreadyDefined. java»= package automata; import java.util . * ; import COM.objectspace. jgl .* ; import java . io . * ; public class AlreadyDefined extends Exception { }
«NotFound . j ava»= package automata ,- import java . util . * ; import COM.objectspace. jgl . *; import java . io . * ; public class NotFound extends Exception {
String name;
NotFound (String name) { this.name = name; } }
«SymbolTable . java>>= package automata; import java.util.*; import COM.objectspace. gl .* ;
public class SymbolTable extends Hashtable { static int symid = 0; Symbol sym; SymbolTable ( ) { super () ; } ; /* String -> Symbol map */
/* generate a unique symbol */ public Symbol genSym(Type_INT t) { symid += 1; return new Symbol("S" + Integer. toString (symid) , t) ; } public Symbol install (String name) { sym = ( Symbol ) super . get (name) ; if (sym == null) { sym = new Symbol (name, Type. typeAny) ; super .put (name , sym) ; } return sym; } public Symbol install (String name, Type_INT type) throws ParseError try { sym = (Symbol) super. get (name) ; if (sym == null) { sym = new Symbol (name, type); super .put (name, sym) ; return sym; } else { sym. expect (type) ; return sym; } } catch (TypeError e) {
System. out.println(e. error) ; throw new ParseError ( ) ; } } public void insert (Symbol sym) throws AlreadyDefined { String name = sym. getName ( ) ; if (super . containsKey(name) ) throw new AlreadyDefined ( ) ; else super.put (name, sym); } public Symbol lookup (String name) throws NotFound { Symbol sym = (Symbol) super .get (name) ; if (sym == null) throw new NotFound (name) ; else return sym; }
Here there is an error that I don't understant. Dana.
«RpeAtomic . java»= package automata; import java .util . * ; import COM. objectspace . jgl . * ; public class RpeAtomic implements Rpe_INT { private UnaryBoolExpr_INT pi , p2 ;
RpeAtomic (UnaryBoolExpr_INT pi) { this .pl = pi ; this .p2 = new Unary BoolExprTrue ( ) ; }
RpeAtomic (UnaryBoolExpr_INT pi , UnaryBoolExpr_INT p2 ) { this .pl = p 1 ; this .p2 = p2 ; } public Automata_INT toAutomata ( ) { State_INT in = new State ( ) ; State_INT out = new State ( ) ; Link_INT[] edges = new Link_INT[l] ; edges [0] = new Link (in, out, pi);
/***** Here I ignore p2 : node conditiosn are not yet implement return new Automata (in, out, edges); } public UnaryBoolExpr_INT UnaryBoolExpr ( ) { return pi; } }
«RpeConcat . java»= package automata; import java.util.*; import COM.objectspace . gl .* ; public class RpeConcat implements Rpe_INT { private Rpe_INT rl, r2 ; public RpeConcat (Rpe_INT rl, Rpe_INT r2) { this.rl = rl; this.r2 = r2; } public Automata_INT toAutomata ( ) {
{ Automata_INT al = rl . toAutomata 0 , a2 = r2. toAutomata ( ) ; State_INT inl=al . getlnputState ( ) , outl=al . getOutputState ( ) , in2=a2.getlnputState () , out2=a2.getOutputState () ; Link_INT[] 11 = al .getLinks () , 12 = a2.getLinks () ;
Link_INT[] 1 = new Link_INT [11. length+12.length+1] ; int j=0;
for(int i=0; i<ll. length; i++) l[j++] = ll[i]; l[j++] = new Link (outl, in2 , new UnaryBoolExprEps ()) ; for (int i=0; i<12. length; i++) l[j++] = 12 [i]; return new Automata (inl , out2 , 1) ; } }
}
«RpeAlt . java»= package automata; import j ava . ut i 1. * ; import COM. objectspace . jgl . * ; public class RpeAlt implements Rpe_INT { private Rpe_INT rl , r2 ; /* Rpe I Rpe * / RpeAlt (Rpe_INT rl , Rpe_INT r2 ) { this . rl = rl ; this . r2 = r2 ; } public Automata_INT toAutomata ( ) { { Automata_INT al = rl . toAutomata ( ) , a2 = r2. toAutomata ( ) ; State_INT inl=al .getlnputState ( ) , outl=al .getOutputState ( ) , in2=a2. getlnputState ( ) , out2=a2. getOutputState ( ) ; Link_INT[] 11 = al . getLinks () , 12 = a2. getLinks () ;
Link_INT[] 1 = new Link_INT[ll.length+12.length+4] ; State_INT in = new State ( ) , out = new State ( ) ;
int j=0; l[j++] = new Link (in, inl, new UnaryBoolExprEps ()) ; for (int i=0; i<ll. length; i++) l[j++] = ll[i]; l[j++] = new Link (outl, out, new UnaryBoolExprEps ()) ;
l[j++] = new Link(in, in2 , new UnaryBoolExprEps ()) ; for (int i=0; i<12. length; i++) l[j++] = 12[i]; l[j++] = new Link(out2, out, new UnaryBoolExprEps ()) ; return new Automata ( in, out , 1) ; }
}
}
«RpeStar . java»= package automata; import java.util.*; import COM. objectspace. gl . * ; public class RpeStar implements Rpe_INT { private Rpe_INT rl; /* Rpe '*' */ RpeStar (Rpe_INT rl) { this.rl = rl; } public Automata_INT toAutomata () { { Automata_INT al = rl . toAutomata ( ) ;
State_INT inl=al . getlnputState ( ) , outl=al . getOutputState ( ) ; Link_INT [ ] 11 = al . getLinks ( ) ;
Link_INT [ ] 1 = new Link_INT [11. length+1] ; int j=0; for (int i=0; i<ll. length; i++) l[j++] = 11 [i] ; l[j++] = new Link (outl, inl, new UnaryBoolExprEps 0 , true) ; return new Automat ( inl , inl, 1); /* here is the difference from plus */ }
}
«RpePlus . j ava»= package automata; import java .util . * ; import COM.objectspace. jgl . *; public class RpePlus implements Rpe_INT { private Rpe_INT rl; /* Rpe '*' */ RpePlus (Rpe_INT rl) { this.rl = rl; } public Automata__INT toAutomata ( ) {
{ Automata_INT al = rl . toAutomata ( ) ;
State_INT inl=al . getlnputState ( ) , outl=al . getOutputState ( ) ; Link_INT[] 11 = al . getLinks () ;
Link_INT [ ] 1 = new Link_INT [11. length+1 ] ; int j=0; for(int i=0; i<ll. length; i++) ltj++] = llti]; l[j++] = new Lin (outl, inl, new UnaryBoolExprEps () , true); return new Automata ( inl , outl, 1); /* here is the difference from star */ } } }
\section{Untyped Expressions}
These are transient values, which exists only during parsing. The
«UExprDataValue. java>>= package automata; import java.util.*; import COM.objectspace. jgl. *; public class UExprDataValue implements UExpr_INT { private DataValue_INT v; public UExprDataValue (DataValue_INT u) {v = u;} public NodeExpr_INT toNodeExpr ( ) { return new NodeExprConst (v) ; } public BoolExpr_INT toBoolExpr ( ) throws TypeError { if (v. getTypeO != Type . typeBool )
{throw new TypeError (v. getName () , Type . typeBool , v . getType ()) ; } return new BoolExprConst (v) ; } public UnaryBoolExpr_INT toUnaryBoolExpr (boolean topLevel) throws Ty peError { if (v. getTypeO == Type . typeBool && v. getName () == "true") return new UnaryBoolExprTrue ( ); else return new UnaryBoolExprConst (v) ; } public CollExpr_INT toCollExprO throws TypeError { throw new TypeError (v . getName ( ) , Type . typeColl , v. getType () ) ; } public ValueExpr_INT toValueExpr ( ) { return new ValueExprConst (v) ; } public Rpe_INT toRpe (boolean topLevel) { return new RpeAtomic (new UnaryBoolExprConst (v) ) ; } }
«UExprId. java»= package automata; import java.util.*; import COM. objectspace . jgl . * ,- public class UExprld implements UExpr_INT { private Symbol_INT s; public UExprld (Symbol_INT x) { s = x; } public NodeExpr_INT toNodeExpr ( ) throws TypeError { s. expect (Type. typeNode) ; return new NodeExprVar (s) ; } public BoolExpr_INT toBoolExpr ( ) throws TypeError { s. expect (Type. typeBool) ; return new BoolExprPred(s, new ValueExpr_INT [ 0] ) ; } public UnaryBoolExpr_INT toUnaryBoolExpr (boolean topLevel) throws Ty peError { if (topLevel) {s .expect (Type. typeLink) ; return new UnaryBoolExprVar ( s ) ; } else {s. expect (Type. typeBool) ; return new UnaryBoolExprPred (s) ; } } public CollExpr_INT toCollExprO throws SemanticError { throw new SemanticError ( "Expected \"(\" after "+s. getName () ) ; } public ValueExpr_INT toValueExpr 0 { return new ValueExprVar (s) ; } public Rpe_INT toRpe (boolean topLevel) { if (topLevel) return new RpeAtomic (new UnaryBoolExprVar ( s )) ; return new RpeAtomic (new UnaryBoolExprPred (s) ) ;
} }
/it**************************************************************** / «UExprSet . java»= package automata; import java.util.*; import COM.objectspace. jgl. *;
/*
Used only in expressions like "x IN {a, b, c, d} " to store the set {a, b, c, d} .
Never converted directly to a typed expression. */ public class UExprSet implements UExpr_INT { public UExpr_INT args[]; public UExprSet (UExpr_INT a[]) {args = a;} public NodeExpr_INT toNodeExpr ( ) { return null;} public BoolExpr_INT toBoolExpr ( ) { return null;} public UnaryBoolExpr_INT toUnaryBoolExpr (boolean b) { return null;} public CollExpr_INT toCollExprO { return null;} public ValueExpr_INT toValueExpr ( ) { return null;} public Rpe_INT toRpe (boolean topLevel) { return null;}
}
<<UExprFunctionCall . java>>= package automata,- import java.util.*; import COM.objectspace. jgl. *; public class UExprFunctionCall implements UExpr_INT { private Symbol_INT f; private UExpr_INT args [ ] ; public UExprFunctionCall (Symbol_INT x) { f = x; args = new UExpr_INT [0]; } public UExprFunctionCall (Symbol_INT x, UExpr_INT a) { f = x; args = new UExpr_INT [1] ; args[0] = a; } public UExprFunctionCall (Symbol_INT x, UExpr_INT a, UExpr_INT b) { f = x; args = new UExpr_IN [2 ] ; args[0] = a; args[l] = b; } public UExprFunctionCall (Symbol_INT x, UExpr_INT[] a) { f = x; args = a; }
public NodeExpr_INT toNodeExpr ( ) throws TypeError, SemanticError { NodeExpr_INT a [ ] ; f .expect (Type. typeSkol) ; a = new NodeExpr_IN [args. length] ; for (int i=0; i<args . length; i++) a[i] = args [i] .toNodeExpr () ; return new NodeExprSkol ( f , a); } public BoolExpr_INT toBoolExprO throws TypeError, SemanticError { if (args. length == 2) { if (f == Strudel. opOR) return new BoolExprOr (args [0] . toBoolExpr (), args [1] .toBoolExpr 0 ) ; if (f == Strudel.opAND) return new BoolExprAnd(args [0] . toBoolEx prO, args[l] .toBoolExprO ) ; } if (args. length == 1 && f == Strudel. opNOT) return new BoolExprNot (args [0] . toBoolExpr () ) ; if (args. length == 2 && f == Strudel .opIN) { UExpr_INT v = args [ 0] ;
UExprSet s = (UExprSet) args[l];
BoolExpr_INT r = new BoolExprConst (new DataValueBool ( false) )
for (int i=0; i<s .args .length; i++)
{ ValueExpr_INT [ ] a2 = new ValueExpr_INT [2 ] ; a2[0] = v. toValueExpr () ; a2[l] = s. args [i] .toValueExpr () ; r = new BoolExprOr (r, new BoolExprPred ( Strudel . opEQ, a2 )
} return r; }
{ ValueExpr_INT [ ] a = new ValueExpr_INT [ args . length] ; for (int i=0 ; i<args . length; i++) a [i] = args [i] . toValueExpr ( ) ; return new BoolExprPred ( f , a) ; }
} public UnaryBoolExpr_INT toUnaryBoolExpr (boolean topLevel) throws Ty peError, SemanticError { if (args. length == 2) { if (f == Strudel . opOR) return new UnaryBoolExprOr (args [0] .toUn aryBoolExpr( false) , args [1] . toUn aryBoolExpr (false) ) ; if (f == Strudel.opAND) return new UnaryBoolExprAnd (args [0] .to UnaryBoolExpr (false) , args [1] .to UnaryBoolExpr ( false) ) ,- } if (args. length == 1 && f == Strudel .opNOT) return new UnaryBoolExprNot (args [0] .toUnaryBoolExpr (false) ) ; throw new SemanticError ( "Function calls not allows in regular exp ressions" ) ; } public CollExpr_INT toCollExprO throws TypeError, SemanticError { f . expect (Type . typeColl ) ; checkNoArgs (1 , "Only unary collections are allowed"); return new CollExpr ( f, args [ 0] . toNodeExpr () ) ; } public ValueExpr_INT toValueExpr () throws SemanticError, TypeError { if (args. length == 2) { if (f == Strudel. opPLUS) return new ValueExprPlus (args [0] . toVa lueExpr ( ) , args [1 ] . toValueExpr 0 ) ; if (f == Strudel. opMINUS) return new ValueExprMinus (args [0] . to ValueExpr ( ) , args [1 ] . toValueExpr () ) ; if (f == Strudel. opSTAR) return new ValueExprTimes (args [0] . toV alueExpr ( ) , args [1] . toValueExpr () ) ; if (f == Strudel. opSLASH) return new ValueExprDiv (args [0] . toVa lueExpr ( ) , args [ 1] . toValueExpr 0 ) ; }
{ ValueExpr_INT [ ] a = new ValueExpr_IN [args . length] ; for (int i=0; i<args . length; i++) a[i] = args [i]. toValueExpr 0 ; return new ValueExprFunctionCall (f, a);} }
public Rpe_INT toRpe (boolean topLevel) throws TypeError, SeraanticErr or { if (f == Strudel. opDOT) { checkNoArgs ( 2 ,"") ; return new RpeConcat (args [0] . toRpe (topLevel ) , args [1] . toRpe (topLevel ) ) ; } if ( f == Strudel . opBAR) { checkNoArgs ( 2 , " " ) ; return new RpeAlt (args [0] . toRpe ( false) , arg s[l] .toRpe( false) ) ;} if (f == Strudel. opCOLON) { checkNoArgs (2 ,"") ; return new RpeAtomic (args [0] . toUnaryBoolE xpr (false) , args[l] .toUnaryBoolE xpr (false) ) ; } if (f == Strudel. opPLUS) { checkNoArgs ( 1 , ""); return new RpePlus (args [0] . toRpe (false) ) ;
} if (f == Strudel.opSTAR) { checkNoArgs ( 1 , "" ) ; return new RpeStar (args [0] . toRpe ( false) ) ; return new RpeAtomic (this. toUnaryBoolExpr (topLevel) ) ; } private void checkNoArgs (int n, String s) throws SemanticError { if (args. length != n) throw new SemanticError ( s ) ; }
}
/* * Copyright 1997 AT&T Labs — Research * By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package CmdLine; import COM. objectspace. jgl . * ; import java.io.*; import java.util.*; import DataRepository.*; import Querylnterpretor . * ,- import HTMLParser . * ; import Util . * ;
* A StrudelMaterialize is a command-line interface for HTML Generator. *
* ©author Jaewoo Kang
* ©version 1.00, 11 Sep 1997
* ©since STRUDELl.O */ public class StrudelMaterialize {
/* \npage-list-file contains a newline separated list of collections\ nthat should be realized as pages . \nobj -list contains list of object ui ds that should be materialized. */ static String usage = "Usage: strudel-materialize.sh [-env env-file] [-obj obj-list] [-ext base-url] -i ddl-file -p page-list-file"; public static void main (String args[]) throws Exception { String ddl_file=null, page_file=null; Queue in_graphs = new Queue ( ) ; Queue base_url = new Queue ( ) ; Queue queries = new Queue ( ) ; Queue objs = new Queue ( ) ; Queue pagelist = new Queue ( ) ; Hashtable arguments = new Hashtable ( ) ; arguments .put ( " " -i", in_graphs) ; arguments .put ( " " --q", queries) ; arguments .put ( " " --obj ' , objs); arguments .put ( " " --p", pageliεt) ,- arguments .put ( " " -ext ' , base_url) ; try {
Environment .parseArguments (args, arguments) ; } catch (Exception e) "{ StrudelQuery. error_msg (usage, e . toString 0 ) ; return; } if (pagelist. isEmpty() | | in_graphs . isEmpty0 | | in_graphs . size ( ) > || base_url .size() > 1) {
StrudelQuery.error_mεg (usage, " " ) ; return; } page_file = (String) pagelist.pop 0 ; ddl_file = (String) in_graphs .pop ( ) ; int ind = ddl_file . indexOf ('.'); String input_graph=null; if (ind < 0) input_graph=ddl_file; else input_graph=ddl_file. substring (0, ind);
HashSet page_set = new HashSet ( ) ,- try {
BufferedReader br = new BufferedReader (new FileReader (page_file) )
String line=null; while { (line=br.readLine ( ) ) != null) { page_set . add (1ine . trim( ) ) ;
} } catch (FileNotFoundException e) {
System.err.printIn ( "Page-list-file not found: "+page_file) ; return; } catch (IOException e) {
System. err.println (e. toString ( ) ) ; return; }
StoredDataGraph g; try { g = (StoredDataGraph) FileUtility. loadGraph (input_graph) ; } catch (Exception e) { return; }
//Materialize Graph
System.out.println ( "\n## Materializing Graph ##"); HashSet all_graphs = g.getAllImportedGraphs ( ) ; // System. err.println(all_graphs) ; // Create set of all objects that are pages HashSet pageobjects = new HashSet () ; Enumeration graphs = all_graphs. elements () ; while (graphs . hasMoreElements () ) {
DataGraph gr = (DataGraph) graphs.nextElement () ; HashSet all_collection = gr.getCollections () ; Enumeration en = all_collection. elements 0 ; while (en.hasMoreElements () ) {
DataCollection collection = (DataCollection) en.nextElement () ; if (page_set. get (collection. getName() ) != null) {
Enumeration iter=collection.getObjects ( ) . elements () ; while (iter . hasMoreElements 0 ) { DataObject obj=( (DataObject) (iter .nextElement ( ) ) ) ; if (obj . isInternal ( ) ) pageobjects .put (ob ) ; } } } "}
String baseurl = null; if ( !base_url . isEmpty ( ) ) baseurl = (String) base_url .pop ( ) ; HTMLGenerator gen = new HTMLGenerator (g, pageobjects, baseurl); boolean success = gen . generateHTML (obj s) ; if ( ! success) { throw new RuntimeException ( "Error generating graph "+g) ; }
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package CmdLine; import COM.objectspace. jgl .* ,- import java . io . * ; import java.util.*; import DataRepository. *; import Querylnterpretor. * ; import Util . * ; **
* A StrudelQuery is a command-line interface for query processor. *
* ©author Jaewoo Kang
* ©version 1.00, 11 Sep 1997
* ©since STRUDEL1.0 */ public class StrudelQuery { private static String usage = "Usage : s t rude 1- query. sh [-debug] [-env env-file] [ -o output-file] -i input-ddl ( s) -q queries " ; public static void error_msg ( String usage , String msg) { System, err . println (msg) ; System. err . println (usage) ; return; } public static void main (String args[]) throws Exception {
String out_file=null;
Queue in_graphs = new Queue ( ) ;
Queue queries = new Queue ( ) ;
DataGraph data_graph = null;
Hashtable arguments = new Hashtable ( ) ; arguments .put ( " -o " , new Queue ( ) ) ; arguments .put ( " -i " , in_graphs) ; arguments .put ( " -q" , queries) ; try {
Environment .parseArguments (args , arguments) ; } catch (Exception e) {
System. err.println (e. toString ( ) ) ; error_msg(usage, " " ) ; return; } if ( in_graphs . isEmpty ( ) | | queries . isEmpty ( ) ) error_msg (usage, " " ) ; String output_graph=null;
Queue outfiles = (Queue) arguments. get ( "-o" ) ; if (! outfiles. isEmpty() ) { out_file = (String) outfiles.pop( ) ; int ind = out_file. indexOf ('.'); if (ind < 0) output_graph=out_file; else output_graph=out_file. substring (0, ind); }
// Load each graph while ( ! in_graphs . isEmpty () ) {
String input_graph = (String) in_graphs .pop () ;
System. out.println ( "\n## Loading "+input_graph) ; try {
DataGraph g = FileUtility. loadGraph (input_graph) ;
} catch (Exception e) { return;
} }
// Parse, optimize & evaluate each query while (! queries. isEmpty() ) {
String query = (String) queries .pop () ;
String query_file = Environment .getEnv ("QUERY_DIRECTORY" ) +File. se parator+query;
File queryFile = new File (query_file) ; if (!queryFile. exists () ) {
System, err.println ( "Query file not found: "+query_file) ,- return; } try {
String dgraph = QueryParser. Strudel. run (queryFile) ; if (dgraph == null ) {
System. err . println ( "Query Evaluation Failed . " ) ; return;
} data_graph = DataRepository. getGraph (dgraph) ; } catch (Exception e) {
System.err.println(query_file+" : " ) ;
System. err.println (e. toStringO ) ;
System. err .println( "Evaluation Failed. " ) ; return; }
}
//Save output DataGraph
System. out .println ( " \n## Save Graph ## " ) ; if (output_graph == null) output_graph = data_graph. getName () ; String dir = Environment .getEnv ( "INPUT_DIR" ) +File.separator+output_ graph;
File data = new File (dir+File.separator+"data"+File. separator) ; File myFile = new File(data, output_graph+Environment.getEnv ( "STORE DGRAPH_FILTER") ) ;
System. out .printl ( "Writing Data Graph: "+myFile. toString( ) ) ; try {
PrintStream ps = new PrintStream(new FileOutputStream (myFile) ) ; data_graph.printDDL (ps , output_graph) ; ps. close () ; } catch (IOException e) {
System. err.println ( "Unable to write DataGraph: "+e. toStringO ) ; } } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package CmdLine; import COM.objectspace. jgl. *; import java . io . * ; import java.util. *; import DataRepository. * ; import Querylnterpretor . * ; import Util . * ; /**
* A StrudelView is a command-line interface for viewing a data/site gr aph. *
* ©author Jaewoo Kang
* ©version 1.00, 11 Sep 1997
* ©since STRUDEL1.0 */ public class StrudelView { private static String usage = "Usage: strudel-view.sh [-env env-file] -i input-ddl"; public static void error_msg(String usage, String msg) { System. err.println (msg) ; System. err.println (usage) ; } public static void main (String args[]) throws Exception { String scriptfile; Queue in_graphs = new Queue ( ) ; Hashtable arguments = new Hashtable ( ) ; arguments .put ( " -s " , new Queue 0 ) ; arguments .put ( " -i " , in_graphs) ; try {
Environment .parseArguments (args , arguments) ; } catch (Exception e) {
System. err.println (e. toString ( ) ) ; error_msg (usage, " " ) ; return; } if (in_graphs . isEmpty( ) ) { error_msg (usage, " " ) ; return; }
Queue scriptfiles = (Queue) arguments. get ( "-s" ) ; if ( 1 scriptfiles. isEmpty( ) ) scriptfile = (String) scriptfiles .pop () ; else { error_msg (usage, " " ) ; return; }
// Load each graph while { ! in_graphs . isEmpty () ) {
String input_graph = (String) in_graphs .pop () ; System. out.println ( "\n## Loading "+input_graph) ; try {
DataGraph g = FileUtility. loadGraph (input_graph) ; String dir = Environment. getEnv ( "INPUT_DIR" ) +File. separator+inp ut_graph;
File tmp = new File (dir+File. separator+"tmp"+File. separator) ; tmp .mkdirs ( ) ;
String graphfile = tmp. toStringO +File.separator+ "graph. dot" ;
PrintStream ps = new PrintStream(new FileOutputStream(graphfile
)) g. graphPrint (ps) ; ps . close ( ) ;
String dot = Environment. getEnv ( "DOT" ) ;
PrintStream view = new PrintStream(new FileOutputStream(scriptf ile))
String psfile = tmp. toString () +File.separator+ "graph.ps" ; view.println( "#! /bin/sh "); view.println (dot+" -Tps "+graphfile+" > "+psfile) ; view.println ( "ghostview "+psfile) ; view. close ( ) ; } catch (Exception e) {
System.err.println (e. toStringO ) ; return; } } } }
/* Generated By:JavaCC: Do not edit this line. ASCII_CharStream. Java Ve rsion 0.7pre5 */ package DDL;
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code.
*/ **
* An implementation of interface CharStream, where the stream is assum ed to
* contain only ASCII characters (without Unicode processing) . */ public final class ASCII_CharStream { public static final boolean staticFlag = false; int bufsize; int available; int tokenBegin; public int bufpos = -1; private int bufline []; private int bufcolumn [ ] ; private int column = 0; private int line = 1; private boolean prevCharlsCR = false; private boolean prevCharlsLF = false; private java.io.InputStream inputStream; private byte[] buffer; private int maxNextCharlnd = 0; private int inBuf = 0; private final void ExpandBuff (boolean wrapAround) { byte[] newbuffer = new byte[bufsize + 2048]; int newbufline[] = new int[bufsize + 2048]; int newbufcolumn[] = new intfbufsize + 2048],- try { if (wrapAround) {
System. arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin) ;
System. arraycopy(buffer, 0, newbuffer, bufsize - tokenBegin, bufp OS) ; buffer = newbuffer;
System, arraycopy(bufline, tokenBegin, newbuflme, 0, bufsize
- tokenBegin) ;
System. arraycopy (bufline, 0, newbufline, bufsize - tokenBegi n, bufpos) ; bufline = newbuflme;
System. arraycopy (bufcolumn, tokenBegin, newbufcolumn, 0, buf size - tokenBegin) ,-
System. arraycopy(bufcolumn, 0, newbufcolumn, bufsize - token Begin, bufpos) ; bufcolumn = newbufcolumn; maxNextCharlnd = (bufpos += (bufsize - tokenBegin) ) ; } else {
System. arraycopy (buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin) ; buffer = newbuffer;
System. arraycopy(bufline, tokenBegin, newbuflme, 0, bufsize
- tokenBegin) ; bufline = newbuflme;
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, buf size - tokenBegin) ; bufcolumn = newbufcolumn; maxNextCharlnd = (bufpos -= tokenBegin) ;
} } catch (Throwable t) { throw new Error ( t . getMessage () ) ; }
bufsize += 2048; available = bufsize; tokenBegin = 0; } private final void FillBuffO throws java.io.IOException { if (maxNextCharlnd == available)
{ if (available == bufsize)
{ if (tokenBegin > 2048) { bufpos = maxNextCharlnd = 0 ; available = tokenBegin; } else if (tokenBegin < 0) bufpos = maxNextCharlnd = 0; else
ExpandBuff (false) ; } else if (available > tokenBegin) available = bufsize; else if ((tokenBegin - available) < 2048)
ExpandBuff { true) ,- else available = tokenBegin; } int i ; try { if ((i = inputStream. read(buffer, maxNextCharlnd, available - maxNextCharlnd)) == -1) { inputStream. close ( ) ; throw new java. io . IOException ( ) ,- } else maxNextCharlnd += i; return; } catch(java.io. IOException e) {
—bufpos; backup ( 0 ) ; if (tokenBegin == -1) tokenBegin = bufpos; throw e; }
public final char BeginTokenO throws Java. io. IOException { tokenBegin = -1; char c = readChar ( ) ,- tokenBegin = bufpos; return c; } private final void UpdateLineColumn(char c) { column++ ,- if (prevCharlsLF) { prevCharlsLF = false; line += (column = 1) ; } else if (prevCharlsCR) { prevCharlsCR = false; if (c == '\n')
{ prevCharlsLF = true;
} else line += (column = 1) ; } switch (c) { case '\r' : prevCharlsCR = true; break; case '\n' : prevCharlsLF = true; break; case '\t' : column += (9 - (column & 07)); break; default : break; } bufline [bufpos] = line; bufcolumn [bufpos] = column;
} public final char readCharO throws java.io. IOException { if (inBuf > 0) {
—inBuf; return (char) ( (char) Oxff & buffer[ (bufpos == bufsize - 1) ? (bu fpos = 0) : ++bufpos] ) ; } if (++bufpos >= maxNextCharlnd) FillBuffO ; char c = (char) ( (char) Oxff & buffer [bufpos] ) ;
UpdateLineColumn(c) ,- return (c) ; }
/**
* ©deprecated
* ©see #getEndColumn */ public final int getColumnO { return bufcolumn [bufpos] ,- } **
* ©deprecated
* ©see ttgetEndLine */ public final int getLine ( ) { return bufline [bufpos] ; } public final int getEndColumn ( ) { return bufcolumn [bufpos] ; } public final int getEndLine ( ) { return bufline [bufpos] ; } public final int getBeginColumn( ) { return bufcolumn [tokenBegin] ; } public final int getBeginLine ( ) { return bufline [tokenBegin] ; } public final void backup (int amount) { inBuf += amount; if ((bufpos -= amount) < 0) bufpos += bufsize; } public ASCII_CharStream(java.io. InputStream dstream, int startline, int startcolumn, int buffersize)
{ inputStream = dstream; line = startline; column = startcolumn - 1; available = bufsize = buffersize; buffer = new byte [buffersize] ; bufline = new int [buffersize] ; bufcolumn = new int [buffersize] ; } public ASCII_CharStream( java.io. InputStream dstream, int startline, int started umn) { this (dstream, startline, startcolumn, 4096); } public void Relnit (java.io. InputStream dstream, int startline, int startcolumn, int buffersize) { inputStream = dstream; line = startline; column = startcolumn - 1; if (buffer == null || buffersize != buffer .length) { available = bufsize = buffersize; buffer = new byte [buffersize] ; bufline = new int [buffersize] ; bufcolumn = new int [buffersize] ; } prevCharlsLF = prevCharlsCR = false; tokenBegin = inBuf = maxNextCharlnd = 0; bufpos = -1; } public void Relnit (java.io. InputStream dstream, int startline, int startcol umn) {
Relnit (dstream, startline, startcolumn, 4096); } public final String Getlmage ( ) { if (bufpos >= tokenBegin) return new String (buffer, 0, tokenBegin, bufpos - tokenBegin +
1); else return new String (buffer, 0, tokenBegin, bufsize - tokenBegin) new String (buffer, 0, 0, bufpos + 1) ;
public final byte[] GetSuffix(int len) { byte[] ret = new byte [len]; if {(bufpos + 1) >= len)
System.arraycopy(buffer, bufpos - len + 1, ret, 0, len); else {
System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0, len - bufpos - 1);
System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1) ; } return ret; } public void Done ( ) { buffer = null; bufline = null; bufcolumn = null; }
} /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTAtomicRef . Java */ package DDL; import DataRepository public class ASTAtomicRef extends SimpleNode implements EvalAST { DataValue type = null, val = null; ASTAtomicRef (int id) { super (id) ; }
ASTAtomicRef (DDLParser p, int id) { super (p, id) ; } public static Node j jtCreate(int id) { return new ASTAtomicRef (id) ; } public static Node j tCreate (DDLParser p, int id) { return new ASTAtomicRef (p, id); } public DataObject eval ( StoredDataGraph g, DataValue commontype) throw s Exception { if (type == null) type = commontype; val = DataValue. convertValue (type, val); LeafDataObject obj = new LeafDataObject (val) ; return (DataObject) obj; } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTAtomieValue. ava */ package DDL; public class ASTAtomieValue extends SimpleNode { ASTAtomieValue ( int id) { super (id) ,- }
ASTAtomieValu (DDLParser p, int id) { super (p, id) ; } public static Node jjtCreate (int id) { return new ASTAtomieValue (id) ; } public static Node jjtCreate(DDLParser p, int id) { return new ASTAtomieValue (p, id); }
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code . */
/* Generated By:JJTree: Do not edit this line. ASTAttributeDef .java */ package DDL; import COM.objectspace. jgl. *; import DataRepository. * ,- public class ASTAttributeDef extends SimpleNode { public String name; public DataValue type; ASTAttributeDef (int id) { super (id) ; }
ASTAttributeDef (DDLParser p, int id) { super (p, id) ; } public static Node jjtCreate(int id) { return new ASTAttributeDef (id) ; } public static Node jjtCreate(DDLParser p, int id) { return new ASTAttributeDef (p, id); }
Copyright 1997 AT&T Labs — Research
By receiving and using the code that follows, the user acknowledges and agrees to keep the code confidential and use the code solely for * non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTAttributeName. Java */ package DDL; public class ASTAttributeName extends SimpleNode { ASTAttributeName ( int id) { super (id) ; }
ASTAttributeName (DDLParser p, int id) { super (p, id); } public static Node j jtCreate (int id) { return new ASTAttributeName (id) ,- } public static Node j jtCreate (DDLParser p, int id) { return new ASTAttributeName (p, id);
} } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTCollectionDef .java */ package DDL; import COM.objectspace. jgl. *; import java. io . * ; import java.util.*; import DataRepository.*,- public class ASTCollectionDef extends SimpleNode { public String name; public Hashtable commontypes; // maps an attribute name to its common type ASTCollectionDef (int id) { super (id) ; }
ASTCollectionDef (DDLParser p, int id) { super (p, id) ; } public static Node jj tCreate (int id) { return new ASTCollectionDef (id) ,-
} public static Node j jtCreate (DDLParser p, int id) { return new ASTCollectionDef (p, id); } public StoredDataCollection eval (DataGraph g) throws Exception {
StoredDataCollection c = (StoredDataCollection) g.getAddCollection(n ame) ; c . updateCommonTypes (commontypes) ; return c; } public static void printDDL (DataGraph g, DataCollection c, PrintStrea m out) { out.println ( "collection " +c . getName ()+ " {"); Enumeration types = c . commontypes . eys 0 ; while (types .hasMoreElements ( ) ) {
String attr = (String) types .nextElement () ; out.printlnt " "+attr+" is "+( (DataValue) c. commontypes .get (att r) ) .getTypeO ) ; } out .println ("}");
Enumeration objs = c.getObjects () .elements () ; while (objs.hasMoreElements () ) {
InternalDataObject iobj = ( InternalDataObject) obj s .nextElement ( ) ; DataGraph og = iobj .getGraph( ) ; if (og != g) { out.printlnt "object "+og. getName () +" . "+iobj .getOid( ) +" in "+c.g etName ( ) + " { } " ) ; } }
} } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTDDL.java */ package DDL; import COM. objectspace . jgl . * ; import java .util . * ; import java. io . * ,- import DataRepository.*; import Util . * ; public class ASTDDL extends SimpleNode { public String graphid; public Hashtable collections = new Hashtable ( ) ,- public SList objects = new SList 0 ; public SList imports = new SList ( ) ;
ASTDDL (int id) { super (id) ; }
ASTDDL (DDLParser p, int id) { super (p, id) ; } public static Node j jtCreate (int id) { return new ASTDDL (id) ; } public static Node j jtCreate (DDLParser p, int id) { return new ASTDDL (p, id);
} public StoredDataGraph eval 0 throws Exception { StoredDataGraph g = new StoredDataGraph (graphid) ; ASTCollectionDef c; ASTObjectDef o; StoredDataCollection sc;
// Import all other graphs first Enumeration graphs = imports . elements ( ) ; while (graphs .hasMoreElements ( ) ) {
String graph = (String) graphs .nextElement () ; try {
DataGraph ig = FileUtility. loadGraph (graph) ; g .addlmportedGraph (ig) ; if (ig instanceof StoredDataGraph)
( (StoredDataGraph) ig) .imported = true; } catch (Exception e) {
System, err.println ("Error loading "+graph+": "+e. toStringO ) ,- throw e; } }
// Merge imported collections here g. importCollections ( ) ;
Enumeration colls = collections. elements () ; while (colls. hasMoreElements () ) { c = (ASTCollectionDef) colls.nextElement () ,- sc = c.eval (g) ; }
Enumeration objs = objects. elements () ; BoolDataValue dummy = new BoolDataValue ( "true" ) ; while (objs.hasMoreElements () ) { o = (ASTObjectDef) objs.nextElement () ; ( (EvalAST) o) . eval (g, dummy) ; } return g; } public static void printDDL (DataGraph g, PrintStream out, String name ) { out .println ( "graph "+name) ;
Enumeration colls = g.getCollections () .elements () ; Enumeration obj s = g. getlnternalObjects 0. elements ( ) ; if (g instanceof StoredDataGraph) {
Enumeration imports = ( (StoredDataGraph) g) .getlmportedGraphs 0.el ements ( ) ; if (imports .hasMoreElements ( ) ) out .print { "import " ) ; while (imports.hasMoreElements () ) {
DataGraph ig = (DataGraph) imports .nextElement 0 ; out.print (ig. getName () +" "); } out.printlnt ) ; } while (colls.hasMoreElements () )
ASTCollectionDef .printDDL (g, (DataCollection) colls.nextElement ( ) , out) ; while (objs .hasMoreElements ( ) )
ASTObjectDef .printDDL ( (InternalDataObject) objs.nextElement ( ) , out );
} } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided * on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code.
*/ /* Generated By:JJTree : Do not edit this line. ASTObjectDef .java */ package DDL; import COM.objectspace. jgl . *; import java.io.*; import java.util.*,- import DataRepository. * ; import Util.*; public class ASTObjectDef extends SimpleNode implements EvalAST { public String oid, graph; public SList collections; public SList attributes; private static Date date = new Date ( ) ; ASTObjectDef (int id) { super (id) ; }
ASTObjectDef (DDLParser p, int id) { super (p, id) ; } public static Node j jtCreate (int id) { return new ASTObjectDef (id) ; } public static Node j jtCreate (DDLParser p, int id) { return new ASTObjectDef (p, id); } private static int oidct = 0 ; public DataObject eval (StoredDataGraph g, DataValue type) throws Exce ption {
InternalDataObject ob ;
Enumeration colls = collections. elements 0 ; Enumeration attrs = attributes. elements () ; StoredDataCollection c; if (graph == null ) { if (oid == null) oid = g .newOid O ; / / UniqueOID O ; // Find if object already exists obj = g. getObject (oid) ; if (obj == null) { obj = new InternalDataObject (g, oid) ,- g.addlnternalObject (obj ) ; } } else {
StoredDataGraph imgraph = (StoredDataGraph) DataRepository. getGra ph(graph) ; obj = imgraph. getOb ect (oid) ; if (obj == null) throw new NotFound ( "Object "+oid+" not found in graph "+graph) ,- }
// Add object to relevant collections while (colls .hasMoreElements () ) { c = (StoredDataCollection) g.getAddCollection( (String) colls. nextEl ement { ) ) ; obj .addCollection(c) ; } if (graph != null && attrs .hasMoreElements () ) throw new ParseError ( "Cannot extend definition of object "+oid+" imported from graph "+graph) ;
// Evaluate object's attributes and add them to object while (attrs.hasMoreElements () ) {
Enumeration objcoll = obj .getCollections 0.elements () ;
Pair p = (Pair) attrs .nextElement () ;
// Lookup attribute ' s common type
String aname = (String) p. first ;
DataValue v = null; while (objcoll.hasMoreElements () ) { v = ( (DataCollection) objcoll .nextElement () ) .commontype (aname) ; if (v != null) { break,-}
}
DataAttribute attr = g.getAddAttribute (aname) ;
EvalAST val = (EvalAST) p. second;
DataObject objtarget = val.eval(g, v) ,-
DataEdge e = new DataEdge(attr, obj, objtarget); } return (DataObject) obj ; } public static void printDDL (InternalDataObject o, PrintStream out) { DataGraph og = o . getGraph ( ) ; HashSet collections = o.getCollections () ; out.print ( "object "+o.getOid( ) ) ; if ( ! collections. isEmpty( ) ) { out .print ( " in " ) ;
Enumeration colls = collections. elements () ; while (colls .hasMoreElements ( ) ) out.print ( ( (DataCollection) colls.nextElement 0 ) . getName ()+" ") ,- } out.printlnt "{") ;
Enumeration edges = o . outEdges ( ) . elements ( ) ; while (edges .hasMoreElements ( ) ) {
DataEdge e= ( (DataEdge) (edges .nextElement 0 ) ) ;
DataObject otarget = e.getToO; DataAttribute att = e .getAttribute ( ) ; out .print ( " " +att . getName () ) ; if (otarget instanceof LeafDataOb ect) {
DataValue v = ( (LeafDataObject) otarget ) .getValueO ; if (v instanceof StringDataValue) out .println ( " \ " " +v. toString ( ) + " \ "" ) ; else if (v instanceof DateDataValue | | v instanceof GifDataValue | | v instanceof HtmlDataValue | | v instanceof PsDataValue | | v instanceof TextDataValue | | v instanceof UrlDataValue) out.println(" is "+v.getType 0 +" \" "+v. toStringO +"\ "") ; else out.printlnt" is " +v. getType () +" "+v. toStringO ) ; } else if (otarget instanceof InternalDataObject) {
DataGraph ot = ( (InternalDataObject) otarget) .getGraphO ; if (og != ot) out.println (" @"+ot .getName ()+"."+( (InternalDataO bject) otarget) .getOid() ) ; else out . println ( " ©" + ( ( InternalDataObject) otarget ) . getOid ( ) ) ,- } } out.printlnC}") ; } }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTObjectRef . java */ package DDL; import DataRepository. * ; public class ASTObjectRef extends SimpleNode implements EvalAST { String oid = null; String graph = null; ASTObjectRef (int id) { super (id) ;
ASTObjectRef (DDLParser p, int id) { super (p, id) ; } public static Node jj tCreate (int id) { return new ASTObjectRef (id) ;
} public static Node jjtCreate (DDLParser p, int id) { return new ASTObjectRef (p, id);
} public DataObject eval (StoredDataGraph g, DataValue type) throws Exce ption { if (graph != null) g = (StoredDataGraph) DataRepository. getGraph (graph) ; InternalDataObject obj = g.getObject (oid) ; if (obj == null) { obj = new InternalDataObject (g, oid); g.addlnternalObject (obj ) ; } return obj ,- } }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTTypeDef . java */ package DDL; public class ASTTypeDef extends SimpleNode { ASTTypeDef (int id) ' { super (id) ; }
ASTTypeDef (DDLParser p , iήt id) { super (p, id) ;
} public static Node jtCreate (int id) { return new ASTTypeDef (id) ; }" public static Node j jtCreate (DDLParser p, int id) { return new ASTTypeDef (p, id);
} } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package DDL; import DataRepository.*; interface EvalAST { public DataObject eval (StoredDataGraph g, DataValue v) throws Excep tion ,- } © Notes .
Questions : undeclared attributes may occur in objects? yes. Is there a root collection of all objects? yes.
Type system: Add type constraints for arbitrary, user-defined collections Add collection hierarchy -- check inherited attributes Resolving multiple-inheritance conflicts ; permit range of object types from restricted to unrestricted, permit union types
Object ids: should be unique within a graph unbound OID is legal ; object with no attributes (warning would be use ful)
Collections: are names unique across universe of graphs or within graphs? one definition of collection C per graph ** define membership of objects in collection separately delay (some) semantic checks of constraints are 2 definitions of oid an error or an extension of existing object? (currently extend existing object)
Semantics of new nodes -> old nodes. influences meaning and use of indices
Look at LOREL DDL.
«ddl-manual . tex»=
A data-definition (DDL) file is a sequence of collection and object def initions .
A collection is a named set of objects; its definition includes the collection's ''type'': its name and a list of attribute names and optional type constraints .
For example, the [ [Title] ] attribute of an object in the [ [Articles] ] collection must be a string. A collection's type does {\em not} enforc e that objects in the collection have all specified attributes; it only specifies that if such an attribute exists, it must have the given type. Conversely, the object may contain other attributes not constrained by the collection's type.
A type is either an atomic type (e.g., [[string]], [[int]], [[url]]), a complex type (e.g., [[Articles]]), or the union type.
A union type specifies the value must have one of the given types (e.g., [[Articles]] or [[string]]). «collection example»= collection Articles {
Title is String # ' ' Title'' must be a string
Date is Date
HTML is html
Text is text
Image # No type constraint on Image
RelatedArticle is object
RelatedSite is url } ©
An object definition includes an optional object identifier, an optional collection-inclusion clause, and a list of attribute, value pairs.
Each attribute
Optional type definition [ [is typevalue] ] . «object example»= object #a2013388527 in Articles {
Title "Combination diet reduces blood pressure"
Abstract "BOSTON (Reuter) — Low-fat dairy products added to a diet rich in fruits and vegetables can reduce high blood pressure significa ntly, and dramatically cut the risk of heart disease and stroke, a stud y in Thursday\ 's New England Journal of Medicine concluded."
Date "Wed Apr 16 03:00:00 EDT 1997" HTML /n/d35/kang/STRUDEL/mylibrary/cnnwrapperl/data_cnn/h2013388527 .html
Text /n/d35 kang/STRUDEL/mylibrary/cnnwrapperl/data_cnn/t2013388527 .txt
Category "Health"
Priority "topstory" }
Nested objects have same syntax as x v top-level ' ' objects.
«object example»=
©
Grammar .
«DDL. j jt»= options {
ERROR_REPORTING = true;
STATIC = false;
USER_CHAR_STREAM = false;
OTHER_AMBIGUITY_CHECK = 1;
BUILD_TOKEN_MANAGER = true;
DEBUG_TOKEN_MANAGER = false;
DEBUG_LOOKAHEAD = false;
USER_TOKEN_MANAGER = false;
LOOKAHEAD = 1;
IGNORE_CASE = false;
FORCE_LA_CHECK = false;
SANITY_CHECK = true;
JAVA_UNICODE_ESCAPE = false;
CHOICE_AMBIGUITY_CHECK = 2;
BUILD_PARSER = true;
DEBUG_PARSER = false;
UNICODE_INPUT = false;
MULTI=true;
NODE_FACTORY=true; }
PARSER_BEGIN{DDLParser) package DDL;
/*
* Copyright 1997 AT&T Labs -- Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in¬ cluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ import COM. objectspace . jgl . * ; import java.util.*; import java. io. * ; import DataRepository. *; import HTMLParser. * ; import Util . * ; public class DDLParser { public static DataGraph parse (String DDLFile) throws Exception { FilelnputStream file=new FilelnputStream(DDLFile) ,- DDLParser parser = new DDLParser (file) ; ASTDDL root = new ASTDDL (JJTDDL) ; try {
System, out .println ( "DDL Parser started" ) ,- root = parser . Start ( ) ,-
System. out .println ( "DDL Parser ended" ) ; } catch (Exception e) {
System. err.println ( "DDL Parser error: "+e. toStringt ) ) ; throw e; } return root . eval ( ) ; } public static void main (String [] args) throws Exception { ASTDDL root; Node kid;
SList collections, objects; int i ; try {
Environment . loadEnv ( ) ,- DataGraph g = parse (args [0] ) ; ASTDDL .printDDL (g, System. out , g . getName 0 ) ; } catch (Exception e) {
System.err.println ( "DDL Parser error: "+e. toStringO ) ; throw e; } } } PARSER_END (DDLParser) « Lexical Rules » « Grammar Rules »
« Grammar Rules »= ASTDDL Start () #void : {}
DDL() { return (ASTDDL) jjtree .popNode () ,- } void DDL ( ) :
Token g, ig;
SList imports = new SList ( ) ;
(<GRAPH> g = <ID>
[ <IMP0RT> (ig = <ID> { imports. add (ig. image) ; })*] ( CollectionDef () I ObjectDefO )*)
{ int i; Node kid; String cname; j tThis. graphid = g. image; j jtThis . imports = imports ; for (i = 0; i < jjtThis. jtGetNumChildren{) ; i++) { kid = jjtThis. jjtGetChiId (i) ,- if (kid instanceof ASTCollectionDef) { cname = ( (ASTCollectionDef) kid) .name; if ( jtThis.collections.containsKey(cname) )
System. err.println ("Collection "+cname+" already defined. Using first definition. \n" ) ; else jjtThis. collections.put (cname, kid); } else if (kid instanceof ASTObjectDef) { jjtThis. objects. add ( (ASTObjectDef) kid) ;
} else { System. err.println ("Error in DDL Parser\n"); }
} } } ©
A collection definition includes a collection name and an optional list of attribute and common type pairs. « Grammar Rules »= void CollectionDef () : { Token cname;
Hashtable commontypes = new Hashtable ( ) ; } {
(<COLLECTION> (cname = <ID>) // [ <ISA> (<ID>)+ ] [<LBRACE> (AttributeDef (commontypes) ) * <RBRACE>] ) { jjtThis.name = cname. image; jtThis .commontypes = commontypes; } }
©
An attribute definition includes the attribute's name and an optional common type for the attribute.
« Grammar Rules »= void AttributeDef (Hashtable commontypes) #void :
{
String name; DataValue type;
(name = AttributeName () <IS> type = TypeldO) { commontypes .put (name, type); }
}
String AttributeName ( ) #void : Token t; DataValue v;
= <ID> { return t. image; } v = TypeldO { return v. getTypeO;
©
An object definition includes an optional object-identifier string, an optional list of collections to which the object belongs, and an optional list of attribute, value pairs.
« Grammar Rules »= void ObjectDef () :
{
Token coll, oid = null;
String name;
SList colls new SList ( ) ;
SList attrs new SList ( ) ; } {
(<OBJECT> [ oid = <ID> ] [ <IN> (coll = <ID> { colls .add (coll . image ); })+ ]
<LBRACE>
(name = AttributeName ( ) AttributeValue ( ) { attrs. add (new Pair (name, j jtree .popNode () ) ) ; } ) * <RBRACE>) { if (oid != null) { int dot = oid. image . indexOf ('.'); if (dot >= 0) { jjtThis.graph = oid. image. substring (0, dot); jjtThis. oid = oid. image. substring (dot+1) ; } else jjtThis. oid = oid. image; } jjtThis. collections = colls; jjtThis. attributes = attrs;
An attribute's value may be an object identifier, an atomic value, or the value of a nested object.
Atomic values take an optional type that can be used to resolve type am biguities.
« Grammar Rules »= void AttributeValue ( ) #void : { }
{
(ObjectRef ( )
I AtomicRef ( )
I ObjectDef O ) } void Ob ectRef () :
{ Token oid, graph = null; }
{ oid = <OIDREF> {
String oidstr = oid. image. substring(1) // Skip "©' int dot = oidstr . indexOf ('.'); if (dot >= 0) { jtThis.graph = oidstr .substring (0, dot) jjtThis. oid = oidstr. substring (dot+1) ; } else jjtThis. oid = oidstr; } } void AtomicRef ( ) : {
DataValue type = null, val;
( [ <IS> type = Typeld( ) ] val = AtomicValue ( ) ) { jjtThis. type = type; jjtThis.val = val; }
} © << Grammar Rules »=
DataValue Typeld() #void {} {
<BOOLTYPE> return DataValue.boolval; } I <DATETYPE> return DataValue.dateval; } j <FLOATTYPE> return DataValue. floatval ; I <IMAGETYPE> return DataValue. imageval ; j <HTMLTYPE> return DataValue.htmlval ; } j <INTTYPE> return DataValue. intval; } j <OBJECT> return DataValue. objval; } j <PSTYPE> return DataValue.psval; } j <STRINGTYPE> return DataValue. stringval; I <TEXTTYPE> return DataValue . textval ; }
<URLTYPE> return DataValue.urlval; }
}
©
« Grammar Rules »=
DataValue AtomicValue ( )
{
Token t; DataValue v = new BoolDataValue ( "true" )
(t = <BOOLVALUE> { v = new BoolDataValue (t . image) ; } t = <FLOATING_POINT> { v = new FloatDataValue (t. image) ; } t = <STRING>{ v = new StringDataValue (HTMLParser. clip (t . image) ) t = <INTEGER>{ v = new IntDataValue (t .image) ; } t = <IMAGEVALUE>{ v = new GifDataValue (t. image) ; } t = <HTMLVALUE>{ v = new HtmlDataValue (t. image) ; } t = <PSVALUE>{ v = new PsDataValue (t . image) ; } t = <TEXTVALUE>{ v = new TextDataValue (t. image) ; } I t = <URLVALUE> { v = new UrlDataValue ( t . image) ; }) { return v; }
}
« Lexical Rules »= TOKEN_MGR_DECLS : { static int curline = 0; static String curfile = " " ; }
SKIP : /* WHITE SPACE */ {
I "\t" j "\n" { curline++; /* update line number here */ } j "\r"
I "\f"
}
« Lexical Rules »= SPECIAL_TOKEN : /* COMMENTS */ {
<SINGLE_LINE_COMMENT : "//" (~ [ " \n" , " \r" ] ) * ( " \n" | " \r" | " \r\n" ) > I <LINE_DIR: "#" ( ~ [ " \n" , " \r" ] ) *> {
StrmgTokenizer tokens = new StrmgTokenizer (image. toStringO , " #\""); curline = Integer.valueOf (tokens .nextToken ( ) ) . intValue ( ) ; curfile = tokens.nextToken () ;
System. out.println (curfile+" : "+curline) ;
}
I <FORMAL_COMMENT: "/**" ("["*"])* " * " ("*" | (-["*","/«] ("["*"])* "*'
))* "/">
I <MULTI_LINE_COMMENT: "/*" ("["*"])* "*" ("*" | (-[•■*»,"/"] ("["*"])*
"*"))* "/">
}
TOKEN [IGNORE_CASE] /* RESERVED WORDS AND LITERALS */ {
< BOOLTYPE : "bool" > ction" > > t" >
> " > > " >
Figure imgf000176_0001
> < OR : "or" >
< PSTYPE : "ps" >
< STRINGTYPE : "string" >
< TEXTTYPE : "text" >
< URLTYPE : "url" >
}
TOKEN [ IGNORE_CASE] : {
<BOOLVALUE : "true" 'false" > }
TOKEN : /* IDENTIFIERS */ {
< OIDREF : "@"<ID> > I < ID: <LETTER> ([ "a"- "z ", "A" - "Z" , "0 "-" 9 ","_","."]) * > j < #LETTER : [ "a"- " z " , "A" - " Z" , "_" ] > j < #DIGIT : ["0"-"9"] > }
TOKEN [IGNORE_CASE] : /* FILE NAME CONVENTIONS */ {
<URLVALUE <URLPRE><PATHCHAR»
<IMAGEVALUE <PATHCHARxIMAGESUF>>
<HTMLVALUE <PATHCHARxHTMLSUF»
<PSVALUE <PATHCHARxPSSUF»
<TEXTVALUE <PATHCHAR»
<#PATHCHAR ["/",""",".", "a." — " z " , "A" — "z " , " 0 " — " 9 " ] { ~ [ " " , "\t" , "\n" ,
\r", "\f "] )* > <#IMAGESUF "-jpg" I ".gif"> <#HTMLSUF ".htm" j ".html"> <#PSSUF " .ps"> <#URLPRE "http://" I "ftp://">
}
TOKEN : /* LITERALS */ {
< INTEGER:
<DECIMAL> I <HEX> j <OCTAL> >
< #DECIMA : [ " 1 " - " 9 " ] ( [ " 0 " - " 9 " ] ) * >
< #HEX: "0" ["x","X"] ( ["0"-"9", "a"-"f ", "A"-"F"] )+ >
I
< tOCTAL : " 0 " ( [ " 0 " - " 7 " ] ) * >
I
< FLOATING_POINT :
(["0"-"9"])+ " . " (["0"-"9"])* (<EXPONENT>)? ( [ " f " , "F" , "d" , "D" ] )
I "." (["0"-"9"])+ (<EXPONENT>)? ( [ " f " , "F" , "d" , "D" ] ) ? j ( ["0"-"9"] )+ <EXPONENT> ( [ " f" , "F" , "d" , "D" ] ) ? j ( [«0"-n9"])+ (<EXPONENT>)? [ " f " , "F" , "d" , "D" ]
< #EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
< CHARACTER:
("["'", "\\", "\n", "\r"] ) C\\"
( ["n", "t" , "b", "r", "f" , "\\", "'" , "\""]
I ["0"-"7"] ( ["0"-"7"] )?
I [ " 0 " - " 3 " ] [ " 0 " - "7 " ] [ " 0 " - "7 " ]
)
< STRING:
( ( ~ [ " \ " " ] )
I "\\\""
) *
« Lexical Rules »=
TOKEN : /* SEPARATORS */
{
< LPAREN " ( " >
| < RPAREN ••)" > j < LBRACE " { " >
| < RBRACE " } " > j < LBRACKET : " [ " > j < RBRACKET : " ] " > j < SEMICOLON: 1 >
| < COMMA: ", " > j < POP : " ' " > j < HASH: "#" > j < UNDER: "_" > j < ARROW: "->" >
}
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness * for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
package DataRepository;
import COM.objectspace. jgl . *; import java . lang . * ; import java.util.*; import java. io . * ;
public class BoolDataValue extends DataValue {
/* Constructors */ public BoolDataValue (boolean b) { this.b=new Boolean(b); } public BoolDataValue (String s) { this.b=new Boolean(s); }
/* Display Methods */ public String toStringO { return b. toString ( ) ,- } public boolean equals (Object obj ) { if (obj .getClass ( ) !=this.getClass () ) return false; return booleanValue ()==((BoolDataValue) obj ) .booleanValu e()
/* Get Methods */ public boolean booleanValue { ) { return b . booleanValue ( ) } public int hashCode ( ) { return b .hashCode ( ) ; } public DataValue copy(){ return new BoolDataValue (booleanValue () ) ; } public String getType ( ) { return "bool";
} /* Data */ private Boolean b; public static BoolDataValue TRUE=new BoolDataValue ( true) ; public static BoolDataValue FALSE=new BoolDataValue (false) ;
} /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package DataRepository; import COM.objectspace. jgl . *; import java . lang . * ; import java .util . * ; **
* CompareObject is a binary predicate that returns -1 if the first
* operand is less than or equal to the second operand; 0 if they are e qual;
* and 1 if the first is greater than the second. *
* Ordering rules :
* 1. An InternalDataObject is always greater than a LeafDataOb ect
* 2. The DataValues of LeafDataObjects are compared as follows:
* a. A pair of Integers and Floats are converted to floats and comp ared. b. Any 2 Dates are compared. c . All other DataValues are converted to Strings and their String values are compared. *
* 3. The OIDs of any 2 InternalDataObjects are compared.
*/ public final class CompareObject { public static int compare (DataObject first, DataObject second) throws RuntimeException { if (first instanceof LeafDataObject) { if (second instanceof InternalDataObject) { return -1; } else if (second instanceof LeafDataObject) { DataValue vfirst = first .getValue{ ) ; DataValue vsecond = second. getValue( ) ,- return compare (vfirst, vsecond); } else throw new RuntimeException ( "Unknown DataObject type in com pare\n" ) ;
} else if (first instanceof InternalDataObject) { if (second instanceof LeafDataObject) { return 1; } else if (second instanceof InternalDataObject) { if (first. equals (second) ) return 0; else return ( (InternalDataObject) first) . getUni ueOid O .compareT o( ( (InternalDataObject) second) . getUniqueOid ( ) ) ;
} else throw new RuntimeException ( "Unknown DataObject type in com pare\n" ) ; } return -1; } public static int compare (DataValue vail, DataValue val2) { if ( (vail instanceof IntDataValue | | vail instanceof FloatDataValue ) &&
(val2 instanceof IntDataValue | | val2 instanceof FloatDataValue )) { float fl, f2; if (vail instanceof IntDataValue) fl = (float) ( ( (IntDataValue)vail) .intValueO ) ; else fl = ((FloatDataValue) vail) . floatValue () ; if (val2 instanceof IntDataValue) f2 = (float) ( ( ( IntDataValue)val2) . intValue 0 ) ; else f2 = ((FloatDataValue) val2 ). floatValue () ,- if (fl < f2) return -1; else if (fl == f2) return 0; else return 1; } else if (vail instanceof DateDataValue && val2 instanceof DateDat aValue) {
Date dvl = ( (DateDataValue) vail) .dateValue( ) ,- Date dv2 = ( (DateDataValue)val2 ) . dateValue ( ) ; if (dvl.before (dv2 ))" return -1; else if (dvl.equals (dv2) ) return 0; else return 1; } else return vail . toString ( ) .compareTo(val2. toString ( ) ) ;
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package DataRepository; import COM.objectspace. jgl. *; import java.lang.*; import java.util.*; import java.io.*,- public class DataAttribute {
/* Constructors */ public DataAttribute (String s) { name=s ,- isPrintable=true; }
/* Display methods */ public String toStringO { return name; }
/* Get Methods */ public String getName ( ) { return name; } public void putPrintable ( ) { isPrintable=true; } public boolean isPrintable ( ) { return isPrintable; } / * Add Methods * /
/ * Data * / protected String name; protected boolean isPrintable;
} /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
package DataRepository; import CO . objectspace .jgl.*; import java. lang. * ; import java . util . * ; import java. io . * ; public class DataCollection{
/* Constructors */ public DataCollection (String s) { name=s ; } public DataCollection (String s, Hashtable types) { name=s ,- commontypes = types ; }
/* Display methods */ public String toStringO { return name; }
/* Get Methods */ public String getName (){ return name; } public HashSet getObjects(){ return new HashSet ( ) ; } public Array getMinAttributes ( ) { return new Array( ) ; } public Array getMaxAttributes ( ) { return new Array( ) ,- } public boolean isStored() { return false; } public void updateCommonTypes (Hashtable c) { commontypes = c; } public DataValue commontype (String a) { if (commontypes != null) return (DataValue) commontypes. get (a) ; else return null; }
/* Data */ protected String name; public Hashtable commontypes = new Hashtable ( ) ;
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package DataRepository; import COM.objectspace. jgl. *; import java. lang . * ; import java . util . * ; import java. io . * ; public final class DataEdge{ /* Constructors */ public DataEdge (DataAttribute a, InternalDataObject f, DataObject t) throws RuntimeException{ attribute=a; from=f; to=t; f .addOutEdge (this) ; if (t instanceof InternalDataObject) {
StoredDataGraph fg = (StoredDataGraph) f.getGraph( ) ; DataGraph tg = ( (InternalDataObject) t) .getGraph() ,- if (fg != tg) fg.addlmportedGraph(tg) ; } }
/* Display Methods */ public String toStringO { return from. toString ( ) +" — ( " +attribute .getName ( ) +" ) —>"+to. toString 0;
} public void graphPrint (PrintStream out) { if ( !attribute . isPrintable ( ) ) return; out .print (from.getUniqueOid() + " -> " ) ,- if (to.islnternal () ) { out.println ( ( (InternalDataObject) to) . getUniqueOid ( )+" [label=\" "+ attribute . getName () +" \ " ] ; " ) ; } else {
String label=LeafDataObject . getNewLabel ( ) ; out .print ( label+ " [ " ) ,-
DataValue value= ( (LeafDataObject) to) .getValue ( ) ; if (value. getType ( ) .equals ( "url" ) ) out.print ( "style=bold, " ) ; out .println ( "label=\ " "+attribute . getName ( ) +" \ " ] ; " ) ; out.println (label+" [color=indigo, label=\" "+value. format 0 +"\" ] ; " );
} }
/* Get Methods */ public DataAttribute getAttribute ( ) { return attribute; } public InternalDataObject getFrom(){ return from; } public DataObject getTo ( ) { return to; } // This is a hack to handle the problem that
// the optimizer assumes the attributes of DataGraphs are non-overlap ping.
// Instead of testing identity equality, test name equality, public boolean isAttribute (DataAttribute a) { return a .getName ( ) . equals (attribute . getName () ) ;
// return (a==attribute) ; }
/* Data */ private DataAttribute attribute; private InternalDataObject from; private DataObject to;
}
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package DataRepository; import COM.objectspace. jgl. *; import java . lang . * ; import java .util.*; import java.io.*,- import DDL.*; import Util .Environment; public abstract class DataGraph{
/* Constructors */ public DataGraph (String n) { name=n; collections=new HashSet ( ) ,- attributes=new Array ( ) ,- stringCollectiσn=new Hashtable 0 ; stringAttribute=new Hashtable { ) ; directory=Environment . getEnv ( " INPUT_DIR" ) +File . separator+name;
} public void changeName (String newName) { name=newName; }
/* Display methods */ public String getDirectoryO { return directory; } public String toStringO { return name; } public void graphPrint (PrintStream out) { out.printlnf "digraph "+name+" {"); out .println ( " center=true; " ) ; out.println( "concentrate=true; " ) ; out. rintln ( "color=lightblue; " ) ; out .println ( "rankdir=LR; " ) ,- Enumeration iter=getEdges ( ) .elements ( ) ,- while (iter .hasMoreElements ( ) )
( (DataEdge) (iter.nextElement () ) ) . graphPrint (out) ; iter=getlnternal0bjects ( ) . elements ( ) ; while (iter .hasMoreElements ( ) )
( (InternalDataObject) ( iter.nextElement () ) ) .graphPrint (out) ; out .println ("}"); LeafDataObject . resetGlobalNb ( ) ; } public void printDDL (PrintStream out) {
ASTDD .printDD (this , out, name) ; } public void printDDL (PrintStream out, String newName) {
ASTDDL.printDDL (this , out, newName) ; }
/* Get Methods */ public String getName ( ) { return name; } public HashSet getCollections ( ) { return collections; } public Array getAttributes ( ) { return attributes; } public DataCollection getCollection(String name) { return (DataCollection) "(stringCollection.get (name) ) ; } public DataAttribute getAttribute (String name) { return (DataAttribute) ( stringAttribute. get (name) ) ; } public void printAttribute (String name) {
DataAttribute att=getAttribute(name) ; if (att!=null) att .putPrintable ( ) ; } public void printAllAttributes ( ) {
Enumeration iter=attributes . elements ( ) ; while (iter .hasMoreElements ( ) )
( (DataAttribute) ( iter.nextElement ( ) ) ) .putPrintable () ; }
/* Get and Add Methods to Schema*/ public synchronized DataCollection getAddCollection( String ε) throws Exception {
DataCollection c = (DataCollection) (εtringCollection. get (s) ) ; if (c != null) return c; c = new StoredDataCollection ( (StoredDataGraph) this, s) ; addCollection(c) ; return c; } public synchronized DataAttribute getAddAttribute (String s) throws Ru ntimeException{
DataAttribute a= (DataAttribute) (stringAttribute. get (s) ) ; if (ai=null) return a; a=new DataAttribute ( s ) ,- addAttribute (a) ; return a; }
/* Add Methods to Schema */ public synchronized void addCollectiontDataCollection c) throws Excep tion { if (stringCollection.put {c.getNamet ) , c) != null) throw new RuntimeException ( "Collection already exists."); collections. dd (c) ,- } public synchronized void addAttribute (DataAttribute a) throws Runtime Exception { if (stringAttribute.put (a.getName( ) , a) !=null) throw new RuntimeException ( "Attribute already exists."); attributes. add (a) ; }
/* Query Processing Methods */ public abstract Array getEdges ( ) ; public abstract Array getlnternalObjects ( ) ; public abstract HashSet getObjects (DataCollection c) ; public abstract Array outObjects (InternalDataObject o) ; public abstract Array outObjects (InternalDataObject o, DataAttribute a); public abstract Array outEdges (InternalDataObject o) ; public abstract Array outAttribute (InternalDataObject o) ; public abstract boolean check (DataObject o , DataAttribute a, DataObjec t ol);
/* Data */ protected String name; protected String directory;
/* Schema */ protected HashSet collections ,- protected Array attributes; protected Hashtable stringCollection; protected Hashtable stringAttribute;
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
package DataRepository; import COM. objectspace. jgl . import java . lang. * ; import java .util.*; import java . io . * ;
public abstract class DataObject {
/* Constructors */ ' public DataObject ( ) { collections=new HashSet ( ) ; } /* Equal Methods */ public abstract boolean equals (DataObject o) ;
/* Display Methods */ public abstract String toStringO;
// Must be able to generate a unique identifier for all objects // Used to generate names of new objects public abstract String getOidO; public abstract String getUniqueOid 0 ; public abstract String toHtml (String fixedfile, String format, String tag, String args) ; public void graphPrint (PrintStream out){}
/* Add Methods */ public void addCollection ( StoredDataCollection c) { collections. add(c) ,- c . addObject ( this ) ; }
/* Get Methods */ public DataValue getValue ( ) { return value; } public String getType ( ) { return value . getType ( ) ; } public HashSet getCollections ( ) { return collections; } public boolean islnternal ( ) { return true; }
/* Query Processing */ public boolean inCollection (DataCollection c) {
Enumeration iter=collections . elements ( ) ; while (iter .hasMoreElements 0 ) {
DataCollection nth= (DataCollection) (iter .nextElement ()) ; if (nth==c) return true;
} return false; } public Array outObjects () { return new Array( ) ; } public Array outlnternalObjects () { return new Array() ; } public Array outLeafObjects ( ) { return new Array( ) ,- } public Array outObjects (String a) { return new Array( ) ; } public Array outObjects (DataAttribute a) { return new Array( ) ; } public Array outEdges ( ) { return new Array( ) ,- } public Array outAttribute ( ) { return new Array ( ) ; } public boolean check (DataAttribute a, DataObject o2) { return false; } public boolean belongsTo (String col){
Enumeration iter=collections . elements ( ) ; while (iter.hasMoreElements () ) {
DataCollection c= ( (DataCollection) (iter.nextElement 0 ) ) ; if (c. getName ( ) .equals (col) ) return true; } return false; }
/* Data */ protected DataValue value; protected HashSet collections;
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories * with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package DataRepository; import COM.ob ectspace. jgl. *; import COM. odi . * ; import jav . lang. * ; import java.util.*; import java. io . * ; import Util.*; public final class DataRepository {
/* Get Methods */ public static String getDirectory (DataGraph g) { return g. getDirectory() ; } public static Array getAllGraphs ( ) { return storedGraphs; } public static void changeGraphName ( String oldName, String newName) th rows Exception {
DataGraph g=getGraph (oldName) ; g.changeName (newName) ,- stringGraph . remove (oldName) ; stringGraph .put (newName , g) ; } public static DataGraph getGraph(String s) throws NotFound {
DataGraph g= (DataGraph) (stringGraph. get (s) ) ; if(g==null) throw new NotFound("No graph with name "+s) ; else return g; } public static DataGraph isGraph(String s) { return (DataGraph) ( stringGraph . get ( s ) ) ; } static synchronized public String getNewOidfDataGraph g) { return new String( "oid" ) ; }
/* Equality Methods */ static synchronized public boolean isomorphic (String si, String s2) throws Exception {
DataGraph gl , g2 ; try { gl=getGraph(sl) ; g2=getGraph(s2) ; } catch (NotFound e) {
System. err.println (e. toString ( ) ) ,- throw e; }
HashSet coll=gl . getCollections ( ) ; HashSet col2=g2. getCollections ( ) ; if (coll . size ( ) ! =col2. size ( ) ) {
System. out.println ( "The graphs "+sl+" and "+s2+" are not isomorph ic: the number of collections is not the same.\n The graph "+sl+" has t he following collections: "+coll+"\n The graph "+s2+" has the following collections: "+col2); return false,- }
Array attl=gl .getAttributes ( ) ; Array att2=g2.getAttributes ( ) ; if (attl.sizeO !=att2.size() ) {
System. out .println ( "The graphs "+sl+" and "+ε2+" are not isomorph ic: the number of attributes is not the same.\n The graph "+εl+" has th e following attributes: "+attl+"\n The graph "+s2+" has the following a ttributes : " +att2 ) ; return false; }
Array objl=gl . getlnternalObjects ( ) ; Array obj2=g2.getlnternalOb ects ( ) ; if (objl.sizeO !=obj2.size( ) ) {
System. out.printlnt "The graphs "+sl+" and "+s2+" are not isomorph ic: the number of objects is not the same.\n The graph "+sl+" has "+ ob jl.size()+" objects. \n The graph "+s2+" haε "+ obj 2.size ( ) +" objects.") return false; }
Array iobj l=gl .getlnternalObj ects ( ) ,- Array iobj2=g2. getlnternalObjects ( ) ; if (iobjl . size ( ) ! =iobj2. size 0 ) {
System. out.printlnt "The graphs "+sl+" and "+s2+" are not isomorph ic: the number of internal objects is not the same.\n The graph "+sl+" has "+ iobjl. size () +" internal objects. \n The graph "+s2+" has "+ iobj2 . size()+" internal objects. "); return false; }
Enumeration iter; iter=coll . elements ( ) ; while (iter.hasMoreElements ( ) ) {
DataCollection cl= ( (DataCollection) (iter .nextElement ( ) ) ) ; DataCollection c2=g2.getCollectionfcl. getName 0 ) ; if (c2==null) {
System. out.printlnt "The graphs "+sl+" and "+s2+" are not isomor phic. \n The collection "+cl .getName 0 +" exists in "+sl+", but not in " +s2 ) ,- return false; } if (cl.getOb ectsO .size() !=c2.getObjects 0.size( ) ) {
System. out.println( "The graphs "+sl+" and "+s2+" are not isomor phic. \n The collection "+cl .getName 0 +" has "+cl. getObjects ( ) .size () +" elements in "+sl+" and "+c2.getObjects 0. size 0 +" elements in "+s2) ,- return false; } }
System. out.println ("The two graphs SEEM to be isomorphic. At least could not detect if they aren't."); return true;
/* Put Methods */ public static StoredDataGraph addStoredGraph (StoredDataGraph g) throw AlreadyDefined {
String name=g. getName ( ) ; if (stringGraph.put (name , g) ! =nul1) throw new AlreadyDefined () ; storedGraphs.add(g) ; return g; }
/* Remove Methods */ public static void deleteStoredGraph ( StoredDataGraph g) { storedGraphs .remove (g) ; stringGraph. remove (g . getName ( ) ) ; }
/* Query processing methods */ Data */ static private Array storedGraphs;
/* I think this is necessary */ static private Hashtable stringGraph; static String htmlDirectory; static private volatile long nb_oids;
/* Constructor */
static { storedGraphs=new ArrayO; stringGraph=new Hashtable ( ) nb_oids=1000; }
/* methods usefull for everybody */ public static Array removeDuplicates (Array input) { Array output=new Array ( ) ; Enumeration iterl, iter2; Object ol, o2; iterl=input . elements ( ) ,- boolean found; while (iterl . hasMoreElements 0 ) { ol=iterl .nextElement ( ) ; found=false; iter2=output . elements ( ) ; while (iter2.hasMoreElements ( ) ) { o2=iter2.nextElement ( ) ; if (ol. equals (o2) ) { found=true; break; } } if ( ! found) output . add(ol) ; } return output; } public static Array union (Array al, Array a2) { Array result=new A ray(al) ; Enumeration iter=a2. elements ( ) ; while (iter .hasMoreElements ( ) ) result . add (iter .nextElement ( ) ) ; return removeDuplicates (result) ,- } public static Array intersection (Array al, Array a2 ) { Array result=new Array(); Enumeration iterl, iter2; Object ol, o2; iterl=al . elements ( ) ; boolean found; while ( iterl . hasMoreElements ( ) ) { ol=iterl .nextElement ( ) ; found=false; iter2=a2. elements ( ) ; while (iter2.hasMoreElements ( ) ) { o2=iter2.nextElement ( ) ; if (ol. equals (o2) ) { found=true; break; } } if (found) result . add(ol) ; } return result; } public static Array difference (Array al, Array a2) { Array result=new Array() ; Enumeration iterl, iter2; Object ol, o2; iterl=al . elements ( ) ; boolean found; while (iterl .hasMoreElements ( ) ) { ol=iterl .nextElement ( ) ; found=false; iter2=a2. elements ( ) ; while (iter2.hasMoreElements ( ) ) { o2=iter2.nextElement ( ) ; if (ol. equals (o2) ) { found=true; break; } } if ( ! found) result .add (ol) ,- } return result;
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package DataRepository; import COM.objectspace. jgl. *; import jav . lang. * ; import java .uti1. * ; import java. io . * ; public abstract class DataValue { public abstract DataValue copy(); public abstract String getType ( ) ; public abstract boolean equals (Object obj); public abstract int hashCode () ; public abstract String toStringO; public String format ( ) { return toString ( ) ; } public String toHtml ( String fixedfile, String format, String tag, Str ing args) { return toString ( ) ; } public String toOid() { int code = hashCode ( ) ; if (code < 0) return "CN"+ (Integer. toString (0-code) ) ; else return "C"+ (Integer. toString (code) ) ,- } public static String filetoHtml (String filename, String tag, String a rgs) { int ind = filename. lastlndexOf (File. separator) ;
String nameonly; if (ind > 0) nameonly = filename. substring (ind+1 ) ; else nameonly = filename,- if (tag != null) return "<A HREF=\ " " +filename+" \ " "+args+">"+tag+"</A>" ; else return "<A HREF=\" "+filename+"\ " "+args+">"+nameonly+"</A>" ; }
// Representative values masquerade as types public static DataValue boolval = new BoolDataValue (true) ; public static DataValue dateval = new DateDataValue { "1/18/94" ) ; public static DataValue floatval = new FloatDataValue ( (float) 1.0) ; public static DataValue imageval = new GifDataValue ( "giffile" ) ; public static DataValue htmlval= new HtmlDataValue ( "htmlfile" ) ; public static DataValue intval = new IntDataValue (1) ; public εtatic DataValue objval = new OidDataValue ( "oid" ) ; public static DataValue psval = new PsDataValue ( "psfile" ) ; public static DataValue stringval = new StringDataValue ( "string" ) ; public static DataValue textval = new TextDataValue ( "textfile" ) ; public static DataValue urlval = new UrlDataValue ( "urlfile" ) ;
// Convert val to type "type", if possible. public static DataValue convertValue {DataValue type, DataValue val) { DataValue newval = val; if (type != null && ! (type. getType () .equals (val .getType 0 )) ) { if (type instanceof BoolDataValue) newval = new BoolDataValue (val. toStringO ) ; else if (type instanceof DateDataValue) newval = new DateDataValue (val. toString ( )) ; else if (type instanceof FloatDataValue) newval = new FloatDataValue (val. toString ( ) ) ; else if (type instanceof StringDataValue) newval = new StringDataValue (val . toString ( ) ) ,- else if (type instanceof IntDataValue) newval = new IntDataValue (val. toString ( )) ; else if (type instanceof GifDataValue) newval = new GifDataValue (val. toString ( )) ; else if (type instanceof HtmlDataValue) newval = new HtmlDataValue (val . toString ( ) ) ; else if (type instanceof PsDataValue) newval = new PsDataValue (val. toStringO ) ,- else if (type instanceof TextDataValue) newval = new TextDataValue (val . toString ( )) ; else if (type instanceof UrlDataValue) newval = new UrlDataValue (val. toString ( ) ) ; val = newval; } return val;
} /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package DataRepository; import COM.objectspace. jgl .* ; import java . lang. * ; import java.util.*; import java . io . * ; public class DateDataValue extends DataValue {
/* Constructors */ public DateDataValue (String s) { date=new Date(Date.parse(s) ) ; } public DateDataValue (Date d) { date=d; }
/* Display Methods */ public String toStringO { return date . toString ( ) ; } public boolean equals (Object obj ) { if ( obj . getClass ( ) ! =this . getClass ( ) ) return false; return dateValue ( ) . equals ( ( (DateDataValue) obj ) .dateValue () ) ; }
/* Get Methods */ public Date dateValue(){ return date; } public boolean before (DateDataValue v) { return date .before (v. dateValue 0 ) ; } public boolean after (DateDataValue v) { return date.after (v.dateValue () ) ; } public int hashCode(){ return date . hashCode ( ) ; } public DataValue copyO { return new DateDataValue (date) ; } public String getType ( ) { return "date";
}
/* Data */ private Date date; } / *
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reaεonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package DataRepository; import COM.objectspace. jgl. *; import java . lang . * ; import java.util.*; import java. io . * ; public class FloatDataValue extends DataValue {
/* Constructors */ public FloatDataValue (float f) { this.f = new Float (f); } public FloatDataValue (String s) { this.f = new Float (s); }
/* Display Methods */ public String toStringO { return f . toString ( ) ;
} public boolean equals (Object obj ) { if (obj .getClass 0 ! =this.getClass ( ) ) return false; return floatValue 0 == ( (FloatDataValue) obj ) . floatValue ( )
} /* Get Methods */
public float floatValue ( ) { return f . floatValue ( ) ,- } public int hashCode ( ) { return f .hashCode ( ) ; } public DataValue copyO { return new FloatDataValue ( floatValue ( ) ) ,- } public String getType ( ) { return " float" ; }
Data */ private Float f;
Copyright 1997 AT&T Labs -- Research
By receiving and using the code that follows, the user acknowledges and agrees to keep the code confidential and use the code solely for non-commercial research. The user further acknowledges and agrees th at the code is not an official product of AT&T Corp., and is provided * on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
package DataRepository; import COM.objectspace. jgl .* ,- import java . lang. * ; import java.util.*; import java. io . * ,- public class GifDataValue extends TextDataValue {
/* Constructor */ public GifDataValue (String s) { super ( s) ,-
}
/* Get Methods */ public String toHtml (String fixedfile, String format. String tag, Str ing arg) { if ( format. equals ( "embed" ) ) return "<IMG SRC=\ " "+fixedfile+" \ " "+arg+" >"; else return filetoHtml (fixedfile, tag, arg); } public String format ( ) { return " Image" ; } public DataValue copy() { return new GifDataValue (super. filename) ; } public boolean equals (Object obj ) { if (obj .getClass ( ) !=this. getClass { ) ) return false; return filename. equals ( ( ( (GifDataValue) obj ) .getFilename( ) ) ) ; } public String getType ( ) { return " image" ;
} } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for * non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code . */
package DataRepository;
import COM.objectspace. jgl. import java . lang . * ; import java.util.*; import java . io . * ; import Util . * ;
public clasε HtmlDataValue extends TextDataValue { /* Constructors */ public HtmlDataValue (String s) { super (s); }
/* Get Methods */ public String toHtml (String fixedfile, String format, String tag, Str ing arg) { if ( format.equals ( "embed" ) ) return FileUtility. readFile (super. filename) ; else return filetoHtml (fixedfile, tag, arg); } public String format ( ) { return "Html"; } public boolean equals (Object obj ) { if (obj . getClass () !=this. getClass () ) return false; return filename. equals ( ( ( (HtmlDataValue) obj ) .getFilenameO ) ) ; }
public DataValue copy(){ return new HtmlDataValue ( filename) ; } public String getType ( ) { return "html"; } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code . */
package DataRepository; import COM.objectspace. gl . ' import java. lang. * ,- import java.util.*; import java.io.*;
public class IntDataValue extends DataValue {
/* Constructors */ public IntDataValue (int i) { this.i=new Integer ( i ); } public IntDataValue (String s) { this.i=new Integer(s),-}
/* Display Methods */ public String toStringO { return i . toString ( ) ; } public boolean equals (Object obj ) { if (obj . getClass ( ) ! =this . getClass ( ) ) return false; return intValue ()==(( IntDataValue) obj ) . intValue ( ) ; }
/* Get Methods */ public int intValue ( ) { return i . intValue ( ) ; } public int hashCode ( ) { return i .hashCode ( ) ; } public DataValue copyO { return new IntDataValue ( intValue 0 ) ;
} public String getType ( ) { return " int" ; }
/* Data */ private Integer i;
}
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp. , and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package DataRepository; import COM.objectspace. jgl. *,- import java . lang . * ; import java.util.*; import java.io.*; import Querylnterpretor . * ; public class InternalDataObject extends DataObject { public InternalDataObject (StoredDataGraph g, String oid) { super ( ) ;
// System. out.println ( "internal object "+oid) ; value=new OidDataValue (oid) ; outEdges=new Array() ; graph = g; }
/* Equal Methods */ public boolean equals (DataObject o) { return o==this; }
/* Display Methods */ public String getUniqueOid 0 { if (graph. imported) return graph.getName () +"_"+getOid( ) ; else return getOidO;
} public String getOidO { return ( (OidDataValue) (value) ) .getOidO ; } public String toStringO { return ( (OidDataValue) (value) ) .getOidO ; } public String toHtml (String fixedfile, String format, String tag, Str ing arg) {
System. err.println ( "Error! in InternalDataObject .toHTML" ) ; return " " ; } public void graphPrint (PrintStream out) { out .print (getUniqueOid () +" [shape=box, ") ; out. rint ( "color=lightskyblue, label=\ " "+getUniqueOid() ) ; if ( ! collections . isEmpty0 ) { out.print ("\\n( ");
Enumeration iter=collections. elements 0 ; while (iter. hasMoreElements () ) out.print ( ( (DataCollection) (iter .nextElement ( ) ) ) . getName ()+" " ) out .print (")"); } out.println ( " \ " ] ; ") ; }
/* Add methods */ public void addOutEdge (DataEdge e) { outEdges . add (e) ,- }
/* Get Methods */ public StoredDataGraph getGrapht) { return graph; } /* Query Processing */ public Array outObjects (String s) {
DataAttribute attr = graph. getAttribute (s) ,- if (attr != null) return outObjects (attr) ; else return new Array() ; } public Array outObjects(){
Array result=new Array( ) ;
Enumeration iter=outEdges . elements ( ) ,- while (iter. asMoreElements ( ) ) result. add ( ( (DataEdge) (iter.nextElement ( ) ) ) .getTo() ) ; return DataRepository. removeDuplicates (result) ; }
public Array outlnternalObjects () throws RuntimeException{ Array result=new ArrayO; Enumeration iter=outEdges . elements ( ) ; while (iter . hasMoreElements ( ) ) {
DataObject o= ( ( (DataEdge) (iter .nextElement O ) ) . getTo ( ) ) ; if (o.islnternal () ) result . add(o) ;
} return DataRepository. removeDuplicates (result) ;
} public Array outLeafObjects () throws RuntimeException{ Array result=new ArrayO; Enumeration iter=outEdges . elements ( ) ; while (iter.hasMoreElements () ) {
DataObject o= ( ( (DataEdge) (iter.nextElement ( ) ) ) ) .getTo ( ) ; if ( ! o.islnternal ( ) ) result. add(o) ; } return DataRepository. removeDuplicates (reεult) ; } public Array outEdges ( ) { return outEdges; } public Array outAttribute ( ) {
Array result=new ArrayO;
Enumeration iter=outEdges . elements ( ) ; while (iter .hasMoreElements () ) {
DataEdge e= (DataEdge) ( iter. nextElement ( ) ) ; result . add (e . getAttribute () ) ;
} return DataRepository. removeDuplicates (result) ; } public Array outObjects (DataAttribute a) { Array result=new ArrayO; Enumeration iter=outEdges . elements ( ) ,- while (iter .hasMoreElements ( ) ) {
DataEdge e= ( (DataEdge) (iter .nextElement ( ) ) ) ; if (e.isAttribute(a) ) { result . add(e . getTo () ) ; } } return DataRepository.removeDuplicates (result) ; } public boolean check (DataAttribute a, DataObject o2){ Enumeration iter=outEdges . elements ( ) ; while ( iter . hasMoreElements ( ) ) {
DataEdge e= (DataEdge) (iter .nextElement ( ) ) ; if ( (e. getTo () .equals (o2) )&&(e. getAttribute () ==a) ) return true; } return false ; } /* Data */ private Array outEdges; protected StoredDataGraph graph; } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package DataRepository; import COM.objectspace. jgl . *,- import java.lang. * ,- import java.util.*; import java.io.*; public final class LeafDataObject extends DataObject{
/* Constructors */ public LeafDataObject (DataValue data) { super ( ) ,- this.value=data; }
/* Equal Methods */ public boolean equals (DataObject o) { if(!(o instanceof LeafDataObject) ) return false; DataValue vl=value; DataValue v2=o . getValue ( ) ; if (vl. equals (v2) ) { return true; } else return false; }
/* Display Methods */ public String toString ( ) { return value . toString ( ) ;
} public String getOidO { return value . toOid ( ) ; } public String getUniqueOid() { return value . toOid ( ) ; } public String toHtml (String fixedfile, String format, String tag, Str ing arg) { return value. toHtml (fixedfile, format, tag, arg); }
/* Get Methods */ public boolean islnternal () { return false;
}
/* Query Processor */ /* Data */
/* Static stuff...*/
static int globalNb; static { globalNb=l ; } static void resetGlobalNb 0 { globalNb=l ; } static String getNewLabel ( ) { return "value"+globalNb++; } }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement . * The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package DataRepository; import java.util.*; import CO . objectspace . jgl . * ,- **
* LessObject is a binary predicate that returns true if the first
* operand as a DataObject is less than or equal to the second operand
* as a DataObject. If <code>key_</code> is defined <code>key_</code> v alues
* of each object are used to determine order, otherwise object itself is
* used.
*
* Changed to LessObject : comparator requires that BinaryPredicate ret urn
* false when two objects are equal. */ public final class LessObject implements BinaryPredicate { private String key_=null; public LessObject () { this (null) ,- } public LessObject (String key) { key_ = key; } public boolean execute (Object first, Object second) { DataObject objl = (DataObject) first; DataObject obj2 = (DataObject) second; DataValue vall=getValue(objl, key_) ; DataValue val2=getValue(obj2, key_) ; int comparator = CompareObject .compare (vail, val2) ; if (comparator < 0) return true; else return false; } public DataValue getValue(DataObject obj, String attr) { if (attr == null || attr. lengthf ) ===== 0 | | !obj . islnternal () ) return obj . getValue ( ) ;
InternalDataObject iobj = (InternalDataObject) obj ; // Get objects bound to attribute "attr" Array targets = iobj .outObjects (attr) ; if (targets. size () > 0) {
DataObject firstobj = (DataObject) targets .at (0) ; return firstobj . getValue ( ) ,- } else return obj . getValue () ,- } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestionε for change and
* improvements to the code . */
package DataRepository;
import COM.objectspace. gl . * ; import java . lang . * ; import java.util.*; import java.io.*;
public class NullDataValue extends DataValue{
/* Constructors */ public NullDataValue ( ) {comment="",- } public NullDataValue (String s) {comment=s;
/* Get Methods */ public String toString ( ) { return "NULL";
public boolean equals (Object obj ) { return false; } public DataValue copyO { return new NullDataValue ( ) ; } public int hashCode ( ) { return comment .hashCode ( ) ,- } public String getType ( ) { return "any"; } /* Data */
String comment;
} /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package DataRepository; import COM.objectspace. jgl . *; import java.lang.*; import java.util.*; import java . io . * ; public final class OidDataValue extends DataValue {
/* Constructors */ public OidDataValue (String s) { this. oid = s; }
/* Get Methods */ public String getOid(){ return oid; } public String toStringO { return oid; } public boolean equals (Object obj ) { return (this==obj ) ; } public int hashCode ( ) { return oid. hashCode 0 ,- } public DataValue copy(){ return new OidDataValue (oid)
} public String getType ( ) { return "oid" ;
}
/* Data */ private String oid;
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The uεer shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package DataRepository;
import COM. objectspace. jgl . * ; import java . lang. * ; import java.util.*; import java . io . * ; public class PsDataValue extends TextDataValue{ /* Constructors */ public PsDataValue ( String s) { super (s); } public String toHtml (String fixedfile, String format, String tag, Str ing arg) { return filetoHtml (fixedfile, tag, arg);
} public String for at ( ) { return "Ps"; } public boolean equals (Object obj ) { if (obj .getClass ( ) ! =this .getClass ( ) ) return false; return filename. equals ( ( ( ( PsDataValue) ob ) .getFilenameO ) ) ; } public DataValue copyO { return new PsDataValue (filename) ; } public String getType (){ }
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp. , and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package DataRepository; import COM.objectspace. jgl. *; import java. lang. * ,- import java.util.*; import java.io.*; public final class StoredDataCollection extends DataCollection {
/* Constructors */ public StoredDataCollection (StoredDataGraph g, String ε) { super (s) ,- graph = g; objects=new HashSet () ; minAttributes=null ; maxAttributes=null ; } public StoredDataCollection (String s, Hashtable types) { super(s) ; objectε=new HaεhSet O ; minAttributes=null ; maxAttributes=null ; commontypes = types ,- } /* Display methods */
/* Get Methods */ public int getSize ( ) { return objects . size ( ) ; } public DataGraph getGraph ( ) { return graph; } public boolean isStoredt) { return true; } public HashSet getObjects (){ return objects; } public Array getMinAttributes ( ) { if (minAttributes != null) return minAttributes; HashSet set = getObjects (); Enumeration iter=set . elements ( ) ; while (iter .hasMoreElements ( ) ) {
DataObject o= ( (DataObject) (iter.nextElement () ) ) ; if (minAttributes == null) minAttributes = o . outAttribute ( ) ; else minAttributes = DataRepository. intersection (minAttributes, o.ou tAttribute 0 ) ; } return minAttributes,- } public Array getMaxAttributes ( ) { if (maxAttributes ! =null ) return maxAttributes; HashSet set= getObjects () ; Enumeration iter=set . elements ( ) ; while ( iter . hasMoreElements ( ) ) {
DataObject o= ( (DataObject) (iter .nextElement ( ) ) ) ; if (minAttributes==null) maxAttributes=o . outAttribute ( ) ; else maxAttributes=DataRepository.union (maxAttributes , o . outAttribut e () ) ; } return DataRepository. difference (maxAttributes, getMinAttributes ( ) )
}
/* Add Methods */ public void addOb ect (DataObject o) { if (o inεtanceof InternalDataObject) {
DataGraph og = ( (InternalDataObject) o) .getGraph () ; if (og != graph) graph. addlmportedGraph (og) ; } objects .add (o) ; } public void addObjects (HashSet objs) { objects = objects.union (ob s) ; }
/* Data */ private HashSet objects; private StoredDataGraph graph; private Array minAttributes; private Array maxAttributes;
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Cor . , and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package DataRepository; import COM.objectspace. jgl . *,- import java . lang . * ; import java.util.*; import java . io . * ; import Util . * ; public class StoredDataGraph extends DataGraph {
/* Constructors */ public StoredDataGraph (String n) { super (n) ; oidObjects=new Hashtable (); }
/* Display Methods */
/* Add Methods to the Data */ public void addlnternalObject (InternalDataObject o) throws AlreadyDef ined { if (oidObjects.put (o.getOidO , o) != null) throw new AlreadyDefinedCOID "+o . getOid () + " already defined in g raph"); } public void addlmportedGraph (DataGraph g) { importedGraphs . add (g) ; }
/* Get Methods */ public HashSet getlmportedGraphs ( ) { return importedGraphs; } public HashSet getAllImportedGraphs ( ) { if (allImportedGraphs == null) { alllmportedGraphs = new HashSet ( ) ; allImportedGraphs . add(this) ,- alllmportedGraphε = importedGraphs.union (allImportedGraphs ) ; Enumeration en = importedGraphs. elements () ; while (en.hasMoreElements () ) {
DataGraph gr = (DataGraph) en.nextElement () ; if (gr instanceof StoredDataGraph) { alllmportedGraphs = alllmportedGraphs.union (( (StoredDataGraph ) gr) .getAllImportedGraphs () ) ,- } } } return alllmportedGraphs; } public void importCollections () throws Exception{ if ( IcollectionsMerged) { if (collections. size ( ) > 0) throw new RuntimeException ( "Must import collections from import ed graphs before defining new collections."); Hashtable mergedColls = new Hashtable (); Enumeration en = importedGraphε . elements () ,- while (en.hasMoreElements () ) {
DataGraph gr = (DataGraph) en.nextElement () ; if (gr instanceof StoredDataGraph) {
( (StoredDataGraph) gr) . importCollections ( ) ; Enumeration colls = gr. getCollections () .elements () ; while (colls.hasMoreElements () ) {
StoredDataCollection newcol = (StoredDataCollection) colls.n extElement ( ) ,-
String colName = newcol.getNamet ) ;
// Inherit collection from imported graph
StoredDataCollection oldcol = (StoredDataCollection)mergedC oils.get (colName) ; if (oldcol == null) {
// Create new collection oldcol = new StoredDataCollection (this, colName); mergedColls.put (colName, oldcol) ; } // Merge in new objects oldcol . addObjects (newcol . getObjects ( ) ) ; } } }
// mergedColls now contains all the collections Enumeration keys = mergedCo11s. eys () ; while (keys .hasMoreElements ( ) ) {
String key = (String) keys.nextElement 0 ; addCollection( (StoredDataCollection) mergedColls. get (key) ) ; } collectionsMerged = true; } }
/* Query Processor */ public InternalDataObject getOb ect (String oid) { return (InternalDataObject) (oidObjects. get (oid) ) ;
} public Array getEdges ( ) { Array result=new ArrayO;
Enumeration iterl=getInternalObjects ( ) . elements ( ) ; while (iterl .hasMoreElementε ( ) ) {
Enumeration iter2= ( (InternalDataOb ect) (iterl .nextElement ( ) ) ) . out Edges ( ) . elements ( ) ; while (iter2.hasMoreElements () ) result . add ( iter2.nextElement 0 ) ; } return result; } public Array getlnternalObjects ( ) {
Array result=new ArrayO;
Enumeration iter=oidObjects . elements ( ) ; while (iter .hasMoreElements ( ) ) result. add(iter.nextElement () ) ; return result; } public HashSet getObjects (DataCollection c) { return c . getObjects ( ) ; } public Array outObjects (InternalDataObject o) { return o . outObjects ( ) ; } public Array outObjects (InternalDataObject o, DataAttribute a) { return o . outObjects (a) ,- } public Array outEdges (InternalDataObject o) { return o . outEdges ( ) ; } public Array outAttribute (InternalDataObject o) { return o . outAttribute ( ) ; } public boolean check (DataObject ol, DataAttribute a, DataObject o2){ return ol. chec (a, o2);
} public String newOid() { internaloid++; return "genoid_"+Integer. toString (internaloid) ,-
}
/* Materialized Data */ private static int internaloid = 0; protected Hashtable oidObjects; protected HashSet importedGraphs = new HashSet ( ) ; protected HashSet alllmportedGraphs = null; public boolean imported = false; private boolean collectionsMerged = false; } /*
* Copyright 1997 AT&T Labs — Reεearch
* By receiving and uεing the code that follows, the uεer acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitnesε
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defectε or εuggeεtionε for change and
* improvements to the code. */ package DataRepository; import COM. objectspace. jgl . * ; import java . lang. * ; import java.util.*; import java . io . * ; public class StringDataValue extendε DataValue {
/* Conεtructorε */ public StringDataValue (String s) { this.s=format (s) ,- alias=null; }
/* Display Methods */ public UrlDataValue getAlias ( ) { return alias; } public void putAlias (UrlDataValue url) { alias=url; } public String toStringO { return s; } public String truncate ( ) { if (s. length ()<15) return s; else return s . substring ( 0 , 10)+"..."; } public boolean equals (Object obj ) { if (obj .getClass ( ) !=this. getClass ( ) ) return false; return stringValue ( ) . equals ( ( (StringDataValue) obj ) . stringValue () ) ; }
/* Get Methods */ public String stringValue () { return s; } public int hashCode ( ) { int code;
// Java's hashCode is not good enough.
// It only the first 12-14 letters to generate a hash.
//System. err.println (s) ,-
//System. err.println (s.hashCode 0 ) ;
StringBuffer buf = new StringBuffer (s) ;
//System. err.println (buf .reverse () ) ;
String si = buf . reverse (). toString () ;
// System.err.println(si.hashCode ( ) ) ; return si .hashCode ( ) ; } public DataValue copyO { return new StringDataValue (s) ; } public String getType ( ) { return "String"; }
/* Data */ private String s; private UrlDataValue alias;
/*Static stuff*/ private static String format (String s) { String result=s. replace ( ' \" ' , ' '); result=result . trim( ) ; return result; } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges * and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package DataRepository; import COM.objectspace. jgl. *; import java.lang.*; import java.util.*; import java.io.*; import Util . * ; public class TextDataValue extends DataValue { /* Constructor */ public TextDataValue (String s) { thiε . filename = s;
}
/* Get Methodε */ public String toStringO { return filename; } public String toHtml (String fixedfile, String format, String tag, Str ing arg) { if (format.equalε ( "embed" ) ) return FileUtility. readFile(filename) ; else return filetoHtml (fixedfile, tag, arg); } public String format ( ) { return "Text" ; } public String getFilename () { return filename; } public DataValue copyO { return new TextDataValue (filename) ; } public boolean equals (Object ob ) { if (obj .getClass 0 !=this .getClass ( ) ) return false; return filename . equals ( ( ( (TextDataValue) obj ) . getFilename ( ) ) ) ; } public int hashCode(){ return filename. hashCode () ; } public String getType ( ) { return "text"; }
/* Data */ protected String filename;
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and lε provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggeεtionε for change and
* improvementε to the code. */
package DataRepository;
import COM.objectεpace. jgl . import java. lang. * ; import java .util . * ; import java . io . * ;
public class UrlDataValue extends DataValue { /* Constructors */ public UrlDataValue (String s) { this. location = s; }
/* Get Methods */ public String toString ( ) { return location; } public String toHtml (String fixedfile, String format, String tag, Str ing arg) { if ( format. equals ( "embed" ) ) return location; else return filetoHtml (location, tag, arg); } public String format ( ) { return "Url"; } public String getLocation() { return location; } public boolean equals (Object obj ) { if (obj .getClass ( ) !=this. getClass ( ) ) return false; return location. equals ( { ( (UrlDataValue) obj ) .getLocation( ) ) ) ; } public int hashCode(){ return location .hashCode ( ) ; } public DataValue copy(){ return new UrlDataValue (location) ; } public String getType ( ) { return "url " ; }
/* Data */ private String location;
* Copyright 1997 AT&T Labε — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" baεis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By.-JJTree: Do not edit this line. ASTAndExpr . java */ package HTMLParser; public class ASTAndExpr extends SimpleNode { public boolean negate = false; ASTAndExpr ( int id) { super (id) ; }
ASTAndExpr (HTMLParser p, int id) { super (p, id) ; } public static Node jjtCreate (int id) { return new ASTAndExpr (id) ,- } public static Node j jtCreate (HTMLParser p, int id) { return new ASTAndExpr (p, id) ;
} public boolean evaKEnv env) throws ASTException { boolean result = false; int kids = j jtGetNumChildren( ) ; if (kids >= 1) {
Node left = j jtGetChild(O) ; if (left instanceof ASTRelExpr) result = ( (ASTRelExpr) left) .eval (env) ; elεe if (left instanceof ASTCondExpr) result = ( (ASTCondExpr) left) .eval (env) ; else throw new ASTException ( "Invalid child of ASTOrExpr"); if (negate) result = .result; if (kids == 2) {
ASTAndExpr right = (ASTAndExpr) jtGetChild(l) ; result = result && right. eval (env) ; } } else throw new ASTException ( "Invalid child count of ASTOrExpr" ); return result; } }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTAttrExpr. java */ package HTMLParser; import COM.objectspace. jgl. *; import java .util . * ; import java. io . * ; import DataRepository. * ; public class ASTAttrExpr extends SimpleNode { public String objvar = "this"; public Array attrs = new ArrayO; private HTMLParser parser; static String nullattr = "<b>*NULL Strudel Attributed/b>" ;
ASTAttrExpr (int id) { super (id) ; }
ASTAttrExpr (HTMLParser p, int id) { super (p, id) ; parser = p; } public static Node j jtCreate (int id) { return new ASTAttrExpr (id) ; } public static Node jtCreate (HTMLParser p, int id) { return new ASTAttrExpr (p, id); }
// Return all instances of obj's attribute "attr"
/* public Enumeration dereference (DataObject obj, String attr) {
DataAttribute
Array out_objs = ob .outObjects (attr) ;
Enumeration iterator = out_objs .elements () ; return iterator; } */ public DataObject toObject(Env env) { if (attrs. sizeO == 0) return env. lookup (objvar) ; elεe {
Enumeration objs = toObjects (env) .elements O ; if (objs.hasMoreElements () ) return (DataObject) ob s .nextElement ( ) ,- else return null; } } public Array toOb ects (Env env) {
DataObject obj = env. lookup (ob var) ;
Array a = new Array ( ) ; a . add(ob ) ;
Enumeration objs = a .elements ( ) ; int i; for (i = 0; objs .hasMoreElements () && i < attrs. size () ; i++) { obj = (DataObject) objs.nextElement () ; a = obj .outOb ects ( (String) attrs. at (i) ) ;
// System. out.printlnt "attr is"+ (String) attrs. at (i) +" size is "+I nteger. toString (a. size ( ) ) ) ; objs = a. elements ( ) ; } return a; } public String eval (Env env, String format, ASTTag tags, ASTTag args) throws ASTException{
DataObject obj = toOb ect (env) ; if (obj == null) { return nullattr; } else {
String tag = null;
String arg = " " ; if (tags != null) tag = tags. eval (env) ; if (args != null) arg = args. eval (env) ;
// All the logic for embedding vs. linking of pages is done here. try {
// System.out.println (obj . toString ( ) ) ; if (obj instanceof InternalDataObject) {
InternalDataObject iobj = (InternalDataObject) obj ; if (parser .objgen. htmlgen. isPage (iobj ) ) {
String url = parser. objgen.htmlgen. urlName (iobj ) ; if (format. equals ( "embed" ) ) { return url; } else { return DataValue. filetoHtml (url, tag, arg); } } else return parser. objgen. getHTML( iobj ) ; } elεe {
String fixedfile = nullattr; DataValue val = obj . getValue ( ) ; if (val instanceof TextDataValue) fixedfile = parser. objgen.htmlgen. uniqueFileName (( (TextData Value) val) . getFilename () ) ,- return obj .toHtml (fixedfile, format, tag, arg); } } catch (Exception e) {
System. err .println ( " In ASTAttrExpr . eval : " +e . toString () ) ; throw new ASTException( "AST Error"); } } } public void dump (String pref) { int i;
Enumeration e = attrs. elements ( ) ; System. out.print (pref + objvar) ; while (e.hasMoreElements () )
System. out.print ( " . " + e.nextElement 0 ) ,- System. out .println ( ) ;
} } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggeεtionε for change and
* improvementε to the code. */
/* Generated By:JJTree: Do not edit thiε line. ASTCondExpr . java */ package HTMLParser; public class ASTCondExpr extends SimpleNode { ASTCondExpr (int id) { super (id) ;
}
ASTCondExpr (HTMLParser p, int id) { super (p, id);
} public static Node j jtCreate (int id) { return new ASTCondExpr (id) ;
} public static Node j tCreate (HTMLParser p, int id) { return new ASTCondExpr (p, id); } public boolean eval (Env env) throws ASTException{ if (jjtGetNumChildrenO == 1) {
ASTOrExpr child = (ASTOrExpr) jjtGetChild(O) ; return child. eval (env) ; } else throw new ASTException ( "Invalid child of ASTCondExpr"); }
Copyright 1997 AT&T Labs — Research
By receiving and using the code that follows, the user acknowledges and agrees to keep the code confidential and use the code solely for non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding * but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTConstant. java */ package HTMLParser; import DataRepository. * ; public class ASTConstant extends SimpleNode {
DataValue value;
ASTConstant (int id) { super (id) ;
}
ASTConstant (HTMLParser p, int id) { super (p, id) ; } public static Node jjtCreate (int id) { return new ASTConstant (id) ; } public static Node jjtCreate (HTMLParser p, int id) { return new ASTConstant (p, id); }
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package HTMLParser; public class ASTException extends Exception {
ASTException (String msg) { super (msg) ;
} } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTFmtExpr . java */ package HTMLParser; public class ASTFmtExpr extends SimpleNode { public ASTAttrExpr attrexpr = null; public String prefix = " " ; public String format = "link"; public ASTTag tags = null; // Contents of HTML tag public ASTTag args = null; // Optional HTML arguments
ASTFmtExpr ( int id) { super (id) ; }
ASTFmtExpr (HTMLParser p, int id) { super (p, id); } public static Node j jtCreate (int id) { return new ASTFmtExpr (id) ; } public static Node j jtCreate (HTMLParser p, int id) { return new ASTFmtExpr (p, id) ; } public String eval (Env env) throws ASTException { return prefix + attrexpr. eval (env, format, tagε, args); // return "*FMT*" + prefix + " " + format + "\n";
} public void dump (String pref) {
System. out.print (pref + "*FMT*" + prefix + " " + format + " " ) ; if (attrexpr != null) attrexpr .dump (pref) ; if (tags != null) tags, dump (pref) ,- }
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code εolely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided * on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTForExpr . ava */ package HTMLParser,- import COM.objectspace. jgl. *; import java.util. *,- import java.io.*; import DataRepository. * ,- public class ASTForExpr extends SimpleNode { public String prefix = " " ,- public String suffix = " " ; public String predelim = " " ; public String delim = " " ,- public String objvar = "this"; public ASTAttrExpr attrexpr = null; public ASTOrder order = null; public ASTTemplate body = null;
ASTForExpr (int id) { εuper (id) ,- }
ASTForExpr (HTMLParεer p, int id) { super (p, id) ; } public static Node j jtCreate (int id) { return new ASTForExpr (id) ; } public static Node j jtCreate (HTMLParser p, int id) { return new ASTForExpr (p, id) ; } public String eval (Env env) throws ASTException { String result = prefix;
Array outobjs = attrexpr. toObjects (env) ; if (order != null) outobjs = order. sort (outobjs) ; // this.dumpC") ;
Enumeration iterator = outobj s. elements 0 ; while (iterator. hasMoreElements () ) {
DataObject curobj = (DataObject) iterator.nextElement () ;
//System. out.println (objvar+"="+curobj .toStringO ) ; env.push (objvar, curobj ) ; result += predelim + body. eval (env) ; if (iterator.hasMoreElements ( ) ) result += delim; env.pop () ; } result += suffix; return result; } public void dump (String pref) {
System. out .println (pref + " *FOR* : " ) ; if (prefix != null) System. out.println (pref + prefix);
System. out.println (pref + objvar) ; if (attrexpr != null) attrexpr. dump (pref + "ATTR "); if (order != null) order.dump (pref) ,- if (body != null) body. dump (pref + "BODY "); if (suffix != null) System. out.println (pref + suffix); } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp. , and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTHtml.java */ package HTMLParser; public class ASTHtml extends SimpleNode { public String text; ASTHtml (int id) { super (id) ; }
ASTHtml (HTMLParser p, int id) { super (p, id) ; } public static Node jjtCreate (int id) { return new ASTHtml (id); } public static Node jjtCreate (HTMLParser p, int id) { return new ASTHtml (p, id); } public String eval (Env env) { return text; } public void dump(String prefix) {
System.out.println(prefix + "*HTML*: " + text);
} } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTIfExpr . java */ package HTMLParser; public class ASTIfExpr extends SimpleNode { public String prefix; public ASTCondExpr cond = null; public ASTTemplate truebody = null; public ASTTemplate falsebody = null; ASTIfExpr (int id) { super (id) ; }
ASTIfExpr (HTMLParser p, int id) { super(p, id) ; } public static Node jjtCreate (int id) { return new ASTIfExpr (id) ; } public static Node jjtCreate (HTMLParser p, int id) { return new ASTIfExpr (p, id); } public String eval (Env env) throwε ASTException { String result = " " ; if (cond.eval (env) ) result = truebody. eval (env) ,- else if (falsebody != null) result = falsebody.eval (env) ; return prefix+result; } public void dump (String pref) {
System.out.println(pref + "*IF*:"); if (cond != null) cond. dump (pref) ; if (truebody != null) truebody. dump (pref + "THEN:"); if (falsebody != null) falsebody. dump (pref + "ELSE:"); } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitnesε
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTOrExpr . java */ package HTMLParser; public class ASTOrExpr extends SimpleNode { ASTOrExpr (int id) { super ( id) ; }
ASTOrExpr (HTMLParser p, int id) { super (p, id) ; } public static Node j tCreate (int id) { return new ASTOrExpr (id) ,- } public static Node j tCreate (HTMLParser p, int id) { return new ASTOrExpr (p, id); } public boolean eval (Env env) throws ASTException { if (jjtGetNumChildrenO == 1) {
ASTAndExpr child = (ASTAndExpr) jtGetChild(O) ; return child. eval (env) ; } else if (JjtGetNumChildre O == 2) {
ASTAndExpr left = (ASTAndExpr) j tGetChild(O) ; ASTOrExpr right = (ASTOrExpr) jjtGetChild(l) ; return left. eval (env) || right. eval (env) ; } else throw new ASTException( "Invalid child of ASTOrExpr"); } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges * and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggeεtions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTOrder . j ava */ package HTMLParser; import COM.objectspace. jgl. *; import java. util . * ; import java. io . * ; import DataRepository. LessObject; public class ASTOrder extends SimpleNode { public String order = null; public String key = null; ASTOrder (int id) { super (id) ; }
ASTOrder (HTMLParser p, int id) { super (p, id) ; } public static Node jjtCreate (int id) { return new ASTOrder (id) ; } public static Node jjtCreate (HTMLParser p, int id) { return new ASTOrder (p, id) ; } public Array sort (Array outobjs) { if (order. equals ( "ascend" ) ) {
Sorting. sort (outobjs, new LessObject (key) ) ; } else if (order.equals ( "descend" ) )
Sorting. sort (outobjs, new SwappedBinaryPredicate (new LessObject (k ey) ) ) ; return outobjs; } public void dump (String pref) {
System. out.println (pref + order + " " + key) ; } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTRelExpr. java */ package HTMLParser; import COM.objectspace. jgl. *; import java.uti1. * ; import java . io . * ; import DataRepository. * ; public class ASTRelExpr extends SimpleNode { String op = " !=" ; ASTTerm left = null; ASTTerm right = null; ASTRelExpr (int id) { εuper (id) ; }
ASTRelExpr (HTMLParser p, int id) { super (p, id) ; } public static Node j tCreate (int id) { return new ASTRelExpr (id) ; } public static Node j jtCreate (HTMLParser p, int id) { return new ASTRelExpr (p, id); }
// Relational public boolean eval (Env env) throws ASTException { boolean result = false; int kids = JjtGetNumChildrenO; DataValue rval = new NullDataValue ( ) ,- if (left != null) {
DataValue lval = left. eval (env) ;
String lsval = lval . toString () ; if (right != null) { rval = right .eval (env) ;
}
String rsval = rval . toString ( ) ; int comp = lsval. compareTo(rsval) ; if (op. equals ("!=") ) result = (comp != 0) ,- else if (op. equals ("=") ) result = (comp == 0) ; else if (op. equals ("<=") ) result = (comp <= 0); else if (op. equals (">=") ) result = (comp >= 0) ,- else if (op. equals ("<") ) result = (comp < 0) ; else if (op. equals (">") ) result = (comp > 0) ; } else throw new ASTException ( "Invalid child count of ASTRelExpr"),- return result,- } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTStart. ava */ package HTMLParser; public class ASTStart extends SimpleNode { ASTStart (int id) { super (id) ; }
ASTStart (HTMLParser p, int id) { super (p, id); } public static Node jjtCreate (int id) { return new ASTStart (id) ; } public static Node j jtCreate (HTMLParser p, int id) { return new ASTStart (p, id); } public static String eval ( ) {
// t = getchild
// result += t. eval (env) return " " ; }
Copyright 1997 AT&T Labs — Research
By receiving and using the code that follows, the user acknowledges and agrees to keep the code confidential and use the code solely for non-commercial research. The user further acknowledges and agrees th at * the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTString.java */ package HTMLParser; public class ASTString extends SimpleNode { public String str; ASTString (int id) { super (id) ;
}
ASTString (HTMLParser p, int id) { super (p, id) ; } public static Node jjtCreate (int id) { return new ASTString (id) ; } public static Node jjtCreate (HTMLParser p, int id) { return new ASTString(p, id) ; } public String eval (Env env) { return str;
} } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTTag. java */ package HTMLParser; public class ASTTag extends SimpleNode { ASTTag (int id) { super (id) ;
}
ASTTag (HTMLParser p, int id) { super(p, id) ; } public static Node jjtCreate (int id) { return new ASTTag(id) ; } public static Node jjtCreate (HTMLParser p, int id) { return new ASTTag(p, id); }
public String eval (Env env) throws ASTException { String result = " " ; int i; Node n; for (i = 0; i < JjtGetNumChildrenO; i++) { n = jjtGetChild(i) ; if (n instanceof ASTString) result += ( (ASTString)n) .eval (env) ,- else if (n instanceof ASTAttrExpr) result += ( (ASTAttrExpr)n) .eval (env, "embed", null, null); else throw new ASTException ( "Invalid child of ASTTag"); } return result; } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTTemplate.java */ package HTMLParser; public class ASTTemplate extends SimpleNode { public String suffix = " " ; ASTTemplate (int id) { super (id) ; } ASTTemplate (HTMLParser p, int id) { super (p, id) ; } public static Node jjtCreate (int id) { return new ASTTemplate (id) ; } public static Node jjtCreate (HTMLParser p, int id) { return new ASTTemplate (p, id); } public String eval (Env env) throws ASTException{ String result = " " ; int i; Node n; for (i = 0; i < jjtGetNumChildrenO; i++) { n = jjtGetChild(i) ; if (n instanceof ASTHtml) result += ( (ASTHtml}n) .eval (env) ; else if (n instanceof ASTFmtExpr) result += ( (ASTFmtExpr)n) .eval (env) ,- else if (n instanceof ASTIfExpr) result += ( (ASTIfExpr)n) .eval (env) ; else if (n instanceof ASTForExpr) result += ( (ASTForExpr) n) .eval (env) ; elεe throw new ASTExceptio ( "Invalid child of ASTTemplate"); } return result+suffix; } } / *
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basiε with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitnesε
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */
/* Generated By:JJTree: Do not edit this line. ASTTerm. java */ package HTMLParser; import COM.objectspace. jgl. *; import ava.util.*; import java.io. *; import DataRepository.*; public class ASTTerm extends SimpleNode { ASTTerm(int id) { super (id) ;
} _
ASTTerm(HTMLParser p, int id) { super (p, id) ;
} public static Node jjtCreate (int id) { return new ASTTerm (id) ; } public static Node jjtCreate (HTMLParser p, int id) { return new ASTTerm (p, id); } public DataValue eval (Env env) throws ASTException { DataValue result; if (jjtGetNumChildrenO == 1) { Node child = jjtGetChild(O) ; if (child instanceof ASTConstant) result = ( (ASTConstant) child) .value,- else if (child instanceof ASTAttrExpr) {
DataObject obj = ( (ASTAttrExpr) child) . toObject (env) ; if (obj == null) result = new NullDataValue ( ) ,- else if (obj instanceof InternalDataObject) result = new StringDataValue (obj . toString ( )) ; else result = ( (LeafDataObject)obj ) .getValuet ) ; } else throw new ASTException ( "Invalid child of ASTTerm"); } else throw new ASTException ( "Invalid child count of ASTTerm"); return result; } } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package HTMLParser; import COM.objectspace. jgl. * ,- import java.util . *; import java. io . * ; import DataRepository. * ; public class Env { private SList env = new SList (); public DataObject lookup (String s) { Enumeration e = env.elements () ; while (e .hasMoreElements ( ) ) {
Pair p = (Pair) e.nextElement ( ) ,- if (s. equals (p. first) ) return (DataObject) p.second; } return (DataObject) null; } public void push(String s, DataObject o) { Pair p = new Pair(ε, o) ,- env.pushFront (p) ; } public void pop() { if (!env.isEmpty() ) env.popFront ( ) ,-
} } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package HTMLParser; import java. io. * ; import java.util . * ; import java. text . * ; import COM.objectspace. jgl . *; import DataRepository.*; import DDL. * ; import Util . * ; /**
* An HTMLGenerator materializes a site graph in a physical HTML web si te. ©author Jaewoo Kang ©version 1.00, 09 Sep 1997 ©see ObjectHTMLGenerator ©since STRUDEL1.0
*/ public class HTMLGenerator { private ObjectHTMLGenerator obj_gen_; private HashSet pageobjects; private DataGraph dg; private HashSet isgenerated; private HashMap fixedFiles; private String baseurl; private String filesDir; public HTMLGenerator (DataGraph graph, HashSet pages, String base) { obj_gen_ = new ObjectHTMLGenerator (this) ; pageobjects = pages; dg = graph; isgenerated = new HashSet ( ) ; fixedFiles = new HashMapO; baseurl = base; filesDir = graph. getDirectory() +File. separator+" files " ; } public boolean generateHTML ( ) { return generateHTML (new QueueO); } private void emitcopyscript ( ) {
File copyscript = new File (filesDir+File.separator+"copyscript" ) ; try {
PrintWriter pw = new PrintWriter (new FileWriter (copyscript) ) ; Enumeration keys = fixedFiles. keys () ; while (keys. hasMoreElements () ) {
String key = (String) keys.nextElement 0 ; pw.println ( "cp "+ (String) fixedFiles.get (key) +" "+fileεDir+File .separator+key) ; } pw. close ( ) ;
System. err.println( "Execute script in: ' "+copyscript .getAbsoluteP ath()+"' to copy all source files referenced in externalized site."); } catch (Exception e) {
System. err.println (e. toStringO ) ,- } } public boolean generateHTML (Queue objlist) {
System. out.printlnt "Materializing graph "+dg . getName ()) ; String dir = dg. getDirectory( )+File. εeparator+"εite" ,- boolean rbool = true; if (dg instanceof StoredDataGraph) rbool &= generatestoredGraphHTML( (StoredDataGraph) dg, objlist); else System.err .println ( "Can only materialize stored graph."),- System. out .println ( "Materialization ended. " ) ;
11 It externalizing graph, emit files to copy in "copyscript1 if (baseurl != null) { emitcopyscript ( ) ; } return rbool;
} public boolean generateStoredGraphHTML ( StoredDataGraph sto, Queue obj { boolean rbool = true;
Array iobjs = new ArrayO ;
SLiεt embedded = new SList () ,-
SList pages = new SList ( ) ;
// Partition embedded objects and page objects if (ob s. isEmpty () ) {
HashSet all_graphs = sto. getAllImportedGraphs () ; Enumeration graphs = all_graphs.elementε 0 ,- while (graphε . haεMoreElementε ( ) ) {
DataGraph gr = (DataGraph) graphε . nextElement () ,- Enumeration en = gr. getlnternalObjects () .elements () ; while (en.hasMoreElements () ) {
InternalDataObject iobj = (InternalDataObject) en . nextElement if (pageobjects. get (iobj ) == null) { embedded. add ( iobj ) ; } else { pages . add ( iobj ) ; }
}
} } else {
Enumeration en = obj s . elements 0 ; while (en. hasMoreElements () ) {
InternalDataOb ect iobj = (InternalDataObject) en. nextElement ( ) if (pageobj ects. get (iobj ) == null) embedded. add (iobj ) ; elεe pages . add ( iobj ) ; } }
// Generate HTML for all embedded objects first while ( ! embedded. isEmpty ( ) ) {
InternalDataObject iobj = (InternalDataObject) embedded.popFront ( ) rbool &= obj_gen_. generateHTML (iobj ) ; isgenerated.put (iobj ) ,- }
// Then generate all pages while (!pages. isEmpty () ) {
InternalDataObject iobj = ( InternalDataObject ) pages .popFront ( ) ; rbool &= obj_gen_. generateHTM (iobj ) ; isgenerated.put (iobj ) ,- } return rbool;
} public boolean isPage( InternalDataObject iobj) { if (pageobjects. get (iobj ) != null) return true; else return false; } public boolean isGenerated( InternalDataObject iobj) { if (isgenerated.get (iobj ) != null) return true; else return false; } public void wasGenerated (InternalDataObject iobj) { isgenerated.put (iobj ) ,- } public String uniqueFileName (String filename) { try { if (baseurl != null) { return baseurl+File. separator+ " files " +File . separator+FileUtilit y. fixedFilename (fixedFiles, filename) ; } else return filename; } catch (NotFound nf) {
Syεtem. err .println (nf) ,- } return filename; } public String htmlFileName (InternalDataObject iobj) { return iobj . getUniqueOid 0 + " .html " ; } public String urlName(InternalDataObject iobj) { if (baseurl != null) return baseurl+File . separator+ "site " +File . separator+htmlFileName ( iobj ) ,- else return htmlFile(iobj ) ; } public String htmlFile(InternalDataObject iobj) {
String htmlDir;
String htmlFileName = htmlFileName (iobj ) ; if (isPagefiobj ) ) { htmlDir=dg.getDirectory( ) +File.separator+"site" ;
} else htmlDir=Environment . getEnv ( "STRUDEL_TMP" ) ; return htmlDir+File. separator+htmlFileName; } public String templateDir ( ) { return dg. getDirectory( ) +File.separator+"htmltemplates" ; } public String collectionTemplate (String name) { return templateDir () +File.separator+"Template. "+name+" .html"; } } * Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitnesε
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ * package HTMLParser; import java . io . * ; import java.util.*; import java . text . * ; import COM. objectspace .jgl.*; import DataRepository.*,- import Util . * ; **
* An ObjectHTMLGenerator materializes each DataObject.
*
* ©author Jaewoo Kang
* ©version 1.00, 09 Sep 1997
* ©see HTMLGenerator
* ©since STRUDEL1.0 */ public class ObjectHTMLGenerator { public HTMLGenerator htmlgen; private String fileHeader (String f) { return "<! — DO NOT EDIT THIS PAGE -->\n"+
"<! — This page is generated by the STRUDEL Web-site management s ystem. —>\n"+
"<! — The HTML template for this page iε derived from:\n"+ " 1. the object-specific template, "+f+", or \n"+
2. the value of the object's \"HTMLtemplate\" attribute, or
\n"+ the template associated with the object's collection. \n"+ If the object belongs to multiple collections, \n"+ a collection template is chosen randomly. \n—>\n\n" ,-
} public ObjectHTMLGenerator (HTMLGenerator gen) { htmlgen = gen; } public String getHTML ( InternalDataOb ect iobj ) throws Exception { boolean success = true ; if (iobj == null) return " " ; if ( !htmlgen.isGenerated(iobj ) ) { success = generateHTML ( iobj ) ; } if (success) return FileUtility. readFile(htmlgen. htmlFiledobj )) ; else return " " ; } public boolean generateHTML (InternalDataObject ob ) { try {
String templatefile = getTemρlateFile(obj ) ; return generateHTML (obj , templatefile); } catch (NotFound nf) {
System.err.println(nf. toStringO ) ; return false; } } public boolean generateHTML (InternalDataObject obj, String file) { boolean εuccess = false;
System, out.println (obj . toString ( ) +" "+file) ,- try {
String htmlFile = htmlgen.htmlFile (obj ) ;
File f = new File (htmlFile) ; if ( f. exists ()) f.deleteO;
PrintWriter pw = new PrintWriter (new FileWriter (htmlFile) ) ; if (htmlgen.isPage(obj ) ) {
DataGraph dg = obj . getGraph ( ) ;
String gname = dg . getName ( ) ,-
String oid = obj . getUniqueOid ( ) ;
String tempname = htmlgen. templateDir () +File. separator+"Object. '+oid+" .html"; pw.println (fileHeader (tempname) ) ; } try {
String output = " " ,-
// Get abεtract εyntax tree for HTML Template
Env env = new Env ( ) ,-
ASTTemplate reεult = HTMLParser .parse (file, this);
// ( ( SimpleNode ) result ) . dump ( " " ) ;
// Bind "this" to current object & Evaluate AST env.push ( "this " , obj ) ; output = result .eval (env) ,- env.pop () ;
// Print result pw.println (output) ,- pw.cloεe( ) ; success = true;
} catch (Exception e) { System, err.printIn (e. toString ( ) ) ; success = false; } } catch (IOException e) {
System. err.println (e. toStringO ) ; εuccesε = false; } htmlgen.wasGeneratedfobj ) ; return success; } public String getTemplateFile ( InternalDataObject obj) throws NotFound
{
DataGraph dg = obj . getGraph ( ) ;
String gname = dg. getName ();
String oid = obj . getUniqueOid () ;
String templatedir = htmlgen. templateDir 0 ;
// Object-specific HTML template
String f = templatedir+File. separator+"Object . "+oid+" .html" ; if (isTemplateOK(f ) ) return f;
// Value of "HTMLte plate" attribute Array objs = obj .outObjects ( "HTMLtemplate" ) ; Enumeration e = objs.elements 0 ; while (e.hasMoreElements () ) {
DataObject dobj = (DataObject) e .nextElement () ;
String file = dobj . toString () ;
// Absolute path or path relative to current directory if (file. indexOf (File. separator) >= 0) f = file; elεe f = templatedir+File. separator+file; if (isTemplateOK(f) ) return f; }
// Collection'ε template
HashSet set = obj .getCollections () ; e = set . elements ( ) ; while (e.hasMoreElements ( ) ) {
DataCollection dc = (DataCollection) e.nextElement () ;
String file = htmlgen. collectionTemplate (dc .getName ()) ; if (isTemplateOK(file) ) return file; } throw new NotFound( "Template for "+obj+" not found."); } public boolean isTemplateOK(String file) { File f = new File(file); if (f. exists ()) { if (f. length () <= 0)
System.err .println ( "Warning: Template , " +f+ " ' is empty. " ) ; return true; } else return false; } }
©
Grammar for HTML template language.
«HTML. jjt»= options {
ERROR_REPORTING = true;
STATIC = false;
USER_CHAR_STREAM = false;
OTHER_AMBIGUITY_CHECK = 1;
BUILD_TOKEN_MANAGER = true;
DEBUG_TOKEN_MANAGER = false;
DEBUG_LOOKAHEAD = false;
USER_TOKEN_MANAGER = false;
LOOKAHEAD = 1;
IGNORE_CASE = false;
FORCE_LA_CHECK = false;
SANITY_CHECK = true;
JAVA_UNICODE_ESCAPE = false;
CHOICE_AMBIGUITY_CHECK = 2;
BUILD_PARSER = true;
DEBUG_PARSER = false;
UNICODE_INPUT = false;
MULTI=true ,-
NODE_FACTORY=true;
NODE_USES_PARSER=true; }
PARSER_BEGIN(HTMLParser) package HTMLParser;
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitneεε
* for a particular purpoεe, and any warrantieε of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ import COM. objectspace . jgl . * ; import java .util.*; import java.io.*; import DataRepository.*; public class HTMLParser { private static int uid = 0; private static Hashtable astcache = new Hashtable ( ) ; public ObjectHTMLGenerator objgen; public HTMLParser (FilelnputStream file, ObjectHTMLGenerator gen) { this (file) ; objgen = gen; } public static ASTTemplate parse (String htmlTemplate, Ob ectHTMLGene rator gen) throws Exception {
ASTTemplate root = (ASTTemplate) astcache. get (htmlTemplate) ; if (root == null) {
FilelnputStream file = new FilelnputStream(htmlTemplate) ; HTMLParser parser = new HTMLParser (file, gen); try { root = (ASTTemplate) parser . Start 0 ; astcache.put (htmlTemplate, root) ; } catch (Exception e) {
System. err.printlnf "Parser error in "+htmlTemplate) ; System. err.println (e. toString ( ) ) ; } } return root; }
// Remove leading and trailing quotes public static String clip (String str) { int len = str .length () ,- if (len >= 2 && str .charAt (0) == "" && str .charAt (len-1) == '"') return str . εubεtring ( 1 , len-1 ) ; elεe return str; } public εtatic String prefixOf (String str, String suffix) { if (str. length() > suffix. length ( ) ) return str.substring(0, str.lengthO - suffix.lengthf ) ) ,- else return " " ; } public static String genVarO { uid++; return "V"+ (Integer. toString (uid) ) ;
} private static ASTForExpr unnestFor (HTMLParser thisparser, ASTForEx pr thisfor, ASTTemplate body, String objvar, ASTAttrExpr attrexpr) { ASTOrder order = thisfor. order; if (attrexpr. attrs. size ( ) > 1) { // Unnest multiple attributes int i , nattrs;
ASTForExpr forexpr = (ASTForExpr) ASTForExpr. j jtCreate (JJTFOREXP R) ; ASTAttrExpr singleattr; nattrs = attrexpr. attrs. size ( ) - 1; for (i = nattrs; i >= 0; ) { forexpr.body = body; forexpr.objvar = objvar; if (i == nattrs) forexpr.predelim = thisfor.predelim; if (i == 0) objvar = attrexpr. objvar; else objvar = genVarO ; singleattr = (ASTAttrExpr)ASTAttrExpr. jjtCreate (thisparser, JJ TATTREXPR) ; εingleattr. objvar = objvar; singleattr. attrs. add (attrexpr. attrs . at (i) ) ; forexpr.attrexpr = singleattr; body = (ASTTemplate) ASTTemplate. j jtCreate (JJTTEMPLATE) ,- body. jjtAddChild( (Node) forexpr, 0) ; i -= 1; if (i == 0) { // Push order expression into deepest SFOR expr forexpr . order = order; forexpr = thisfor; thisfor. order = null; } else forexpr = (ASTForExpr)ASTForExpr. jjtCreate (JJTFOREXPR) ;
} thisfor.predelim = ""; } else { thisfor. objvar = objvar; thisfor .attrexpr = attrexpr; thisfor.body = body; } return thisfor; } public static void main (String [ ] args) throws Exception { Node root, kid; int i; try {
System, out.println (args. length) ,-
FilelnputStream file = new FilelnputStream(args [0] ) ; HTMLParser parser = new HTMLParser (file) ; root = parser . Start ( ) ; { (SimpleNode) root) . dump (" " ) ; for (i = 0; i < root, jjtGetNumChildrenO ; i++) { kid = root. j jtGetChild(i) ; if (kid instanceof ASTTemplate) {
System. out. println ( "ASTTemplate\n" ) ; } else { System. out .println ( "Error ! \n" ) ; } }
System. out .println ( " " ) ; } catch (Exception e) {
System. err. rintln ( "Parser error: "+e. toStringO ) ; } } } PARSER_END (HTMLParser) « Lexical Rules » « Grammar Rules »
« Grammar Rules »= ASTTemplate Start ( ) #void : { } {
Template () { return (ASTTemplate) jjtree.popNode () ; } } void Template ( ) : { } {
( ExtExpr ( )
I HtmlO
)* } void HtmK) : {
Token v; } { v = <HTML>
{ // System. out. rintln ( "*HTML*"+v. image) ; jjtThis . text = . image; } }
« Grammar Rules »= void ExtExpr () #void : {} {
( FmtExpr ( )
I IfExpr ()
I ForExpr ( )
) }
« Grammar Rules »= void FmtExpr ( ) : {
Token v;
ASTFmtExpr t, f = (ASTFmtExpr)ASTFmtExpr. jjtCreate (JJTFMTEXPR) ; ASTForExpr e = null; String prefix; } {
( (v = <SFMT> AttrExprO [ f = Format 0 ] [ e = Enumerate ( ) ] <RBRK> { prefix = prefixOf (v. image, "<SFMT");} ) I (v = <SDOL> AttrExprO [ f = Format ( ) ] [ e = Enumerate 0 ] <RBRK>) { prefix = prefixOf (v. image, "<$");} )
{ t = (ASTFmtExpr) jj tree .popNode ( ) ; if (e != null) {
// Unnest multiple attributes ASTTemplate body = (ASTTemplate) ASTTemplate. j jtCreate (JJTTEMPLA
TE) e.prefix = prefix + e.prefix; e . ob var = genVar ( ) ; f. attrexpr = (ASTAttrExpr) ASTAttrExpr. j jtCreate (this, JJTATTREXP
R) f. attrexpr. ob var = e. objvar; body. jjtAddChiId ( ( ode) f , 0 ) ; e = unnestFor(this, e, body, e. objvar, (ASTAttrExpr) t.jjtGetCh ild(O)),- jjtree .pushNode ( (Node) e) ,- } else { f.prefix = prefix; f. attrexpr = (ASTAttrExpr) t . j tGetChild(O) ; j j tree .pushNode ( (Node) f ) ; } } }
« Grammar Rules »= void IfExpr ( ) :
{
Token begin, end; String sfiεuffix; } {
(begin = <SIF> CondExprO <RBRK> Template 0 [ LOOKAHEAD(l) <SELSE> Template 0 ] end = <SFI>) { jjtThis.prefix = prefixOf (begin. image, "<SIF"); sfisuffix = prefixOf (end. image, "</SIF>"); jjtThis. cond = (ASTCondExpr) jjtThiε. j jtGetChild(O) ; j This. truebody = (ASTTemplate) jj tThis. j jtGetChild(l) ; if (jjtThis. JjtGetNumChildrenO > 2) { jjtThis. falsebody = (ASTTemplate) jjtThis. jjtGetChild{2) ; j tThis. falsebody. εuffix = sfiεuffix; } else jjtThis. truebody. suffix = sfisuffix; . } }
« Grammar Rules »= void ForExpr ( ) :
{
Token begin, o, end;
ASTAttrExpr attrexpr;
ASTOrder order;
ASTTemplate body;
String objvar; } {
(begin = <SFOR> o = <ID> <IN> AttrExprO [ Order () ] <RBRK> Templat e() end = <SROF>) { attrexpr = (ASTAttrExpr) jjtThis. jjtGetChild(O) ; objvar = o. image; if (jjtThis. JjtGetNumChildrenO == 3) { jjtThis. order = (ASTOrder) jjtThis. jjtGetChild(l) ; body = (ASTTemplate) j jtThis. jjtGetChild(2) ; } else body = (ASTTemplate) j jtThis. jjtGetChild(l) ; jjtThis = unnestFor (this, jjtThis, body, objvar, attrexpr); jjtThis.prefix = prefixOf (begin. image, "<SFOR"); jjtThis. body. suffix = prefixOf (end. image, "</SFOR>"); } }
« Grammar Rules »= void AttrExprO : {
Token o, a; } {
(<AT> o = <ID> { jjtThis. objvar = o. image; }) [ (<DOT> (a = <ID> { jjtThis .attrs . add(a . image) ; } ) ) +]
I (a = <ID> { jjtThiε.attrε.add(a.image) ; }) [ (<DOT> (a = <ID> { jjt Thiε. attrs. add (a. image) ; }))+] } void Order () : {
Token t, k; } { <ORDER> <EQ> (t = <ASCEND>|t = <DESCEND>) <KEY> <EQ> k = <ID> { j j tThis . order = t . image . toLowerCase ( ) ; jtThis. key = k. image; } } ©
Second rule is for backward compatibility. << Grammar Rules »= ASTFmtExpr Format ( ) #void: {
Token t;
ASTFmtExpr h = (ASTFmtExpr)ASTFmtExpr . jjtCreate (this, JJTFMTEXPR) ; } {
( (<EMBED> { h. format = "embed"; } I (<TEXT> <EQ> Tag() { h.tags = (ASTTag) j j tree .popNode () ; }) j (<LINK> [<EQ> Tag() { h.tags = (ASTTag) jjtree .popNode 0 ; }])) [ <ARGS> <EQ> Tag() { h.args = (ASTTag) jj tree.popNode 0 ; } ]) { return h; }
} void Tag () : { } {
(String ( ) | AttrExpr () ) * } void StringO: { Token t; } {
(t = <STRING>)
{ jtThis. str = clip (t. image) ; } } ©
« Grammar Rules »= ASTForExpr Enumerate ( ) #void : {
Token t = null, d = null;
ASTForExpr h = (ASTForExpr) STForExpr . j tCreate (this, JJTFOREXPR) ; } {
([ <FORMATxEQ> ] (t = <OL> | t = <UL> | <ENUM>) [<DELIM><EQ> d = <STR ING>] [ Order () ] ) { if (t != null) { h.prefix = "<"+t.image+">" ; h. suffix = "</"+t.image+">" ; h.predelim = "<LI>"; } if (d != null) h.delim = clip (d. image) ,- if (jjtree.nodeArityf ) >= 1 && (j tree.peekNode ( ) instanceof ASTOrd er)) h. order = (ASTOrder) j j tree .popNod 0 ; return h; }
}
« Grammar Ruleε »= void CondExprO : {} {
OrExpr ( ) }
« Grammar Rules »= void OrExpr ( ) : { } {
( AndExprO ( L00KAHEAD{2) <OR> OrExpr ( ) )*
) }
« Grammar Rules »= void AndExpr ( ) : { Token t = null; } { [ t = <NOT> ] ( RelExprt)
I <LPAREN> CondExprO <RPAREN>) ( LOOKAHEAD (2 ) <AND> AndExpr ( ) ) * ) { if (t != null) jjtThis.negate = true; } } void RelExpr( ) : {
String op = " ! = " ,-
} {
(TermO [ op = RelOp () Term() ])
{ j j tThis. left = (ASTTerm) j jtThis . jjtGetChild(O) ; if ( jjtThis. j jtGetNumChildrent ) > 1) { j j tThis .op = op; jjtThis. right = (ASTTerm) jjtThis . jtGetChild(l) ; }
void TermO : {}
AttrExprO I Constant ( )
void Constant ( ) Token t;
(t = <BOOLEAN> { jjtThis.value = new BoolDataValue (t. image) ; })
(t = <INTEGER> { jjtThis.value = new IntDataValue (t. image) ; })
(t = <FLOATING_POINT> { j tThis .value = new FloatDataValue ( t . image) ; )
(t = <STRING> { jjtThis.value = new StringDataValue (clip (t. image) ) ; }
(<NULL> { jjtThis.value = new NullDataValue () ; })
String RelOp ( ) #void :
Token t;
(t = <LT> I t = <EQ> I t = <LE> <GE> t = <NE>) { return t. image; }
« Lexical Rules »= TOKEN_MGR_DECLS : static int curline = 0; static String curfile = © We start out in raw HTML text.
<< Lexical Rules »=
TOKEN [IGNORE_CASE] : /* Raw HTML text */
{
< SIF "<SIF" > : STRUDEL
< SFOR "<SFOR"> : STRUDEL
< SDOL "<$" > : STRUDEL
< SFMT "<SFMT"> : STRUDEL
< SELSE "<SELSE>" >
< SFI "</SIF>" >
< SROF "</SFOR>" >
}
« Lexical Rules »=
MORE : /* Raw HTML text */
{
< ("<" ["\n", "\r", "\f" ]) >
}
TOKEN [IGNORE_CASE] /* Raw HTML text */
{
< HTML : ["\n", "\r", "\f " ]>
}
« Lexical Rules »=
<STRUDEL> SKIP : /* WHITE SPACE */
{
"\t" "\n" { curline++; /* update line number here */ } "\r" "\f "
}
<STRUDEL> TOKEN [IGNORE_CASE] : /* In Strudel Extension */
{ /* RESERVED WORDS AND LITERALS */
< AND: "AND">
< ARGS: "ARGS">
< ASCEND: "ASCEND">
< AT: "©" >
< BOOLEAN : ("true" | "false" ) >
< DESCEND: "DESCEND">
< DELIM: "DELIM">
< DOT : " . " >
< EMBED: "EMBED">
< ENUM: "ENUM">
< FORMAT: "FORMAT">
< IN: "IN">
< KEY: "KEY">
< LINK: "LINK">
< LPAREN: " (" >
< NOT: "NOT">
< NULL: "NULL">
< OR: "OR"> < ORDER: "ORDER">
< OL: "OL">
< RPARE : " ) " >
< TEXT: "TEXT">
< UL: "UL">
}
« Lexical Rules »=
<STRUDEL> TOKEN : /* IDENTIFIERS */
{
< ID: <LETTER> (<LETTER> | <DIGIT>) * >
I < #LETTER : [ "a" -" z ", "A"- "Z" ,"_","-" ] >
I < #DIGIT : ["0"-"9"] >
}
« Lexical Rules »=
<STRUDEL> TOKEN : /* LITERALS */
{
< INTEGER:
<DECIMAL> I <HEX> j <OCTAL> >
I
< #DECIMAL: [ "1" -" 9 " ] ( [ " 0 " - "9 " ] ) * >
I
< #HEX: "0" ["x","X"] ( ["0"-"9" , "a"-"f", "A"-"F"] )+ >
I
< #OCTAL: " 0 " ( [ " 0 "- "7 " ] ) * >
< FLOATING_POINT:
(["0"-"9"])+ "." ( ["0"-"9"])* (<EXPONENT>)? ( [ " f " , "F" , "d" , "D" ] ) p
I "." ( ["0"-"9"])+ ( <EXPONENT> ) ? ( [ " f " , "F" , "d" , "D" ] ) ? j ( ["0"-"9"] )+ <EXPONENT> ( [ " f " , "F" , "d" , "D" ] ) ? j ( ["0"-"9"] )+ (<EXPONENT>) ? [ " f " , "F" , "d" , "D" ] >
I
< #EXPONENT: ["e","E"] (["+" ,"-"]) ? (["0"-"9"])+ >
I
< STRING:
( (~["\"","\\","\n", "\r"] ) I C\\"
( ["n", "t", "b", "r", "f ", "\\", " '" , "\""] I [»0"-"7"] ( ["0"-"7"] )? j [ » o " - " 3 " ] [ " 0 " - " 7 " ] [ " 0 " - " 7 " ] ) ) )*
>
} <STRUDEL> TOKEN OPERATORS */
{
< LT " < " >
| < EQ j < LE ' <= " > j < GE ">=" > j < NE
}
<STRUDEL> TOKEN : /* End of Extension Tag */
{
< RBRK : " > " > DEFAULT
}
/*
* Copy~rrii rgrhhtt- 119 Q97 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledgeε and agreeε th¬ at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package Optimizer; import COM.objectspace. jgl. *,- import java . lang . * ; import java .util . * ; import java . io . * ; import Querylnterpretor . * ; import Automata . * ; public abεtract claεε AtomicQEP extendε QEP {
/* Constructor */ public AtomicQEP(){ super ( ) ; name="AtomicOperation" +number,- time=0; nb_tuples_exec=0 ; nb_tuples_prod=0 ; } /* Display Methodε */
/* Get Methods */ public long getTime(){ return time; } public int getNbTuplesΞxec ( ) { return nb_tuples_exec; } public int getNbTuplesProd() { return nb_tuples_prod; }
/* Optimization methods */ public boolean equal (Object q) { return this==q; }
/* Execution methods */ public abstract void profile (PrintStream out, long totaltime, int nb _tuples) ,- public abstract Array consume (Binding b) throws Exception; public Array execute (Binding b) throws Exception{
Date initialTime=new Date 0 , finalTime;
Array result=consume(b) ; finalTime=new Date ( ) ; time=time+finalTime . getTime ( ) -initialTime . getTime ( ) ; nb_tuples_exec++; nb_tuples_prod=nb_tuples_prod+result . size ( ) ; return result; }
/* Data*/
/* Profile Data */ protected long time; protected int nb_tuples_exec; protected int nb_tuples_prod; } /*
* Copyright 1997 AT&T Labs -- Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package Optimizer; import COM.objectspace. jgl ."*,- import java . lang. * ; import java.util.*; import java . io . * ; import Querylnterpretor . * ; import Automata. * ,- public class BuiltlnOperation extends AtomicQEP {
/* Constructor */ public BuiltlnOperation (Operation o) { super ( ) ; name="BuiltlnOperation" +number; operation=o; }
/* Methods */ public String toString ( ) { return operation. toString ( ) ,- }
/* Execution Methods */ public Array consume (Binding b) throws Exception{ return operation. execute (b) ; } public void toDot (PrintStream out) { out. rintln (name+" [label=\" "+operation+" \ " , style=filled, color=lig htblue] ,- ") ; } public void profile (PrintStream out, long totaltime, int nb_tuples) { out.println ( "Operation "+operation) ,- out.printlnC Running time: "+operation. getTime ( ) +"mε . "+(((f loat) (operation. getTimeO ) /totaltime) *100)+"% of total time."); out.printlnC Nb Tuples executed: " +operatio . getNbTuplesExec () + " " + ( float ) ( ( ( float) (operation . getNbTupl esExec () ) /nb_tupleε) *100) + "% of total number of tuples.".); out.printlnC Nb Tuples produced: "+oρeration.getNbTuρlesProd() +" "+(( (float) (operation. getNbTuplesProdt) ) /nb_tuples) *100) +"% of tot al number of tuples. "); out.println( " Running time/tuple: "+( (float) (operation. getTime ( ) ) / (float) (operation. getNbTupleεExec () ) )+" .mε" ) ; out .println ( " Fan-out : "+ ( ( float) (operation. getNbTupleεProd() ) / (float) (operation. getNbTuplesExec ()))); }
/* Data*/
Operation operation; } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and uεing the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research." The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* "for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code . */ package Optimizer; import COM. objectspace . jgl . * ,- import java . lang. * ; import java.util.*; import java . io . * ; import Querylnterpretor . * ,- import Automata . * ; public class ConstructedQEP extends QEP {
/* Constructor */ public ConstructedQEP ( ) { super ( ) ; initialize ( ) ; } private void initialize (){ name= "ConstructedQEP"+number; time=0; nb_tuples_exec=0 ; nb_tupleε_tranεit=0 ; nb_tuples_prod=0 ; links=new HashMap(true) ; subQEP=new Array( ) ; } public void addSubPlan(QEP q) { subQEP.add(q) ; } public void addOperation (BuiltlnOperation o) { subQEP.add(o) ; }
// Extend plan by adding link from ql -> q2 public void extend(QEP ql, BuiltlnOperation q2) { addOperation (q2 ) ; addLink(ql, q2); } public void addLink(QEP ql, QEP q2){ links . ad ( l , q2 ) ; } public void putInput(QEP q) { input=q; } public void putOutput (QEP'q) { output=q; }
/* Display Methods */ public void toDot (PrintStream out) { Enumeration iterl=subQEP . elements ( ) ; while ( iterl . hasMoreElements ( ) ) {
QEP ql= ( (QEP) (iterl .nextElement 0 ) ) ; ql . toDot (out) ;
QEP q2=ql . getOutput ( ) ;
String label=" { " ; if (q2. getBoundVariables ( ) ! =null ) {
Enumeration iter=q2. getBoundVariables ( ) . elements ( ) ; boolean first=true; while (iter .hasMoreElements 0 ) { if ( ifirst) label=label+" , " ; label=label+ ( ( Symbol ) ( iter .nextElement ( ) ) ) . getName ( ) ; first=false; } } label=label+"}";
Enumeration iter2=links.values (ql) ; while (iter2.hasMoreElements ( ) ) {
QEP q3= ( (QEP) (iter2.nextElement ( ) ) ) ; QEP q4=q3. getlnput ( ) ,- out.println (q2.getNameO +" -> " +q4. getName ()+ " [label=\ " "+label +"\"] ;") ; }
/* Get Methods */ public Array getSubPlans ( ) { return subQEP; } public QEP getlnput ( ) { return input; } public QEP getOutput ( ) { return output; } public HashMap getLinks ( ) { return links; } public long getTime ( ) { return time; } public int getNbTuplesExec ( ) { return nb_tuples_exec ; } public int getNbTuplesProd() { return nb_tuples_prod; }
/* Optimization methods */ /* Execution methods */ public void run (PrintStream profilefile) throws Exception{ execute (new Binding ( ) ) ; if (profilefile != null) { profile (profilefile) ,- // profile (System. out) ; } } public Array execute (Binding b) throws Exception{ nb_tuples_exec++ ; Date initialTime=new Date ( ) ; Array result=new ArrayO; java.util. Stack stack=new java.util .Stack( ) ; stack.push (new Pair(b, input) ) ;
Pair currentPair=null;
Binding bl , b2 ;
QEP ql, q2;
Enumeration iterl, iter2; while ( ! stack. isEmpty () ){ currentPair= ( (Pair) (stack.popO ) ) ,- nb_tuples_transit++; bl= ( (Binding) (currentPair. first) ) ; ql=( (QEP) (currentPair. second) ) ;
Array setl=ql. execute (bl) ; iterl=setl . elements ( ) ; while (iterl .hasMoreElements ( ) ) { b2=( (Binding) (iterl.nextElement ( ) ) ) ; if (ql==output) result .add(b2 ) ; else{ iter2=links.valueε (ql) ; while (iter2.hasMoreElements ( ) ) { q2= ( (QEP) (iter2.nextElement ( ) ) ) ; stack,push(new Pair(b2, q2)),- } } } } time=time+ (new Date ( ) ) . getTime ( ) -initialTime . getTim ( ) ; nb_tuples_prod=nb_tuples_prod+result . εize ( ) ; return result;
public void profile (PrintStream out) {
// these are informations only for the operations in this QEP -non cumulative . out. rintln ( ' "Profiling information for constructed QEP.") out.printlnt ' "Total time: "+time+" ins."); out.println( ' "Total number of tuples: "+nb_tuples_transit) out.println ("Fan-out: "+( (float) (nb_tuples_prod) / (float) (nb_tuples_ exec) ) ) ; out.println ( "Detailed informations about each operation:"); Enumeration iter=subQEP . elements ( ) ; while (iter .hasMoreElements 0 ) {
QEP op=( (QEP) (iter.nextElementO ) ) ; if (op instanceof AtomicQEP)
( (AtomicQEP) op) .profile (out, time, nb_tuples_transit );
}
/* Data*/ protected Array subQEP; // list of QEP protected HashMap links; // list of pairs QEP->QEP protected QEP input; protected QEP output;
/* Profile Data */ protected long time; protected int nb_tuples_exec; protected int nb_tuples_prod; protected int nb_tuples_transit;
* Copyright 1997 AT&T Labε — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp. , and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitnesε
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratorieε
* with reports of any errors, defects or suggeεtions for change and
* improvements to the code. */ package Optimizer,- import COM.objectspace. jgl. *; import java. lang. * ; import java.util.*; import java. io . * ; import Automata . * ; import DataRepository.*,- import Querylnterpretor . * ; import QueryParser . * ; public class Optimizer { public static QEP optimize (Query q) throws RuntimeException, Exceptio n {
HashSet inGraphs = q . inGraphs ( ) ;
StoredDataGraph outGraph = ( (StoredDataGraph) (DataRepository. isGrap h (q. outGraph ()))),- if (outGraph==nul1 ) outGraph = DataRepository.addStoredGraph (new StoredDataGraph (q.ou tGraph ( ) ) ) ; q.putlnputGraphs (inGraphs) ; q. putOutputGraph (outGraph) ;
ConstructedQEP result = null; try{ result = optimize ({ (cQueryBlock) (q.cbodyO )) , inGraphs, outGraph, null, null) ,- result .putOutput (null ) ; return result; } catch (Exception e) {
Syεtem. err.println ( "Optimizer exception: "+e. toStringO ) ; e .printStackTrace ( ) ,-
DataRepository. deleteStoredGraph (outGraph) ; throw e; } } public static ConstructedQEP optimize (cQueryBlock body, HashSet inGra phs, StoredDataGraph outGraph, ConstructedQEP oldplan, QEP lastOper) th rows RuntimeException{
System. out.println ( "Optimizing a new block") ; if (lastOper != null) {
System. out.println ( "Last operation of the previous one: "+lastOper
);
System. out.println ( "Bound variables: "÷laεtOpe . getBoundVariableε ( ))
} else System, out.println ( "No last operation"),-
/* Initialize query variables */
HashSet memConditions = body.cMemConditions ( ) ;
HashSet conditions = body.cCondition( ) ; //superset of "memConditions
HashSet automata = body.getAutomataO ;
/* Initialize usual variables */ Array fragments = new Array ( ) ; ConstructedQEP plan; Automata currentAutom = null; HashSet boundVariables = null; /* Initialize this plan, using last operation in old plan, if one e xists */ plan = initializePlan (oldplan, lastOper, conditions, memConditionε, boundVariables , fragments) ;
/* Create scan operation for each membership condition */ createScans (plan, inGraphs, conditions, memConditionε, boundVariabl eε, fragments) ,-
/* Loop until no more automatas */ while (! automata. isEmpty () ) {
QEP currentFragment = null; int nb_currentFragment ;
/* Choose a fragment to continue and an automata that can continu e this fragment */ for (nb_currentFragment = 0; nb_currentFragment < fragments .εize ( ) ; nb_currentFragment++) { currentFragment = ( (QEP) ( fragments. at (nb_currentFragment) ) ) ;
System. out.printlnt "Trying fragment: " +currentFragment ) ; Syεtem. out.printlnt "Bound variableε: "+currentFragment .getBound Variables ( ) ) ;
System. out.println ( "Automatas are: "+automata) ; System. out.println ( "Conditions are : "+conditions) ; currentAutom = selectAut (automata, conditions, currentFragment. getBoundVariables () ) ; if (currentAutom != null) break; }
/* if there iε no continuation point */ if (currentAutom == null) throw new RuntimeException ( "Query non-safe !"); else { currentFragment = processAutomata(plan, inGraphs, conditions, c urrentAutom, currentFragment) ; fragmentε.put (nb_currentFragment, currentFragment) ,- automata . remove (currentAutom) ; } }
/* Create joins between remaining fragments that share common varia bles */ joinFragments (plan, fragments);
/* Create cartezian products between remaining fragments that do no t share variables */ cartezianProducts (plan, fragments) ;
QEP lastOperation; if (fragments. size () == 0) { // Empty WHERE clause lastOperation = plan. getlnput () ; boundVariables = new HashSet ( ) ; boundVariables . add (UnitOperation.unit ) ; } else { lastOperation = (QEP) fragments . at ( 0 ) ; boundVariableε = lastOperation. getBoundVariables () ; }
/* Inject filters at end of block for remaining conditions on bound variables */ lastOperation = applyFilter (plan, conditions, lastOperation, boundV ariables, boundVariables) ; if (! conditions. isEmpty () ) throw new RuntimeException ( "There exiεt unapplicable filters: "+c onditions) ;
/* Consume results in LINK & COLLECT Clauses */ Array projects = new ArrayO ; consumeClauεes (plan, outGraph, body .getLinkClauses () .elements () , pr ojects, lastOperation, boundVariables); consumeClauses (plan, outGraph, body.getCollectClauses ( ) .elementsO, projects, lastOperation, boundVariables) ; plan.putOutput (lastOperation) ;
/* Optimize sub-blocks */
Enumeration iter = body.getCleanQueryBlocks ( ) .elementε ( ) ; while (iter . hasMoreElements ( ) ) optimize ( ( (cQueryBlock) (iter .nextElement ( ) ) ) , inGraphs, outGraph, plan, lastOperation) ; return plan; } private static ConstructedQEP initializePlan (ConstructedQEP oldplan, QEP lastOper, HashSet conditions, HashSet memConditions, HashSet boundV ariables, Array fragments) {
ConstructedQEP plan;
Enumeration iter; if (oldplan != null) { plan = oldplan; boundVariableε = (HashSet) lastOper. getBoundVariables () .clone () ;
/* Create Filter at the beggining of the block */ lastOper = applyFilter (plan, conditions, laεtOper, boundVariables , boundVariables) ; fragments. add(lastOper) ; } else {
BuiltlnOperation init; plan = new ConstructedQEP { ) ;
// First block and there are collections to scan if (!memConditions. isEmpty() ) { init = new BuiltlnOperation (new InitiateScan( ) ) ;
System. out.println ( "Create initial scan"); // First block is empty -- use Unit() operation } else init = new BuiltlnOperation (new UnitOperationO ) ; init .putBoundVariables (new HashSet ( ) ) ; plan. addOperation (init) ,- plan.putlnput (init) ; } return plan; } private static void createScans (ConstructedQEP plan, HashSet inGraphs , HashSet conditions, HashSet memConditions, HashSet boundVariables, Ar ray fragments) {
DataCollection col;
Enumeration iter = memConditions. elements () ;
BoolExprPred cond; while ( iter.hasMoreElements () ) { cond = ( (BoolExprPred) (iter .nextElement () ) ) ;
Symbol var = ( (Symbol) ( ( (ValueExprVar) (cond. getSubExprs ( ) [0] ) ) .ge tSymbol ( ) ) ) ; memConditionε . remove (cond) ,- conditions . remove (cond) ; col = getCollection (inGraphs, cond. getPredName ( )) ; if (col == null) throw new RuntimeException ( "Non-existent collection as starting point : " +cond. getPredName ( ) ) ;
BuiltlnOperation scan = new BuiltlnOperation (new ScanOperation (v ar, col)),- fragment . add ( scan) ; plan. extend(plan. getlnput ( ) , scan) ; boundVariables = new HashSet ( ) ; boundVariableε. add (var) ; scan.putBoundVariables ( ( (HashSet) (boundVariables. clone ()))); } } private static DataCollection getCollectiontHashSet graphs, String na me) {
Enumeration iter=graphs . elements ( ) ; while (iter.hasMoreElements () ) {
StoredDataGraph g = ( (StoredDataGraph) (iter.nextElement ())) ; DataCollection c = g. getCollection (name) ,- if (c!=null) return c; } return null; }
// getAttribute () assumes that the names of attributes in DataGraphs are disjoint,
// which is wrong. The εolution is to hack DataEdge. isAttribute to t st for
// name equality instead of identity equality of attributes, private static DataAttribute getAttribute (HashSet graphs, String name ) {
Enumeration iter = graphs .elements ( ) ; while (iter .hasMoreElements () ) {
StoredDataGraph g = ( (StoredDataGraph) (iter.nextElement ())) ; DataAttribute c = g. getAttribute (name) ; if (c!=null) return c; } return null; }
// Return an automata whose input state is bound:
// If there are multiple choices, choose one that has a filter on itε output state // Null if no choices public static Automata selectAut (HashSet automata, HashSet conditions , HashSet boundSymbols) { Enumeration iter; Automata a; Symbol variable; iter = automata. elements () ; HashSet choices = new HashSet ( ) ; while (iter.hasMoreElements () ) { a = (Automata) (iter.nextElement ( ) ) ,- variable = ((State) (a. getlnputState () ) ) .getVar ( ) ; if (boundSymbols. count (variable) > 0) { choices . add (a) ,-
HashSet boundVariables = ( (HashSet) (boundSymbols. clone ())) ; boundVariables . add ( ( (State) (a. getOutputState ( ) ) ) .getVarO ) ; HashSet applicCond = getApplicableConditions (conditions, boundVa riables) ; if (!applicCond. isEmpty() ) return a; } } if (choices . elements ( ) .hasMoreElements ( ) ) return (Automata) choices . elements ( ) . nextElement ( ) ; else return null; }
// Return all the conditions that can be applied given the boundVaria bles public static HashSet getApplicableConditions (HashSet conditions, Has hSet boundVariables) { Enumeration iterl; HashSet answer = new HashSet ( ) ; BoolExpr_INT elem; iterl = conditions . elements () ; while (iterl.hasMoreElements () ) { elem = ( (BoolExpr_INT) iterl .nextElement ()) ; HashSet vars = elem. getVars () ; if (vars . subsetOf (boundVariables) ) answer .add(elem) ; else {
System. err.println ( "NO APPLICABLE CONDITIONS");
System. err.println ( "vars - boundVars = "+vars. difference (boundV ariables) ) ;
System.err .printIn ( "boundVars - vars = "+boundVariableε.differe nee (vars) ) ; } } return answer; } public static Object commonElement (HashSet setl, HashSet set2) { Enumeration iterl, iter2; Object tmp; iterl = setl . elements ( ) ; while ( iterl . hasMoreElements 0 ) { tmp = iterl.nextElement () ; if (set2.get (tmp) != null) return tmp; } return null; } private static Pair processLink (ConstructedQEP plan, Link link, HashS et inGraphs, HashSet arcs, HashSet conditions, HashSet vars) {
BuiltlnOperation join; BuiltlnOperation currentLastOp = null;
UnaryBoolExpr_INT arcCond = link. getLabel 0 ;
State fromState = ( (State) (link. getlnputState ( ))) ,-
Symbol fromVar = fromState . getVar ( ) ,-
Symbol toVar = ( (State) ( link. getOutputState ( ) ) ) .getVarO ; varε . add ( fromVar) ,- varε .add(toVar) ;
/* Build the dependent join */ if (arcCond instanceof UnaryBoolExprEps) join = new BuiltlnOperation (new ExpandOperationtfromVar, toVar) ) ; else if (arcCond instanceof UnaryBoolExprTrue) join = new BuiltlnOperation (new FDJoinOperation(fromVar, toVar) ) ; else if (arcCond instanceof UnaryBoolExprConst) {
DataValue value = ( (UnaryBoolExprConst) arcCond) .getValue () ,- if (value instanceof StringDataValue) {
DataAttribute a = getAttribute ( inGraphs , value . toString ( ) ) ; if (a == null) throw new RuntimeException ( "Non-existent attribute '"+value.t oString ( ) + " ' in input graphs . " ) ; join = new BuiltlnOperation (new DJoinOperation( fromVar, toVar, a));
} else throw new RuntimeException ( "Bad UnaryBoolExpr on an arc 1"
);
} else if (arcCond instanceof UnaryBoolExprVar) {
Symbol arc = (Symbol) ( ( (UnaryBoolExprVar) arcCond) . getSymbol 0 ) ; if ( ! arc . isGenerated ( ) ) arcs. add (arc) ; join = new BuiltlnOperation (new GDJoinOperation ( fromVar, toVar, a re)); vars . add(arc) ;
HashSet newArc = new HashSet ( ) ; newArc . add(arc) ,- currentLastOp = (BuiltlnOperation) applyFilter (plan, conditions, join, newArc, varε) ;
} else throw new RuntimeException ( "Bad UnaryBoolExpr on an arc 2"); join.putBoundVariables (varε) ; plan. addOperation (join) ; if (currentLastOp == null) currentLastOp = join; return new Pair (join, currentLastOp) ; } private static void connectFragments (ConstructedQEP plan, Array fragm ents, int i, int j, BuiltlnOperation opl, BuiltlnOperation op2) {
QEP fi = (QEP) fragments. at (i) ; QEP fj = (QEP) fragmentε. at (j) ,- plan . extend ( fi , opl ) ; plan . extend( fj , op2 ) ;
BuiltlnOperation union = new BuiltlnOperation (new UnionOperation ( ) ) plan. extend (opl, union); plan.addLink(op2, union);
HashSet bVars = fi . getBoundVariables ( ) .union ( f . getBoundVariables ( ) ); union.putBoundVariableε (bVars) ; opl .putBoundVariables ( ( (HashSet) (bVars . clone ()))); op2.putBoundVariables ( ( (HashSet) (bVars . clone ()))); fragment . ut ( i , union) ,- fragments .remove (j ) ; } private static void consumeClauses (ConstructedQEP plan, StoredDataGra ph outGraph, Enumeration clauses, Array projects, QEP lastOperation, Ha shSet boundVariables) { while (clauses.hasMoreElements () ) {
Consume_INT ce = (Consume_INT) clauseε.nextElement () ; HashSet variables = ce . getVars ( ) ; BuiltlnOperation op = ce. toBuiltlnOp (outGraph) ; if ( !variables . subsetOf (boundVariables) ) throw new RuntimeException ( "Unapplicable clause: "+ce) ; if (variables . isEmpty( ) ) variables = (HashSet) boundVariables . clone ( ) ; consumeResult (plan, projects, variables, op, lastOperation); } } private static void consumeResult (ConstructedQEP plan, Array projects , HashSet variables, BuiltlnOperation oper, QEP laεtOperation) { boolean foundproject = false; HashSet set2;
// Search for project clause that binds this operation's variables Enumeration iter=projects . elements ( ) ; while (iter. hasMoreElements () ) {
BuiltlnOperation good= ( (BuiltlnOperation) (iter. nextElement () ) ) ; set2 = good. getBoundVariables () ,-
// It is possible that a link/collect clause has no bound variabl es.
// In that case, any project operation will do if (variables. ubsetOf (set2) && set2.subsetOf (variables) ) { plan. extend (good, oper) ; foundproject = true; break; }
}
// No project clause exists, create one if (! foundproject) {
BuiltlnOperation ρroject=new BuiltlnOperation (new Pro ectOperatio n (variables) ) ; project .putBoundVariables (variables) ;
BuiltlnOperation removeDup=new BuiltlnOperation (new RDOperation(v ariables) ) ; removeDup.putBoundVariableε (variables) ; plan. extend (project, removeDup) ; plan. extend(removeDup, oper) ; plan. extend (lastOperation, project) ; projects . add(removeDup) ; } } private static void cartezianProducts (ConstructedQEP plan, Array frag ments) {
/* Create cartezian products between remaining fragments */ for (int i = fragments . size ( ) -1; i >=1; i— ) {
Array HI = new Array() , H2 = new Array( ) ;
BuiltlnOperation cpl=new BuiltlnOperation (new CartProdOperation(H 1, H2));
BuiltlnOperation cp2=new BuiltlnOperation (new CartProdOperation(H
2, HI)); connectFragments (plan, fragments, i-1, i, cpl, cp2); } } private static void joinFragments (ConstructedQEP plan, Array fragment s) { boolean foundJoin = true; Symbol varO = null; while (fragments. size ( )>1 && foundJoin) { int i=0,j=0; foundJoin = false; for(i=0; i < fragments. size () && IfoundJoin; i++) { for(j=0; j < fragments, size ( ) && IfoundJoin,- j++) { if (i != j) { varO = ( (Symbol) (commonElement ( ( (QEP) ( fragments. at (i) ) ) .get BoundVariables ( ) , ( (QEP) (fragments. at (j ) ) ) . getBoundVariables () ) ) ) ; if (varO != null) { foundJoin = true; break; } } } if (foundJoin) break; } if (foundJoin) {
/* Create join between fragments i and j */ HashMap HI = new HashMap (true) , H2 = new HashMap ( true) ; BuiltlnOperation joinl=new BuiltlnOperation (new JoinOperation(v arO ,varO , HI , H2 ) ) ;
BuiltlnOperation join2=new BuiltlnOperation (new JoinOperation(v arO , varO , H2 , HI ) ) ; connectFragmentε (plan, fragments, i, j, joinl, join2); } } } private static QEP applyFilter (ConstructedQEP plan, HashSet condition s, QEP currentFragment, HashSet filterVars, HaεhSet boundVarε) {
HashSet applicCond = getApplicableConditions (conditions, filterVars ); conditions. copy(conditions.difference (applicCond) ) ; Enumeration iter = applicCond.elements () ,- while ( iter .hasMoreElements ( ) ) {
BuiltlnOperation filter = new BuiltlnOperation (new FilterOperatio n ( ( (BoolExpr_INT) (iter .nextElement ())))); filter.putBoundVariables ( (HashSet) boundVars . clone () ) ; plan.extend(currentFragment, filter) ; currentFragment = filter; } return currentFragment; } private static QEP processAutomata (ConstructedQEP plan, HashSet inGra phs, HashSet conditions, Automata currentAutom, QEP currentFragment) { HashSet boundVariables = currentFragment . getBoundVariables ( ) ,- State inputState = ( (State) (currentAutom. getlnputState () )) ; State outputState = ( (State) (currentAutom. getOutputState ( ))) ; Symbol inputVar = inputState .getVar ( ) ; Symbol outputVar = outputState . getVar ( ) ; HashSet stateε = currentAutom. getStateSet 0 ; HashSet unionStates = currentAutom. getUnionStateε () ;
Haεhtable producedBy = new Hashtable ( ) ; Hashtable unionsBy = new Hashtable { ) ; HaεhMap conεumedBy = new HashMap (true) ; HashSet boundArcs = new HashSet ( ) ;
/* Iterate over all the union stateε and create unions */ Enumeration iter = unionStates .elements () ; while ( iter.hasMoreElements () ) {
State s = ( (State) (iter.nextElement ( ) ) ) ;
Symbol εym = ε. getVar ();
BuiltlnOperation union = new BuiltlnOperation (new UnionOperationt ));
HaεhSet vars = ( (HashSet) (boundVariables. clone ())) ; vars . add(sym) ; vars . add ( inputVar) ,- union.putBoundVariables (vars) ; plan. addOperation (union) ;
BuiltlnOperation removeDup = new BuiltlnOperation (new RDOperation (vars) ) ; removeDup.putBoundVariables (vars) ; plan. extend(union, removeDup); producedBy.put ( s , removeDup) ; unionsBy.put (ε, union); }
/* Link old QEP and beginning of the automata */ if (unionStates. count (inputState) == 0) producedBy.put (inputState, currentFragment) ; else plan. addLink(currentFragment, ( (QEP) (unionsBy.get (inputState) ) ) ) ;
/* Process all links in automata */ iter = currentAutom.getLinkSet ( ) . elements ( ) ; while ( iter . hasMoreElements 0 ) {
Link link = ( (Link) (iter .nextElement ())) ;
State toState = ( (State) (link.getOutputState ())) ;
State fromState = ( (State) (link. getlnputState 0 )) ; Pair p = processLink(plan, link, inGraphs, boundArcs, conditions, (HashSet) (boundVariables.cloneO ) ) ;
BuiltlnOperation join = (BuiltlnOperation) (p. first) ; BuiltlnOperation currentLastOp = (BuiltlnOperation) (p. second) ;
/* Make all the links */ consumedBy.add(fromState, join) ,-
BuiltlnOperation oper = ( (BuiltlnOperation) (unionsBy.get (toState)
)) if (oper == null) producedBy.put (toState, currentLastOp) ; else plan.addLink (currentLastOp, oper) ;
}
/* Make the final links producer->conεumer for all εtateε */ iter = stateε. element () ; while ( iter. hasMoreElements () ) {
State state = ( (State) (iter.nextElement ())) ;
BuiltlnOperation fromOper = ( (BuiltlnOperation) (producedBy. get (st ate) ) ) ;
Enumeration iter2 = consumedBy.values (state) ; while (iter2.hasMoreElements ( ) ) {
BuiltlnOperation toOper = ( (BuiltlnOperation) (iter2.nextElement ( ) ) ) ; plan. addLink (fromOper, toOper) ; } }
/* Determine the output of the automata */ currentFragment = (BuiltlnOperation) producedBy. get (outputState) ,-
HashSet Bvars = boundVariables.union (boundArcs) ;
Bvars . add(outputVar) ; currentFragment.putBoundVariableε (Bvars) ;
/* Build the projection at the end of the automata */ boundVariables = currentFragment . getBoundVariables ( ) ,- if ( ! currentAutom. isSimple () ) {
HashSet vars = (HashSet) (boundVariables.cloneO ) ;
BuiltlnOperation proj = new BuiltlnOperation (new ProjectOperation (vars) ) ; proj .putBoundVariables (vars) ,- pla . extend (currentFragment , proj ) ; currentFragment = proj ;
}
/* Create Filter at the end of the automata */ boundVariables = currentFragment .getBoundVariables ( ) ; currentFragment = applyFilter (plan, conditions, currentFragment, bo undVariables , boundVariables) ; return currentFragment ; /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitneεε
* for a particular purpoεe, and any warrantieε of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defectε or suggestions for change and
* improvements to the code. */ package Optimizer; import COM.objectspace. jgl. *; import java . lang . * ; import java.util. *; import java . io . * ; import Automata . * ; import Querylnterpretor. * ; import Util . Environment ; public abstract class QEP {
/* Constructor */ QEPO { number++ ,- name= "QEP" +number; boundVariables=null ; } public void putBoundVariable (HaεhSet vars) { boundVariables=vars ; }
/* Get Methods */ public String getName (){ return name; } public HashSet getBoundVariables () { return boundVariables; } public QEP getlnput () {//overwritten in ConstructedQEP and QueryQEP return this; } public QEP getOutput () {//overwritten in ConstructedQEP and QueryQEP return this; }
/* Optimization methods */
/* execution Methods */ public void run (PrintStream profile) throws Exception{/ /overwritten i n ConstructedQEP throw new RuntimeException ( "Try to run a non-constructed QEP."); } public abstract Array execute (Binding b) throws Exception; public void print (PrintStream out) { out .println ( "digraph QEP {\n center=true; \n concentrate=true; \n col or=lightblue; \n rankdir=BT; " ) ,- toDot (out) ; out .println ("}"); } public abstract void toDot (PrintStream out);
/* Data*/ protected String name; protected HashSet boundVariables;
/* Static stuff.. */ protected static int number = 0;
} /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code εolely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package Querylnterpretor; import COM.objectspace. jgl. *,- import java . lang . * ; import java.util.*; import java. io . * ; import DataRepository. * ; import Automata . * ; public class Binding{ /* Constructors */ public Binding ( ) { table=new Hashtable ( ) ; } private Binding (Hashtable t) { table=t ; }
/* Display methods */ public String toStringO { String result="{"; int i=0;
Enumeration iter=table .keys ( ) ; while (iter.hasMoreElements 0 ) { Object var=iter.nextElement () ,- if ((i++)==0) result=result+var+"/"+table.get (var) ; elεe result=result+" , "+var+"/ "+table.get (var) ,-
} result=result+ " } " ; return result ; } /* Put Methods */ public Binding put (Symbol var, DataObject val) throws RuntimeExcepti on{ if ( ( Ivar.isNodeVariableO ) && ( ! val . getType () .equals ("String" ) ) ) throw new RuntimeException ("Bad binding for an arc variable") ,- if ( (table. containsKey(var) ) &&
( ! ( ( (DataObject) (table. get (var) ) ) . getValue 0.equalε (val .getValu e())))l throw new RuntimeException ( "Variable "+var+" already bound. Old v alue="+( (DataObject) (table. get (var) ) ) . getValue ()+ " New Value="+val .getV alue ( ) ) ,- table.put (var, val) ; return this; } public Binding remove ( Symbol var) { table . remove (var) ; return this; } public Binding remove (Array varSet) { Enumeration iter=varSet . elements ( ) ; while ( iter .hasMoreElements ( ) ) table . remove ( (Symbol) ( (iter. nextElement ( ) ) ) ) ; return this; } public Binding project (Array varSet) throws RuntimeException { Binding result=new Binding ( ) ,- Enumeration iter=varSet . elements ( ) ; Symbol var; while ( iter .hasMoreElements 0 ) { var= ( (Symbol) (iter .nextElement 0 ) ) ; DataObject val=getBinding(var) ; if (val==null) throw new RuntimeException ( "Projection on non-existent variable "+var+" in tuple "+this) ; result.put (var, val); } return result; } public Binding join (Binding b) {
Enumeration iter=b . getVariables ( ) . elements ( ) ; Binding temp=this . copy( ) ; while (iter . hasMoreElements 0 ) {
Symbol var= (Symbol) (iter .nextElement ( ) ) ; DataObject val=b. getBinding (var) ,- temp .put (var, val) ; } return temp; } public boolean sameValue (Binding b, Symbol var) {
DataObject ol=getBinding(var) ,-
DataObject o2=b.getBinding(var) ; if (ol. equals (o2) ) return true; else return false; } ** expansion FBB and BBF -- the order of the variables is the one in the arcs */ public Array expand (Symbol inVar, DataAttribute a, Symbol outVar)thro ws RuntimeException {
Array result=new ArrayO; DataObject o=getBinding(inVar) ; if (o==null) throw new RuntimeException ( "Bad binding in expand (-B-) : "+this+" 1 ooking for "+inVar); Array valueSet; if (o.islnternal 0 ) { valueSet=o. outObjects (a) ; } else return new ArrayO; Enumeration iter=valueSet . elements ( ) ; while (iter .hasMoreElements 0 ) { Binding copy=this.copy ( ) ; copy. remove (outVar) ,-
DataObject newValue= ( (DataObject) ( iter. nextElement () ) ) ; if (copy.put {outVar, newValue) ==null) continue; result .add (copy) ; } return result;
} ** expansion FFB and BFF -- the order of the variables is the one in the arcs */ public Array expand (Symbol inVar, Symbol arc, Symbol outVar) throws Ru ntimeException {
Array result=new ArrayO; DataObject o=getBinding(inVar) ; if(o==null) throw new RuntimeException ( "Bad binding in expand (-F-) ... "+this+" looking for "+inVar) ; Array attribSet; if (o.islnternal ( ) ) attribSet=o . outAttribute ( ) ; else return new ArrayO; Enumeration iterl=attribSet .elements ( ) ; while (iterl .hasMoreElements ( ) ) {
DataAttribute a=( (DataAttribute) (iterl.nextElement ( ) ) ) ; LeafDataObject arcValue=new LeafDataObject (new StringDataValue (a. getName ( ) ) ) ;
Enumeration iter2=o. outObjects (a) . elements () ; while (iter2.haεMoreElements () ) { Binding copy=this . copy ( ) ; copy. remove (outVar) ; copy.remove (arc) ;
DataObject newValue= ( (DataObject) (iter2.nextElement ( ) ) ) ; if (copy.put (arc, arcValue) ==null) continue; if (copy.put (outVar, newValue) ==null) continue; reεult. add (copy) ; } } return result;
}
/** expansion F_B and B_F — the order of the variables is the one in the arcs */ public Array expand (Symbol inVar, Symbol outVar) throws RuntimeExcepti on {
Array result=new ArrayO; DataObject o=getBinding ( inVar) ; if (o==null) throw new RuntimeException ( "Bad binding in expand(-*-) ... "+this+" looking for "+inVar) ;
Enumeration iterl=o . outObjects ( ) . elements ( ) ; while (iterl .hasMoreElementε () ) { Binding copy=this . copy( ) ; copy. remove (outVar) ;
DataObject newValue= ( (DataObject) (iterl .nextElement ( ) ) ) ; if (copy.put (outVar, newValue) ==null) continue; result. add (copy) ,- } return result;
/* Get Methods */ public Hashtable getHashtable ( ) { return table; }
public Binding copyO { return new Binding ( ( (Hashtable) (table . clone () ) ) }
public boolean equals (Binding b2) { Binding bl=this;
Enumeration iter=bl . getHashtable ( ) . keys ( ) while ( iter . hasMoreElements ( ) ) {
Symbol v= ( Symbol ) (iter .nextElement () ) ; DataObject ol=bl. getBinding (v) ,- DataObject o2=b2.getBinding (v) ; if (ol==o2) continue; if (o2==null) return false; if ( !ol. equals (o2) ) return false; } return true; }
public Array getVariables ( ) { Array result=new Array ( ) ; Enumeration iter=table . keys ( ) ; while (iter .hasMoreElements ( ) ) result . add (iter .nextElement ( ) ) ; return result;
} public boolean isBounded(Symbol var) { return table. containsKey(var) ; } public DataObject getBinding (Symbol var) { return (DataObject) (table. get (var) ) ; } public boolean areAllBounded (Array vars) { Enumeration iter=vars. elements ( ) ; while (iter .hasMoreElements ( ) ) if ( ! table. containsKey(iter.nextElement () ) ) return false; return true; } " /* Data */
Hashtable table;
} /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The uεer further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either expresε or implied, in eluding
* but not limited to implied warrantieε of merchantability and fitneεε
* for a particular purpoεe, and any warranties of noninfringement .
* The user εhall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defectε or suggestionε for change and
* improvementε to the code . */ package Querylnterpretor; import COM. objectspace. jgl . *; import java.lang.*; import java.util.*; import java. io . * ; import DataRepository. * ,- import Automata . * ;
/* Simple Cartezian Product this operation corresponds to test the join of two dataflow return the common bindings
*/ public class CartProdOperation extends Operation{ public CartProdOperation (Array HI, Array H2) { super ( ) ; build=Hl; probe=H2 ; }
/* Display Methods */ public String toStringO { return "CartProduct " ; } /* Execution */ public Array consume (Binding bl) throws Exception { Array result=new ArrayO; Enumeration iter=probe . elements ( ) ; while (iter .hasMoreElements 0 ) {
Binding b2= (Binding) ( iter.nextElement ()) ; Binding temp=bl. oin(b2) ; if (temp!=null) result . add (temp) ; } build. add(bl) ; return result; }
/* Execution data */ private Array build; private Array probe;
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledgeε
* and agreeε to keep the code confidential and use the code solely for
* non-commercial reεearch. The uεer further acknowledgeε and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratorieε
* with reports of any errors, defects or suggestionε for change and
* improvements to the code. */ package Querylnterpretor; import COM. objectspace . jgl . * ; import java. lang. * ; import java.util.*; import java. io . * ,- import DataRepository. * ; import Automata. * ; import Querylnterpretor. * ;
/* Collect Operation this operation add a given node to a given collection right now the only thing that we suppport are nodes on this form: F(x)
*/ public class CollectOperation extends Operation{ public CollectOperation (StoredDataGraph g, NodeExpr_INT node, String name) { super ( ) ; graph=g; this .node=node ; collection=name; }
/* Display Methods */ public String toStringO { return "Collect ( "+node+" ) " ; } /* Execution */ public Array consume (Binding b) throws Exception{
InternalDataObject o = (InternalDataObject) node. toObject (b, graph)
StoredDataCollection c = ( (StoredDataCollection) (graph. getAddCollec tion (collection) ) ) ; o.addCollection(c) ; return new Array ( ) ; }
/* Data*/
StoredDataGraph graph; String collection; NodeExpr_INT node; /* Execution data */
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledgeε
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as iε" baεis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package Querylnterpretor; import COM.objectspace. jgl. *; import java.lang.*; import java.util.*; import java. io . * ; import Automata . * ; import DataRepository. * ;
/* Dependent Join this operation corresponds to test x-(l)->y when only one of x or y is bound there are two cases: forward and backward Forward: input: one dataflow with x bound and: 1 is also bound return x,l,y bound Backward: input: one dataflow with y bound and: 1 is also bound return x,l,y bound By default: forward */ public class DJoinOperation extends Operation{ public DJoinOperation (Symbol inVar, Symbol outVar, DataAttribut e attrib) { super ( ) ; this . inVar=inVar; this . outVar=outVar; this . attrib=attrib; } /* Display Methods */ public String toStringO { return "DJoin ( " +inVar+ " , " +outVar+ " , " +attrib . getName () + "
)";
}
/*Execution */ public Array consume (Binding b) throws Exception{
Array result=b. expand (inVar, attrib, outVar) ,- return result; }
/* Get Methods */ public Symbol invariable ( ) { return inVar; } public Symbol outVariable ( ) { return outVar; }
/* Data*/ private Symbol iriVar; private Symbol outVar; private DataAttribute attrib; } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggeεtions for change and
* improvements to the code. */ package Querylnterpretor; import COM.objectspace. jgl . *; import java . lang. * ; import java.util.*; import java. io . * ; import Automata. * ; import DataRepository. * ,-
/* Expand Operation*/ public class ExpandOperation extends Operation{
public ExpandOperation (Symbol inVar, Symbol outVar) { super ( ) ; this . inVar=inVar; this . outVar=outVar; }
/* Display Methods */ public String toStringO { return "Copy ( " +inVar+ " , " +outVar+ " ) " ; }
/* Execution */ public Array consume (Binding bl) throws Exception{ Array result=new ArrayO ; Binding b=bl . copy( ) ,- DataObject value=b. getBinding (inVar) ; if ( (value==null) || (b.put (outVar, value) ==null) return result; result. add (b) ; return result; }
/* Get Methods */
/* Data*/ private Symbol inVar; private Symbol outVar;
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledgeε
* and agreeε to keep the code confidential and uεe the code εolely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package Querylnterpretor; import COM.objectspace. jgl. *; import java.lang.*; import java.util.*,- import java. io . * ; import DataRepository. * ,- import Automata. * ;
/* Free Dependent Join this operation corresponds to test x-(*)->y when only one of x or y is bound Remark: the arc is not interesting there are two cases: forward and backward Forward: input: one dataflow with x bound return x,y bound Backward: input: one dataflow with y bound return x,y bound By default: forward */ public class FDJoinOperation extends Operation{ public FDJoinOperation (Symbol inVar, Symbol outVar) { super ( ) ; this . inVar=inVar; this . outVar=outVar,- }
/* Display Methods */ public String toStringO { return "FDJoin ( "+inVar+ " , "+outVar+" }
/* Execution */ public Array consume (Binding b) throws Exception{ return b. expand ( inVar, outVar) ; }
/* Get Methods */ public Symbol invariable () { return inVar; } public Symbol outVariable ( ) { return outVar; }
/* Data*/ private Symbol inVar; private Symbol outVar; private boolean forward;
}
Copyright 1997 AT&T Labs — Research
By receiving and using the code that follows, the user acknowledges and agrees to keep the code confidential and use the code solely for non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as iε" basis with no warranty, either expresε or implied, in eluding
* but not limited to implied warranties of merchantability and fitneεs
* for a particular purpose, and any warranties of noninfringemen .
* The user shall- use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package Querylnterpretor; import COM.objectspace. jgl .*,- import java. lang. * ,- import java.util.*; import java.io.*; import DataRepository. import Automata . * ;
/* Select Operation*/ public class FilterOperation extends Operation{
public FilterOperation (Expr_INT pred) { super ( ) ,- this .pred=pred;
/* Display Methods */ public String toStringO { return "Filter ( " +pred+ " ) " ; }
/* Control of the Execution */ public Array consume (Binding b) throws Exception{
Array result=new ArrayO;
DataValue v=pred.Eval (b) ; if (v. equals (BoolDataValue. TRUE) ) result. add (b) ; return result; }
/* Get Methods */
/* Data*/ private Expr_INT pred;
/* Execution data */
}
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness * for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package Querylnterpretor; import COM.objectspace. jgl. *; import java. lang. * ; import java.util.*; import java.io.*; import DataRepository. * ; import Automata . * ;
/* General Dependent Join this operation corresponds to test x-(l)->y when only one of x or y is bound and 1 is not bound there are two cases : forward and backward Forward: input : one dataflow with x bound return x,l,y bound Backward: input: one dataflow with y bound return x,l,y bound By default: forward */ public class GDJoinOperation extends Operation{
public GDJoinOperation (Symbol inVar, Symbol outVar, Symbol areVar) { super ( ) ; thi . inVar=inVar; this . outVar=outVar,- thiε . arcVariable=arcVar; }
/* Display Methods */ public String toStringO { return "GDJoin ( " +inVar+ " , " +outVar+ " , " +arcVariable+ " ) " ; }
/* Control of the Execution */ public Array consume (Binding b) throws Exception{ return b. expand ( inVar, arcVariable, outVar); }
/* Get Methods */ public Symbol invariable ( ) { return inVar; } public Symbol outVariable ( ) { return outVar; }
/* Data*/ private Symbol inVar; private Symbol outVar; private Symbol arcVariable; /* Execution data */
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitnesε
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package Querylnterpretor; import COM.objectspace. jgl . *; import j ava . lang . * ; import java.util.*; import java.io.*; import DataRepository. *,- import Automat . * ;
/* Expand Operation*/ public class InitiateScan extends Operation{
public InitiateScan ( ) { super ( ) ,- }
/* Display Methods * / public String toString O { return " InitiateScan" ; / * Execution * / public Array consume (Binding b) throws Exception {
Array result=new ArrayO ; result . add (b) ; return result; }
/* Get Methods */
/* Data*/
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and iε provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package Querylnterpretor; import COM.objectspace. jgl. * ; import java. lang. * ; import java.util.*; import java. io . * ; import DataRepository. * ,- import Automat . * ;
/* HashJoin this operation corresponds to test the join of two dataflow based on a join predicate of the form varl=var2 (where one of the flow have bound varl and the other var2 varl and var2 are not necessarilly distinct) return the collapse of the pair of bindings satisfying the predicate */ public class JoinOperation extends Operation{ public JoinOperation (Symbol vl, Symbol v2 , HashMap HI, HashMap H2){ super ( ) ; build=Hl; probe=H2 ; varl=vl; var2=v2;
/* Display Methods */ public String toString (){ if (varl==var2 ) return "Joi ( " +varl+ " ) " ; else return "Join("+varl+" ="+var2+" ) " ,- }
/* Execution */ public Array consume (Binding bl) throws Exception { Array result=new ArrayO ;
DataValue valuel=bl . getBinding (varl) .getValue ( ) ; if (probe. isEmpty ( ) ) { build. add(valuel,bl) ; return new Array( ) ; } else{
Enumeration iter=probe.values (valuel) ; while (iter .hasMoreElements 0 ) {
Binding b2= (Binding) (iter. nextElement ( ) );
Binding temp=bl. join(b2) ; if (temp! =null) result . add(temp) ; } return result; } }
/* Execution data */ private HashMap build; private HashMap probe; private Symbol varl; private Symbol var2; /* this is unusefull */
Copyright 1997 AT&T Labs — Research
By receiving and using the code that follows, the user acknowledges and agrees to keep the code confidential and use the code solely for non-commercial research. The user further acknowledges and agrees th at the code is not an official product of AT&T Corp., and is provided on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package Querylnterpretor,- import COM. objectspace .jgl.*; import java. lang. * ; import java.uti1. * ; import java. io . * ; import Automata . * ; import DataRepository. *,- import Querylnterpretor . * ;
/* Link Operation this operation creates a new node in the new graph given a left node specification, a right node specification and an arc specification
The only form suported right now iε F(x) -(l)-» G(y) */ public class LinkOperation extends Operation{
public LinkOperation ( StoredDataGraph g, NodeExpr_INT from, NodeExpr_I NT to, UnaryBoolExpr_INT arc) throws RuntimeException{ super ( ) ,- graph=g; this . from=from; this.to=to; if (arc instanceof UnaryBoolExprConst) { constantArc= ( (StringDataValue) ( ( (UnaryBoolExprConst) arc) .getValue O ) ) ; symbolArc=null ; } else if (arc instanceof UnaryBoolExprVar) { symbolArc=( (Symbol) ( ( (UnaryBoolExprVar) arc) .getSymbol 0 ) ) ; constantArc=null ; } else throw new RuntimeException ( "Bad Link Operation"); }
/* Display Methods */ public String toStringO {
String result="Link( "+from+"- if (constantArc !=null) result=result+constantArc ; else result=result+symbolArc .getName ( ) ; return result+"->"+to+" ) " ; }
/* Execution Method */ public Array consume (Binding b) throws Exception{
InternalDataObject fromObj = (InternalDataObject) from. toObject (b, graph) ;
DataObject toObj=to. toObject (b, graph);
DataAttribute a; if (constantArc ! =null) a=graph.getAddAttribute (constantArc . stringValue ( ) ) ; else a=graph.getAddAttribute ( ( (StringDataValue) ( ( (LeafDataObject) (b.ge tBinding(symbolArc) ) ) .getValue ( ) ) ) . stringValue () ) ; DataEdge e=new DataEdge (a, fromObj , toObj ) ; return new Array( ) ,- }
/* Data*/
StoredDataGraph graph; UnaryBoolExpr_INT arc; NodeExpr_INT from; NodeExpr_INT to; Symbo1 symbo1Arc; StringDataValue constantArc;
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package Querylnterpretor; import COM.objectspace.jgl . *; import java. lang. * ; import java.util.*; import java.io.*; import Automat . * ; import Optimizer.*; public abstract class Operation {
/* Constructor */ Operatio ( ) { nb_tuples_exec=0 ; nb_tuples_prod=0 ,- }
/* Get Methods */ public long getTime ( ) { return time; } public int getNbTuplesExec ( ) { return nb_tuples_exec; } public int getNbTuplesProd( ) { return nb_tuples_prod; }
/* Execution */ public Array execute (Binding b) throws Exception{ nb_tuples_exec++;
Date initialTime=new Date();
Array result=consume(b) ; time=time+ (new Date () ) . getTime ( ) -initialTime . getTime ( ) ; nb_tuples_prod=nb_tuples_prod+result . size ( ) ; return result; } public Array consume (Binding b) throws Exception{ throw new RuntimeException (" Sorry operation not implemented! "+this)
}
/* Profile Data */ protected long time; protected int nb_tuples_exec; protected int nb_tuples_prod;
Copyright 1997 AT&T Labs — Research
By receiving and using the code that follows, the user acknowledges and agrees to keep the code confidential and use the code solely for non-commercial research. The user further acknowledges and agrees th at the code is not an official product of AT&T Corp. , and is provided on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package Querylnterpretor; import COM. objectspace . jgl . * ; import java . lang. * ; import java .util . * ; import java . io . * ; import Automata . * ; import DataRepository. * ,-
/* Project Operation -- keep only the variables in the varSet*/ public class ProjectOperation extends Operation{
public ProjectOperation (HashSet set) { super ( ) ; varSet=new Array( ) ;
Enumeration iter=set. elements 0 ; while ( iter. hasMoreElements ( ) ) varSet . add ( iter .nextElement ( ) ) ; } public ProjectOperation (Symbol var) { super ( ) ; varSet=new Array ( ) ; varSet . add (var) ; }
/* Display Methods */ public String toString ( ) { return "Project ( "+varSet+" ) " ; }
/* Control of the Execution */ public Array consume (Binding b) throws Exception{
Array result=new ArrayO;
Binding bl=b.project (varSet) ; result.add (bl) ; return result; }
/* Get Methods */ /* Data*/ private Array varSet;
/* Execution data */ }
/*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitnesε
* for a particular purpoεe, and any warrantieε of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package Querylnterpretor; import COM.objectspace. jgl. *; import java.lang. * ; import java.util. *,- import java.io. *,- import Automata. *; import DataRepository. * ;
/* Remove Duplicates this operation remove duplicates.
It uses a simple list in the absence of a variable, otherwise it uses a hastable based on the value for the variable
*/ public class RDOperation extends Operation{ public RDOperation() { super ( ) ; simpleList=new ArrayO; hashTable=null; variable=null; } public RDOperation(HashSet vars) { super ( ) ; variable=null;
Enumeration iter=vars . elements ( ) ; while(iter.hasMoreElements () ) { variable= ( (Symbol) (iter.nextElement ( ) ) ) ; break; } if (variable==null) { simpleList=new ArrayO ; hashTable=null; } else{ simpleList=null ; hashTable=new HashMap (true) ; }
/* Display Methods */ public String toStringO { if (variable==null) return "RemoveDup" ; else return "RemoveDup ( " +variable+ " ) " ; }
/* Control of the Execution */ public Array consume (Binding b) throws Exception{ Array result=new ArrayO; Enumeration iter; boolean found=false; if (variable==null) { iter=simpleList . elements ( ) ; while (iter.hasMoreElements 0 ) {
Binding bl= ( (Binding) (iter.nextElement ( ) ) ) ; if (bl. equals (b) ) { found=true; break; } if (! found) { result. add(b) ; simpleList.add(b) ; } } } else{
DataValue valuel=b. getBinding (variable) . getValue () iter=hashTable.values (valuel) ; while (iter .hasMoreElements 0 ) {
Binding b2= (Binding) (iter.nextElement 0 ) ; if (b. equals (b2) ) { found=true; break; } } if (! found) { result. add (b) ; hashTable . add(valuel ,b) ; } } return result; }
/* Private Data */ Array simpleList; HashMap hashTable; Symbol variable;
* Copyright 1997 AT&T Labs — Research
* By receiving and uεing the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpoεe, and any warrantieε of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code . */ package Querylnterpretor; import COM.objectspace. jgl. *; import java. lang. * ; import java.util . * ,- import java. io . * ; import Automata ..* ; import DataRepository. *,-
/* this operation finds the first bindings for a variable x, with a con straint of the form C(x) —C being a collection-- or no constraints at a 11*/ public clasε ScanOperation extends Operation{
/* this operation finds the first bindings for a variable x, with a c onstraint of the form C(x) —C being a collection*/ public ScanOperation (Symbol v, DataCollection c) { super ( ) ; var=v; col=c;
}
/* Display Methods */ public String toStringO { return "Scan ( " +col . getName ()+"," +var+ " ) " ; }
/* Execution Methods */ public Array consume (Binding b) throws Exception{ Array result=new ArrayO;
Enumeration iter= col . getObjects ( ) . elements ( ) ; while (iter . hasMoreElements ( ) ) {
Binding bl=new Binding ( ) ; bl.put (var, ( (DataObject) (iter .nextElemen 0 ) ) ) ; reεult . add(bl) ; } return result ; }
/* Get Methods */ public Symbol getVariable ( ) { return var; } public DataCollection getCollection ( ) { return col; }
/* Data*/ private Symbol var; private DataCollection col;
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package Querylnterpretor; import COM.objectspace. jgl. import java . lang. * ; import java.util.*; import java.io.*; import Automata . * ; import DataRepository.*;
/* Union this operation corresponds the union of two dataflows return the union of bindings -- keep duplicates
*/ public clasε UnionOperation extendε Operatio {
public UnionOperation {) { super ( ) ;
}
/* Display Methods */ public String toStringO { return "Union"; }
/* Control of the Execution */ public Array consume (Binding b) throws Exception{ Array result=new Array () ; reεult.add(b) ; return result; } }
/*
* Copyright 1997 AT&T Labs -- Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package Querylnterpretor,- import COM.objectspace. jgl .* ; import java. lang. * ; import java.util.*; import java. io . * ; import Automata . * ; import DataRepository. * ; import Querylnterpretor . * ;
/* Unique Link Operation
This operation specializes LinkOperation, which creates a new node in the new graph given a left node specification a right node specification and an arc specification. UniqueLinkOperation represents a Link expression that contains no variables and therefore only needs to be executed (consumed) once. */ public class UniqueLinkOperation extends LinkOperation{ public UniqueLinkOperation (StoredDataGraph g, NodeExpr_INT from, Node Expr_INT to, UnaryBoolExpr_INT arc) throws RuntimeException{ super(g, from, to, arc); }
/* Execution Method */ public String toStringO {
String result="UniqueLink( "+from+"-" ; ; if (constantArc ! =null ) result=result+constantArc; else result=result+symbolArc . getName ( ) ; return result+"->"+to+" ) " ; } public Array consume (Binding b) throws Exception { if ( ! consumed) { consumed = true; return super. consume (b) ; } else return new ArrayO; } boolean consumed = false; }
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledgeε and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitnesε
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package Querylnterpretor; import COM.objectspace. jgl. *; import java . lang . * ; import java.util.*; import java . io . * ; import Automata . * ; import DataRepository.*,-
/* The Unit operation produces the set "{ () }", which contains the empty tuple "()", called unit. */ public class UnitOperation extends Operation{
/* Display Methods */ public String toStringO { return "Unit";
}
/* Execution Methods */ public Array consume (Binding b) throws Exception{
Array result=new ArrayO;
Binding bl=new Binding () ; bl .put (unit , emptytup) ; reεult.add(bl) ; return result; }
/* Get Methods */
/* Data*/ public static DataObject emptytup = new LeafDataObject (new StringData Value ("_unit_") ) ; public static Symbol unit = new Symbol ( "_unit_" ) ; } /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledgeε
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package Query-Parser; import COM.objectspace. jgl. *,- import java.util.*; import java . io . * ; import Automata. * ; import Util.*; public class Env { private SList env = new SList ( ) ;
Env (SymbolTable symtab) { env.pushFront ( symtab) ; } public Symbol install (String s) { try { return lookup (s) ; } catch (NotFound nf) { if (! env. isEmpty () ) {
SymbolTable top = (SymbolTable) env. front () ; return top . install (s ) ; } else throw new RuntimeException ( "Empty symbol environment"); } } public Symbol lookup (String s) throws NotFound { Enumeration e = env. elements () ; while (e.hasMoreElements () ) {
SymbolTable symtab = (SymbolTable) e. nextElement () ; try {
Symbol sym = symtab. lookup (s) ; return sym; } catch (NotFound nf) { } } throw new NotFound (s) ; // return (Symbol) null; } public void push() { env.pushFront (new SymbolTable 0 ) ; } public void pop ( ) { if (! env. isEmpty () ) env.popFront 0 ;
} } ©
STRUDEL LANGUAGE PARSER.
The Strudel parser produces an abstract syntax ''tree'' (list, really), called ''ast'', which includes the '' select" fragment of a query (i.e., the automata that denote regular path expressions) and the ' 'create and link'' fragment of a query
(i.e., vectors of link, range, create, and collect expressions). «Strudel . jj»= options {
LOOKAHEAD = 1;
CHOICE_AMBIGUITY_CHECK = 2;
OTHER_AMBIGUITY_CHECK = 1;
STATIC = false;
DΞBUG_PARSER = false; DEBUG_LOOKAHEAD = false; DEBUG_TOKEN_MANAGER = false; ERROR_REPORTING = true; JAVA_UNICODE_ESCAPE = false; UNICODE_INPUT = false; IGNORE_CASE = false; USER_TOKEN_MANAGER = false; USER_CHAR_STREAM = false; BUILD_PARSER = true; BUILD_TOKEN_MANAGER = true; SANITY_CHECK = true; FORCE_LA_CHECK = false; }
PARSER_BEGIN(Strudel) package QueryParser; /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basiε with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitnesε
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errorε, defectε or suggestions for change and
* improvements to the code. */ import COM.objectspace. jgl. *; import java.util.*; import java . io . * ; import Automata . * ,- import DataRepository. *,- import Util . * ; public class Strudel { public static SymbolTable symtab = new SymbolTable ( ) ; public static Env env = new Env (symtab) ,- private static String outputFile = Environment . getEnv("STRUDEL_TMP") + File . separator+ " output " ; public static Query onlyParse(File queryFile) throws Exception { Query currentQuery = null;
FilelnputStream file=new FilelnputStream(queryFile) ; Strudel parser = new Strudel (file) ;
PrintStream out=new PrintStream(new FileOutputStream (outputFile) , t rue) ,- try {
System, out . println ( "Parser started" ) ,- currentQuery= ( (Query) (parser .Query ( ) ) ) ; currentQuery . clean ( ) ; out.println(currentQuery. toString ( ) ) ; System. out.println ( "Parser ended") ;
String outgraph = currentQuery. outGraph () ;
String dir = Environment.getEnv( "INPUT_DIR" ) +File.separator+outgr aph;
File data = new File (dir+File. separator+"data"+File. separator) ; File files = new File(dir+File.seρarator+"files"+File.εeparator) ; File tmp = new File (dir+File. separator+" tmp" +File. separator) ; File htmltemplates = new File (dir+File. separator+"htmltemplateε"+ File.εeparator) ;
File εite = new File(dir+File.separator+"site"+File. separator) ,- data.mkdirs( ) ; files .mkdirs ( ) ; tmp.mkdirs ( ) ; htmltemplates .mkdirs ( ) ; site.mkdirs 0 ; out.cloεeO ,- } catch (Exception e) {
// e .printStackTrace ( ) ;
System. err.println ( "Parser error: "+e. toString ()+" \n" ) ; throw e; } return currentQuery; } public static void onlyOptimize (Query q) throws Exception { try {
System. out.println( "Optimization started") ; q. optimize ( ) ;
System. out .println ( "Optimization ended") ; } catch (Exception e) { e .printStackTrace ( ) ;
System. err.println ( "Optimization error: "+e. toString () + "\n" ) ; throw e; } } public static String onlyRun (Query q) throws Exception { try {
String outgraph = q. outGraph () ;
String dir = Environment .getEnv ("INPUT_DIR" ) +File. separator+outgr aph;
File tmp = new File (dir+File. separator+"tmp"+File. separator) ;
String profilefile = tmp. toStringO +File.separator+ "profile" ; System. out .println ( "Execution trace in: " +profilefile) ; PrintStream profile = new PrintStream(new FileOutputStream(profil efile) , true) ,-
System. out.printlnt "Start running " ) ; q. run (profile) ;
System. out.println ( "Query executed and produced the graph "+q.out Graph ( ) ) ; } catch (Exception e) {
System. err.println ( "Execution error: "+e. toString () +"\n" ) ; throw e; } return q. outGraph ( ) ; }
public static Query optimize (File queryFile) throws Exception {
Query q = onlyParse (queryFile) ; onlyOptimize (q) ; return q; }
public static String run (File queryFile) throws Exception {
Query q = onlyParse (queryFile) ; onlyOptimize (q) ; return onlyRun (q); }
public static Query_INT strudelParser (InputStream in) throws ParseErr or, IOException {
Strudel parser = new Strudel (in) ,-
PrintStream out=new PrintStream (new FileOutputStream ( "outfile" ) , tr ue) ;
Query_INT q; q=parser . Query ( ) ; q. clean ( ) ; out .println (q. toString ( ) ) ; out. close ( ) ; return q; }
public static Query_INT parser ( InputStream in) throws ParseError, IOE xception { return strudelParser (in) ; }
public static void main (String args[]) throws Exception { try { strudelParser (System. in) ; } catch (ParseError e) { // e.printStackTrace () ; System. err.println ( "Parser error: "+e. toStringt ) ) ; /* Operators */ public static Symbo1_INT opBAR = env. install ( " | " ) public static Symbol_INT opDOT = env.instalK".") public static Symbol_INT opCOLON = env.instalK": public static Symbol_INT opOR = env. install ( "or" ) public static Symbol_INT opAND = env. install ( "and public static Symbol_INT opNOT = env. install ( "not public static Symbo1_INT opLE = env. install ( <=") public static Symbol_INT opGE = env. install ( >=") public static Symbol_INT opNE = env. install ( !=") public static Symbol_INT opGT = env. install ( >"); public static Symbol_INT opLT = env. install ( <"); public static Symbol_INT opIN = env. install ( in") public static Symbol_INT opEQ = env. install ( = "); public static Symbol_INT opPLUS : env. install (" + ") ; public static Symbol_INT opMINUS = env. install ("-"); public static Symbol_INT opSTAR = env. install ("*"); public static Symbol_INT opSLASH = env. install ("/"); public static Symbol_INT predlnternal = env . install ( " islnternal " ) ; public static Symbol_INT predValue = env . install ( " isValue" ) ; public static Symbol_INT predBool = env . install ( " isBool " ) ; public static Symbol_INT predDate = env. installt "isDate" ) ; public static Symbol_INT predFloat = env . install ( " isFloat " ) ; public static Symbol_INT predlmage = env . install ( " islmage" ) ; public static Symbol_INT predHTML = env. install ( "iεHTML" ) ,- public static Symbol_INT predlnt = env. inεtall ( "islnt" ) ,- public static Symbol_INT predPoεtScript = env. install ( "isPostScript" ; public static Symbol, .INT predString = env. install ( "isString" ) public static Symbol,.INT predText = env. install ( "isText" ) ; public static Symbol..INT predURL = env. instalK "isURL" ) ; public static boolean isRelOp(Symbol_INT s) { return s == opEQ I I ε == opNE I j ε == opLE s == opGE s == opGT I I s == opLT; } public static boolean isArithOp(Symbol_INT s) { return s == opPLUS I I s == opMINUS | | s == opSTAR | | s == opSLASH; } public static boolean isBuiltinPred (Symbo1_INT s) { return s == predlnternal | | s == predValue j | s ===== predBool | | ε == predDate | | s === predFloat ] | s ===== predlmage j | _=__; ===== predHTML | j s ===== predlnt | | s == predPoεtScript | | s ===== predString I | s == predText | | ε == predURL; } public static DataValue evalBuiltinPred(Symbol_INT s, DataObject o) { boolean b = false; if (s == predlnternal) b = o . islnternal ( ) ; else if (!o.islnternal () ) { if (s == predValue) b = true; else if (s == predBool) b = (o . getValue ( ) instanceof BoolDataValue) ; else if (s == predDate) b = (o . getValue ( ) instanceof DateDataValue) ; else if (s == predFloat) b = (o. getValue () instanceof FloatDataValue) ; else if (s == predlmage) b = = (o . getValue ( ) instanceof GifDataValue) ; else if (s == predHTML) b = = (o. getValue ( ) instanceof HtmlDataValue) ; else if (s == predlnt) b = = (o. getValue () instanceof IntDataValue) ; else if (s == predPostScript) b = = (o.getValueO instanceof PεDataValue) ; else if (s == predString) b = = (o. getValue ( ) instanceof StringDataValue) else if (s == predText) b = = (o.getValueO instanceof TextDataValue) ; else if (s == predURL) b = = (o. getValu ( ) instanceof UrlDataValue) ; } return new BoolDataValue (b) ;
/* the "true" unary boolean predicate, as in x->(_*)->y, where _ mean s "true" */ public static Symbol_INT predTrue = env. install ( "predTrue" ) ;
static final Symbol_INT tokenToSymbol (Token t) { try { return env. lookup (t . image) ; } catch (NotFound nf) { return (new Symbol ( t . image) ) ;
}
} static final Symbol_INT newSymboKString ε, boolean check) { Symbol sym; if (check) { try { sym = env. lookup (s) ,- } catch (NotFound exp) {
System. err.println ( "Symbol "+s+" in Link/Collect/Create clause not bound in Where clause"); throw new RuntimeException () ,- } } else sym = env. install (s) ; return sym; } static Operator [ ] RegularOp = { new Operator (opNOT, OperatorKmd.prefix) , new Operator (opAND, OperatorKmd. infix) , new Operator (opOR, OperatorKmd. infix) , new Operator (opCOLON, OperatorKind. infix) , new Operator (opPLUS , OperatorKind.postfix) , new Operator (opSTAR, OperatorKind.postfix) , new Operator (opDOT, OperatorKind. infix) , new Operator (opBAR, OperatorKind. infix)
}; static Operator [ ] NonRegularOp = { new Operator (opSLASH, OperatorKind. infix) , new Operator (opSTAR, OperatorKind. infix) , new Operator (opMINUS, OperatorKind.prefix) , new Operator (opPLUS, OperatorKind.prefix) , new Operator (opMINUS, OperatorKind. infix) , new Operator (opPLUS , OperatorKind. infix) , new Operator (opIN, OperatorKind. infix) , new Operator (opEQ, OperatorKind. infix) , new Operator (opLT, OperatorKind. infix) , new Operator (opGT, OperatorKind. infix) , new Operator (opNE, OperatorKind. infix) , new Operator (opLE, OperatorKind. infix) , new Operator (opNOT, OperatorKind.prefix) , new Operator (opAND, OperatorKind. infix) , new Operator (opOR, OperatorKind. infix) };
} class OperatorKind { static OperatorKind prefix = new OperatorKind () ,- static OperatorKind infix = new OperatorKind 0 ; static OperatorKind postfix = new OperatorKind() ; } class Operator { public Symbol_INT symbol; public OperatorKind kind;
Operator (Symbo1_INT a, OperatorKind b) { symbol = a; kind = b; } }
PARSER_END(Strudel) « Lexical Rules » « Grammar Rules »
©
STRUDEL LANGUAGE GRAMMAR.
The query construct \verb | INPUT ... HERE ... COLLECT | selects nodes and paths from the data graphs in the \verb| INPUT | clause and produces new collections of nodes.
The transformation construct \verb | HERE...CREATE...LINK| selects nodes and paths from the data graphs in the \verb| INPUT | clause and creates a new graph with the name given in the \verb | OUTPUT | clause.
The new graph may point to nodes in the input graphs; its ''entry'' point nodes are specified in the \verb | COLLECT | clause.
The body of a \verb| HERE | clause is interpreted as a conjunction of all itε \verb | path_definition| and \verb I condition I sub-expressions.
/A***************************************************************/
« Grammar Rules »=
Query_INT Query() throws ParseError:
{ QueryBlock_INT q;
String [ ] input= { " " } ;
String output= " " ;
Symbol_INT s; } {
[<INPUT> input = IdList (false) ] q = QueryBlock ( )
[<0UTPUT> ε = Id(false) { output = s.getNamet);} ]
[<END>]
{ return new Query (input, output, q) ; } }
String [] IdLiεt (boolean check) : { Vector v = new Vector ( ) ,-
Symbo1_INT s; } { ε = Idtcheck) { v. addElement (s. getName ()) ; }
( <COMMA> s = Id (check) { v. addElement (ε . getName ()) ; } )*
{ int n = v.size( ) ;
String [] res = new String [n] ,- for (int i = 0; i<n; i++) res[i] = (String) v.elementAt (i) ; return res; } }
QueryBlock_INT QueryBlock ( ) throws ParseError { Vector vNodeExprs = new Vector ( ) , vArcVars = new Vector () , vConditions = new Vector (), vAutomata = new Vector ( ) , vCreates = new Vector ( ) , vLinks = new Vecto ( ) , vCollects = new Vector ( ) , vSubQueries = new Vector ( ) ;
QueryBlock_INT q; env.push ( ) ;
}
{ (<WHERE> Where (vNodeExprs, vArcVars, vConditions, vAutomata) |
<CREATE> Create (vCreates) |
<LINK> Link(vLinks) |
<C0LLECT> Collect (vCollects) I
<LBRACE> q = QueryBlock () { vSubQueries. addElement (q) ; } <RBRACE> )
{
NodeExpr_INT [ ] nodeExprs = new NodeExpr_INT [vNodeExprs. size ()] ;
Symbol_INT [ ] arcVars = new Symbol_INT [vArcVars . size ( ) ] ;
BoolExpr_INT [ ] conditions = new BoolExpr_IN [vConditions . size ()] ;
Automata_INT [ ] automata = new Automata_INT [vAutomata. size ()] ;
NodeExpr_INT [ ] creates = new NodeExpr_INT [vCreates. size ()] ; Link_INT[] links = new Link_INT[vLinks.size ( ) ] ;
CollExpr_INT[] collectε = new CollExpr [vCollects . size ()] ; QueryBlock_INT [ ] subQueries=new QueryBlock_INT [vSubQueries . size () ] ; for (int i=0; i<vNodeExprs . size 0 ; i++) nodeExprs[i] = (NodeExpr_INT) vNodeExprε . elementAt ( i ) ; for (int i=0; i<vArcVars. size() ; i++) arcVars [i] = (Symbol_INT) vArcVars . elementAt (i ) ; for (int i=0; i<vConditions . size 0 ; i++) conditions [i] = (BoolExpr_INT) vConditionε. elementAt (i) ; for (int i=0; i<vAutomata. εize ( ) ; i++) automata [i] = (Automata_INT) vAutomata . elementAt ( i ) ;
for (int i=0; i<vCreates. size ( ) ; i++) createsfi] = (NodeExpr_INT) vCreateε. elementAt (i) ; for (int i=0; i<vLinkε . size ( ) ; i++) links [i] = (Link_INT) vLinks .elementAt (i) ; for (int i=0; i<vCollects.size ( ) ,- i++) collects[i] = (CollExpr_INT) vCollects .elementAt (i) ; for (int i=0; i<vSubQueries . size ( ) ; i++) subQueries [i] = (QueryBlock_INT) vSubQueries. elementAt (i) ; env.pop () ; return new QueryBlock (nodeExprs, arcVars, conditions, automata, creates, links, collects, subQueries) ,-
}
/A***************************************************************/
© Where Clause.
« Grammar Rules »= void Where (Vector vNodeExprs, Vector vArcVars, Vector vConditions, Vect or vAutomata) throws ParseError :
{}
{
Wherel (vNodeExprs, vArcVars, vConditionε, vAutomata) (<C0MMA> Wherel (vNodeExprs, vArcVars, vConditions, vAutomata))*
} void Wherel (Vector vNodeExprs, Vector vArcVars, Vector vConditions, Vec tor vAutomata) throws ParseError : {UExpr_INT el, e2 , e3 ; boolean isNodeExpr = false; NodeExpr_INT xl = null, x3 = null; Automata_INT aut , aut2 ; BoolExpr_INT cond; } { el = Expr (false)
(<ARROW> e2 = ExprR( false) <ARROW> e3 = Expr (false) { try { if ( ϋsNodeExpr) { /* first iteration only */ isNodeExpr = true; xl = el . toNodeExpr ( ) ; vNodeExprε . addElement (xl ) ; } x3 = e3. toNodeExpr ( ) ,- vNodeExprs . addElement (x3 ) ; aut2 = e2. toRpe (true) . toAutomata ( ) ; aut = new Automata (aut2, xl, x3); /* rename input and output *
aut . elimEpsEdges ( ) ; vAutomat . addElement (aut) ; } catch (StrudelError err) { System, err.println(err. error) ; throw new ParseError ( ) ; } xl = x3; /* prepare for next iteration */ }
)* { if (ϋsNodeExpr) try { cond = el . toBoolExpr { ) ; vConditionε. addElement (cond) ; } catch (StrudelError err) { System,err.println (err. error) ; throw new ParseError ( ) ; } } /* don't know how to distinguish boolean expr from collections */ } /****************************************************************/
« Grammar Rules »= void Create (Vector vCreates) throws ParseError :
{}
{
Createl (vCreates) (<COMMA> Createl (vCreates) ) * } void Createl (Vector vCreates) throws ParseError : {UExpr_INT e; NodeExpr_INT x; } { e = Expr (true) { try { x = e . toNodeExpr ( ) ,- vCreates . addElement (x) ; } catch (StrudelError err) { System. err.println(err. error) ; throw new ParseError ( ) ; } } }
© Link clauses .
« Grammar Rules »= void Link (Vector vLinks) throws ParseError :
{}
{ Linkl (vLinks)
(<C0MMA> Linkl (vLinks) ) * } void Linkl (Vector vLinkε) throws ParseError : { UExpr_INT el;
NodeExpr_INT xl; } { el = Expr (true) { try { xl = el . toNodeExpr () ; } catch (StrudelError err) {
System. err.println (err. error) ; throw new ParseError ( ) ,- } }
[<ARR0W> Targets (xl, vLinks)] } void Targets (NodeExpr_INT xl, Vector vLinks) throwε ParseError : { UExpr_INT e2 , e3 ;
NodeExpr_INT x3;
Rpe_INT rpe;
UnaryBoolExpr_INT ub; } { e2 = Expr (true) { try { rpe = e2. toRpe (true) ; if (rpe instanceof RpeAtomic) ub = ((RpeAtomic) rpe) .UnaryBoolExpr () ; else { System. err.println ( "Only single edge allowed here"); throw new ParseError ( ) ,- } } catch (StrudelError err) {
System. err.println (err. error) ; throw new ParseError ( ) ; } }
<ARROW> e3 = Expr (true) { try { x3 = e3. toNodeExpr ( ) ; vLinks. addElement (new Link(xl, x3, ub) ) ; } catch (StrudelError err) {
System, err.println (err. error) ,- throw new ParseError ( ) ; } }
[<ARR0W> Targets (x3, vLinks)] |
<ALL> <LBRACE> Targets (xl, vLinks) (<COMMA> Targets (xl, vLinks))* <RB RACE> }
/****************************************************************/
© Collect clauses.
«tested by»= t28 t29
« Grammar Rules »= void Collect (Vector vCollects) throws ParseError :
{}
{
Collectl (vCollects) (<COMMA> Collectl (vCollects) ) * } void Collectl (Vector vCollects) throws ParseError : { UExpr_INT e;
CollExpr_INT c; } { e = Expr (true) { try { c = e . toCollExpr O ; vCollects . addElement (c) ,- } catch (StrudelError err) {
System. err. println f err . error) ,- throw new ParseError ( ) ; } } }
« Grammar Rules »= /**********************************************************************
**********
UExpr_INT Expr (boolean check) :
{ UExpr_INT r; }
{ r = Expri (Strudel.NonRegularOp. length, Strudel.NonRegularOp, check)
{ return r; } }
UExpr_INT ExprR (boolean check) :
{ UExpr_INT r; }
{ r = Expri (Strudel.RegularOp. length, Strudel .RegularOp, check)
{ return r; } }
UExpr_INT Expri (int i, Operator [] ops, boolean check) :
{}
{
[LOOKAHEAD( {0<0} ) Expri_simple (ops, check)] /* never taken; just to fool JavaCC */
{ if (i==0) return Expri_simple(ops, check); else return Expri_nonsimple(i, ops, check); }
UExpr_INT Expri_simple (Operator [] ops, boolean check) : { UExpr_INT r, e, a [ ] ,- DataValue v; Vector w; Symbol_INT s; String t; } {
( <UNDER> { r = new UExprld (predTrue) ; }
I <STAR> { r = new UExprFunctionCall (opSTAR, new UExprld (pre dTrue)); }
I <LPAREN> r = Expri (ops. length, ops, check) <RPAREN> I v = Value () { r = new UExprDataValue (v) ; } j t = IdStringO { r = null; } [LOOKAHEAD (<LPAREN>)
{ // System. err.println("Func?"+t) ; w = new Vector (0) ,- } <LPAREN> ( LOOKAHEAD (<RPAREN>) <RPAREN>
I e = Expri ( ops . length, ops , check) { w. addElement (e ) ; } (<COMMA> e = Expri ( ops . length, ops , check) { w. addElement (e) ; } ) * <RPAREN> ) { s = env. install (t ) ; a = new UExpr_INT [w. size ( ) ] ; . for ( int i=0 ; i<w. size ( ) ; i++ ) a [ i ] = ( UExpr_INT ) ( w . elementAt ( i ) ) ; r = new UExprFunctionCall ( s , a ) ; } ] { if (r == null ) {
// System,err.println ("Var? "+t) ,- ε = newSymbol (t, check); r = new UExprld(s) ; } } I <LBRACE> { w = new Vector (0); } ( LOOKAHEAD (<RBRACE>) <RBRACE>
I (e = Expri (ops. length, ops, check) { w. addElement (e) ; } (<COMMA> e = Expri (ops. length, ops, check) { w. addElement (e) ; })* <RBRACE> ) )
{ a = new UExpr_INT[w.size( ) ] ; for (int i=0; i<w.size(); i++) a[i] = (UExpr_INT) (w.elementAt (i) ) ,- r = new UExprSet (a) ; } )
{ return r; } }
UExpr_INT Expri_nonsimple (int i, Operator [] ops, boolean check) : { UExpr_INT r;
Vector w = new Vector (0 ) ,- } {
{ if (ops [i-1] .kind == OperatorKind.prefix) w = Expri_prefix(i,opε) ; } r = Expri (i-1, opε, check) { for (int j = w.εize()-l; j >=0; j — ) { UExpr_INT args [ ] = {r} ; r = new UExprFunctionCalK (Symbol_INT) (w.elementAt (j )) , args); } if (ops [i-1] .kind == OperatorKind. infix) r = Expri_infix(r, i, ops, check) ,- if (ops [i-1] .kind == OperatorKind.postfix) r = Expri_postfix(r, i, ops) ,- return r; } } Vector Expri_prefix (int i, Operator [] opε) : { Vector w = new Vector (0) ,-
Symbo1_INT op; } { { while ( tokenToSymbol (getToken(l) ) == ops [i-1] .symbol) { op = Op ( ) ; w. addElement (op) ; } return w;
} }
UExpr_INT Expri_infix(UExpr_INT e, int i, Operator!] ops, boolean check ) :
{ UExpr_INT r = e; Symbol_INT op; } { { while (tokenToSymbol (getToken(l) ) == ops [i-1] .symbol) { op = Op () ; r = new UExprFunctionCall (op, r, Expri(i-1, ops, check)); } return r; } }
UExpr_INT Expri_postfix(UExpr_INT e, int i, Operator [ ] ops) : { UExpr_INT r = e; Symbo1_INT op; } { { while (tokenToSymbol (getToken(l) ) == ops [i-1] .symbol) { op = Op () ; r = new UExprFunctionCall (op, r) ; } return r; } }
****************************************************************
Symbol_INT Op () :
{Token t; }
{
(t = <BAR> I t = <DOT> I t = <COLON> I t = <OR> I t = <AND> | t = <NOT> j t = <LE> | t = <GE> j t = <NE> j t = <GT> | t = <LT> | t = <EQ> j t = <IN> j t = <PLUS> | t = <MINUS> t = <STAR> | t = <SLASH>)
{ return tokenToSymbol(t) ; }
Symbol_INT Id (boolean check) :
{ String s; }
{ s = IdString ( )
{ return newSymbol (s, check) }
String IdString ( ) : { Token t;
DataValue ty;
(t = <ID> { return t. image; }
I ty = Typeld0 { return ty. getType 0 ,- })
}
DataValue Value ( ) : { Token t;
DataValue r, ty = null; } {
[ <IS> ty = Typeld () ]
( t = <INTEGER> { r = new IntDataValue (Integer .valueOf ( t . image) . intVa lue ( ) ) ,- }
I t = <FLOATING_POINT> { r = new FloatDataValue (Float .valueOf (t. imag e) . floatValue ( ) ) ; }
I t = <STRING> { r = new StringDataValue (t. image, substring (1 , t . image. length()-D); }
I t = <TRUE> { r = new BoolDataValue (true) ; } j t = <FALSE> { r = new BoolDataValue (false) ; }
)
{ if (ty != null) r = DataValue. convertValue (ty, r) ; return r;
} DataValue Typeld ( ) {} {
<BOOLTYPE> return DataValue . boolval ; }
<DATΞTYPE> return DataValue . dateval; }
<FLOATTYPE> return DataValue . floatval ; }
<IMAGETYPE> return DataValue . imageval ; }
<HTMLTYPE> return DataValue . htmlval ; }
<INTTYPE> return DataValue . intval ; }
<PSTYPE> return DataValue .psval; }
<STRINGTYPE> return DataValue .stringval; }
<TEXTTYPE> return DataValue . textval ,- }
<URLTYPE> return DataValue . urlval ,- }
©
STRUDEL LANGUAGE LEXICAL ANALYSIS
« Lexical Rules »=
SKIP : /* WHITE SPACE */
{
I "\t"
I "\n" j "\r" I "\f"
}
« Lexical Rules »= SPECIAL_TOKEN : /* COMMENTS */ {
<SINGLE_LINE_COMMENT : "//" (~ [ " \n" , " \r" ] ) * ( " \n" | " \r" | " \r\n" ) > I <FORMAL_COMMENT: "/**" (-["*"])* « * >• ("*>■ | (~ [ •> * " t » / « ] ("["*"])* " * " ))* "/"> I <MULTI_LINE_COMMENT: " /* " (-["*•'])* •> * " ( •• * « | ( ~ [ >• * » , •■ / " ] (-[«*"])*
}
« Lexical Rules »= TOKEN [ IGNORE_CASE] : /* RESERVED WORDS AND LITERALS */ {
< ALL: "all" >
< AND: "and" >
< CASE: "case" >
< COLLECT: "collect" >
< CREATE: "create" >
< ELSE: "else" >
< END: "end" >
< FALSE: "false" >
< IF "if" >
< IN "in" >
< IS "is" >
< INPUT: "input" >
< LENGTH: "length" >
< LINK: "link" >
< MATCHES: "matches" > < NOT: "not" >
< OR: "or" >
< OVER: "over" >
< OUTPUT: "output" >
< RANGE: "range" >
< SELECT: " select">
< THEN: "then" >
< TRUE: "true" >
< WHERE: "where">
< BOOLTYPE : "bool" >
< DATETYPE : "date" >
< FLOATTYPE : "float" >
< HTMLTYPE : "html" >
< IMAGETYPE : "image" >
< INTTYPE : "int" >
< PSTYPE : "ps" >
< STRINGTYPE : "string" >
< TEXTTYPE : "text" >
< URLTYPE : "url" >
}
<< Lexical Rules >>= TOKEN : /* LITERALS */ {
< INTEGER:
<DECIMAL> I <HEX> j <OCTAL> >
< #DECIMAL: ["l"-"9"] (["0"-"9"])* >
I
< #HEX: "0" ["x","X"] ( ["0"-"9", "a"-"f " , "A"-"F"] )+ >
I
< #OCTAL : " 0 " ( [ " 0 " - " 7 " ] ) * >
I
< FLOATING_POINT :
(["0"-"9"])+ "." (["0"-"9"] )* (<EXPONENT>)? ( [ " f " , "F" , "d" , "D" ] ) ?
I "." (["0"-"9"])+ (<EXPONENT>)? ( [ " f " , "F" , "d" , "D" ] ) ? j ( ["0"-"9"] )+ <EXPONENT> ( [ " f " , "F" , "d" , "D" ] ) ? j (["0"-"9"])+ (<EXPONENT>) ? [ " f " , "F" , "d" , "D" ] >
I
< #EXPONENT: ["e","E"] (["+","-"] )? ( ["0"-"9"])+ >
I
< CHARACTER:
( ("["'", "\\", "\n","\r"]) I ("\\"
( [ "n" , " t " , "b" , "r " , " f " , " \ \ »,'"»," \ " " ]
I [ " 0 " - " 7 " ] ( [ " 0 " - " 7 " ] ) ? j [ " 0 " - " 3 " ] [ " 0 " - " 7 " ] [ " 0 " - " 7 " ]
) < STRING:
("\\"
( ["n" , "t", "b", "r" , "f " , "\\" , " ' ", "\" " ]
I [ " 0 " - " 7 " ] ( [ " 0 " - " 7 " ] ) ? j [ " 0 " - " 3 " ] [ " 0 " - " 7 " ] [ " 0 " - " 7 " ]
) )
}
« Lexical Rules »= TOKEN : /* IDENTIFIERS */ {
< ID: ("#")? <LETTER> ( [ "a"- "z ", "A" - "Z" , " 0 " -"9 ","_", "."] ) * > I < #LETTER : [ "a" - "z" , "A" - "Z " ] > j < #DIGIT : ["0"-"9"] > }
<< Lexical Rules >>= TOKEN : /* SEPARATORS */ {
< LPAREN "C >
| < RPAREN " ) " > j < LBRACE " { " > j < RBRACE " } " > j < LBRACKET : " [ " >
| < RBRACKE : " ] " > j < SEMICOLON: "; " > j < COMMA: ", " > j < POP : " ' " > j < HASH: "#" > j < UNDER: "_" > j < ARROW: "->" >
}
« Lexical Rules »=
TOKEN : /* OPERATORS */
{
< BAR: " | " >
| < DOT : " . " >
| < COLON: " : " >
1 < LE "<=" > j < GE ">=" > j < NE j < GT "> ' > | < LT: "<" > j < EQ: "= » >
< PLUS: > j < MINUS: >
1 < STAR: >
1 < SLASH: "/ >
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledgeε and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defectε or εuggestions for change and
* improvements to the code. */
/* \subsection{Symbol Table}
*/ /* The symbol table is implemented by means of a hash table.
*/ /*
*/ /*
*/ /* <AlreadyDefined. java>=
*/ package Util; import COM.objectspace. jgl. *,- import java.util.*; import java. io. * ,- public class AlreadyDefined extends Exception { public AlreadyDefined () { super 0 ; } public AlreadyDefined(String name) { super (name); } }
/*
* Copyright 1997 AT&T Labε — Reεearch
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement . * The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code. */ package Util; import COM.objectspace. gl. *; import java . io . * ; import java.uti1. * ; **
* The class <code>Environment</code> represents a set of all environme nt
* variables used in STRUDEL.
* <p>
* This is the list of all environment variables used in the code.
* There are two distinction between these variables> they are classifi ed
* according to two directions:
* <p>
* 1) basic vs. computed: Some of them have input values (the basic var iables)
* and the value of the others (the computed variables ) is calculated used
* some εpecific rule based on the value of the basic ones.
* <p>
* 2) mutable vs. imutable: the value of the imutable variables can be changed
* in the user environment which is loaded at the beggining of the exe cution
* but they can not be changed during execution. The value of the mutab le
* variables can change during execution.
* <p>
* <dl>
* <dt> STRUDELDIR</dt>
* <dd>
* The directory where the sources of strudel are (basic, immutable) .
* It is used to compute the path to the library (DOT) and the
* path to the strudel image (IMAGE) .
* default: /home/dana/strudel
* </ddx/dl>
* <dlxdt>DB_DIR</dt>
* <dd>
* The directory where the database is stored (basic, imutable) .
* It is used to compute the path to the current database (INPUT_DIR) .
* default: $ (STRUDELDIR) /database
* </ddx/dl>
*
* <dlxdt>DB_NAME</dt>
* <dd>
* The name of the database (basic, imutable) .
* It is used to compute the path to the current graph ( ) .
* no default * </ddx/dl>
*
* <dlxdt>QUERY_FILTER</dt>
* <dd>
* The suffix for the StruQL queries (basic, imutable) .
* Used for filtering in GUI.
* default: .st
* </ddx/dl> *
* <dlxdt>STOREDGRAPH_FILTER</dt>
* <dd>
* The suffix for files in DDL format (basic, imutable) .
* Used for filtering in GUI.
* default: .DDL
* </ddx/dl>
*
* <dlxdt>IMAGE</dt>
* <dd>
* The path to the Strudel image (computed, imutable) .
* Depends on: STRUDELDIR
* rule: $ (STRUDELDIR) /src/GUI/images/background. gif
* </ddx/dl> *
* <dlxdt>DOT </dt>
* <dd>
* The path to the dot package (computed, imutable) .
* Depends on: STRUDELDIR
* rule: $ (STRUDELDIR) /lib/graphvizl_2/dot
* </ddx/dl>
*
* <dlxdt>INPUT_DIR</dt>
* <dd>
* The directory to the current database (computed, imutable) .
* Depends on: STRUDELDIR, DB_NAME
* rule : $ (DB_DIR) /$ (DB_NAME)
* </ddx/dl> *
* <dlxdt>STRUDEL_TMP</dt>
* <dd>
* The directory used for temporary files (computed, imutable) .
* Depends on: STRUDELDIR, DB_NAME
* rule : $ (INPUT_DIR) /tmp
* </ddx/dl>
*
* <dlxdt>QEP</dt>
* <dd>
* The file containing the last QEP (computed, imutable) .
* Depends on: STRUDELDIR, DB_NAME
* rule: $(STRUDEL_TMP)/QEP
* </ddx/dl> *
* <dlxdt>GS</dt>
* <dd>
* The file containing the last Graph Schema (computed, imutable) * Depends on: STRUDELDIR, DB_NAME
* rule: $ (STRUDEL_TMP) /GraphSchema
* </ddx/dl>
*
* <dlxdt>QUERY_DIRECTORY</dt>
* <dd>
* The directory for queries (computed, imutable) .
* Depends on: STRUDELDIR, DB_NAME
* rule: $ (INPUT_DIR) /queries
* </ddx/dl> *
* <dlxdt>ALIAS</dt>
* <dd>
* The file containing the Aliases used in Strudel (computed, imutable)
* Depends on: STRUDELDIR, DB_NAME
* rule: $ (QUERY_DIRECTORY) /ALIAS
* </ddx/dl>
*
* ©author Jaewoo Kang
* ©author Daniela Florescue
* ©version 1.00, 09 Sep 1997
* ©since STRUDEL1.0 */
public class Environment { private static Properties prop_; public static void loadEnv (String STRUDELDIR, String USERENV) throws IOException { try { prop_ = new Properties ( ) ; prop_.put ( "STRUDELDIR" , STRUDELDIR) ; prop_. load(new FilelnputStream(USERENV) ) ; updateDependantVariables ( ) ; } catch (IOException e) {
System.err.println (e. toString ( ) ) ,- throw e; } } public static void loadEnv(String STRUDELDIR) throws IOException {
String curdir = System. getProperty( "user. dir" ) ; prop_ = new Properties ( ) ; prop_.put ( "STRUDELDIR" , STRUDELDIR) ; prop_.put("DB_DIR" , curdir. substring (0, curdir .lastlndexOf (File. sep arator) ) ) ; prop_.put ( "DB_NAME" , curdir . substring (curdir . lastlndexOf (File . separ ator)+l) ); prop_.put ( "STOREDGRAPH_FILTER" , " .DDL" ) ; prop_.put ( "QUERY_FILTER" , " . st " ) ; updateDependantVariables ( ) ,- } public static String getEnv(String env) { return prop_. getProperty(env) ; } public static String getSysEnv(String env) { return System. getProperties 0.getProperty(env) ; } public static void setEnv(String env, String value) prop_.put {env, value) ; }
private static void updateDependantVariableε ( ) { prop_.put ( " MAGE" , prop_. getProperty ( "STRUDELDIR" ) +File . εeparator+ " src " +File . separator+"GUI "+File . separator+ "background. gif " ) ; prop_.put ( "DOT" , prop_. getProperty( "STRUDELDIR" ) +File. εeparator+"li b" +File . separator+"graphvizl_2 "+File . separator+ "dot" ) ; prop_.put ( "INPUT_DIR" , prop_. getProperty( "DB_DIR" ) +File.separator+ prop_ . getProperty ( "DB_NAME" ) ) ; prop_.put ( " STRUDEL_TMP" , prop_. getProperty( "INPUT_DIR" ) +File. separa tor+"tmp") ; prop_.put ( "QEP" , prop_. getProperty ( "STRUDEL_TMP" ) +File. separator+ "Q EP"); prop_.put ( "GS" , prop_. getProperty ( "STRUDEL_TMP" ) +File. separator+"Gr aphSchema" ) ; prop_.put ( "QUERY_DIRECTORY" , prop_.getProperty( "INPUT_DIR" ) +File . s eparator+ "queries " ) ; prop_.put ( "ALIAS" , prop_. getProperty ( "QUERY_DIRECTORY" ) +File . separa tor+ "ALIAS") ; } public static void parseArguments (String args[], Hashtable arguments) throws Exception {
String env_file = null;
String strudel_dir = null; int i; for (i=0,-i<args. length;i++) { if (args[i] .startsWithf "-" ) && i < args.length-1) { if (args [i] .equals ( "-env" ) ) { env_file=args [i+1] ,- i++; } else if (args [i] .equals ( "-εdir" ) ) { strudel_dir=args [i+1] ; i++; } else { if (arguments. get (args [i] ) == null) throw new RuntimeException ( "Option "+args[i]+" not recogniz ed.") if (args [i] . equals ( " -i " ) ) { while ( i < args . length-1 && ! args [i+1] . startsWith ( " - " ) ) { String input = args [i+1 ] ; int ind = input. lastlndexOf ('.'); String input_graph=null; if (ind < 0) input_graph=input; else input_graph=input . substring (0 , ind) ; ( (Queue)arguments.get ( " -i" ) ) .push(input_graph) ; i++; } } else {
String option = args[i]; while (i < argε.length-1 && !args [i+1] .startsWithC-" ) ) ( (Queue) arguments. get (option) ) .push (args [i+1] ) ; i++; } } } } else throw new RuntimeException ( "Invalid argument "+args[i]); } if (strudel_dir == null) throw new RuntimeException( "STRUDELDIR is undefined."); if (env_file == null)
Environment . loadEnv(strudel_dir) ; elεe
Environment . loadEnv(strudel_dir, env_file) ;
} /*
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledgeε
* and,agrees to keep the code confidential and use the code εolely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitnesε
* for a particular purpoεe, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratorieε
* with reports of any errorε, defects or suggestions for change and
* improvements to the code. */ package Util; import COM.objectspace. jgl. *; import java.util.*; import java. io . * ; import DataRepository. * ,- import DDL. * ,- public class FileUtility { public static DataGraph loadGraph(String input_graph) throws Exceptio n {
String input_ddl = Environment . getEnv( "INPUT_DIR" ) +File . separator* input_graph+File . separator* "data" +File . separator+input_graph+ " . DD
L" try {
DataGraph g = DataRepository. getGraph (input_graph) ; return g; } catch (NotFound e) { return loadGraphFile (input_ddl ) ; }
public static DataGraph loadGraphFile (String input_ddl) throws Except ion {
StoredDataGraph g = null; try { g= (StoredDataGraph) DDLParser .parse ( input_ddl ) ; DataRepository. addstoredGraph (g) ,- } catch (AlreadyDefined d) {
System. err.println (d. toString ( ) ) ,- } catch (Exception e) {
System. err.println ( "Load Failed: "+e. toStringO ) ; e .printStackTrace ( ) ,- throw e; } return g; } public static String readFile (String file) { String rdata = " " ; BufferedReader br=null; try { br = new BufferedReader (new FileReader (file) ) ;
String line; while ( (line=br.readLine( ) ) != null) { rdata += line+"\n"; } br . close ( ) ; } catch (IOException e) {
System. err.println ( "Warning: Cannot read file '"+file+"' :"+e.toS tring ( ) ) ; rdata = " " ,- } return rdata; }
// Map filename into a string that is unique in the "names" map. // "names" maps unique name to absolute path of filename public static String fixedFilename (HashMap names, String filename) th rows NotFound {
File f = new File (filename) ; if (f.existsO) {
String nameonly = f.getName();
String absname = f . getAbsolutePath( ) ,-
String fixedna e = (String) names. get (nameonly) ; // Preserve the suffix int ind = absname . lastlndexOf ('.'); String suffix = " " ; if (ind > 0) suffix = absname. substring( ind) ; int split = absname. lastlndexOf (File. separator) ; while (fixedname != null && ! fixedname. equals (absname) && split > 0) {
String abs = absname. substring ( split) ; int code = abs .hashCode ( ) ; if (code < 0) code = 0 - code; nameonly = "_F"+Integer. toString (code) +suffix; fixedname = ( String) names. get (nameonly) ,- split = absname. lastlndexOf (File. separator, split-1) ; }
// Guaranteed to be unique if (split < 0) nameonly = absname . replace ( f . separatorChar , '_' ) ; names.put (nameonly, absname); return nameonly; } else throw new NotFound( "Warning: file ' "+filename+" ' does not ex ist.") ; }
}
* Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows, the user acknowledges
* and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basiε with no warranty, either expreεε or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defectε or suggestions for change and
* improvements to the code. */
/ * <NotFound. java>=
*/ package Util; import COM. objectspace . jgl . * ,- import java.util.*,- import java.io. *; public class NotFound extends Exception { public NotFound (String name) { super (name); } }
Copyright 1997 AT&T Labs — Research
* By receiving and using the code that follows , the user acknowledges * and agrees to keep the code confidential and use the code solely for
* non-commercial research. The user further acknowledges and agrees th at
* the code is not an official product of AT&T Corp., and is provided
* on an "as is" basis with no warranty, either express or implied, in eluding
* but not limited to implied warranties of merchantability and fitness
* for a particular purpose, and any warranties of noninfringement .
* The user shall use reasonable efforts to provide AT&T Laboratories
* with reports of any errors, defects or suggestions for change and
* improvements to the code . */ package Wrapper; import COM.objectspace. jgl. *; import java . lang. * ; import java.util.*; import java . io . * ; import DataRepository.*;
public final class Wrapper { /* Constructor */ public Wrapper (String name) { this .name=name; }
/* Display Methods */ public String toStringO { return name;
} public void print (PrintStream out) { out .println ( "wrapper ' s name : " +name) ; }
/* Get Methods */ public String getName ( ) { return name; }
/* Query Processing Methods */ public Array selectLeafs (DataValue value) { return new Array ( ) ;
/* to be completed */ } public Array getLeafObjects ( ) { return new Array( ) ,- /* to be completed */ } public Array getEdges ( ) { return new Array( ) ;
/* to be completed */ } public Array getEdges (DataAttribute a) { return new Array( ) ;
/* to be completed */ } public Array getObjects () { return new ArrayO ;
/* to be completed */ } public Array getlnternalObjectε ( ) { return new ArrayO ;
/* to be completed */ } public Array getObjects (DataCollection c) { return new Array( ) ;
/* to be completed */ } public Array outObjects (InternalDataObject o) { return new Array ( ) ;
/* to be completed */ } public Array inObjects (DataObject o) { return new ArrayO ;
/* to be completed */ } public Array outObjects (InternalDataObject o, DataAttribute a) { return new Array( ) ;
/* to be completed */ } public Array inObjects (DataObject o, DataAttribute a) { return new Array ( ) ,-
/* to be completed */ } public Array outEdges (InternalDataObject o) { return new ArrayO;
/* to be completed */ } public Array inEdges (DataObject o) { return new Array ( ) ;
/* to be completed */ } public Array outAttribute (InternalDataObject o) { return new Array( ) ,-
/* to be completed */ } public Array inAttribute (DataObject o) { return new ArrayO ;
/* to be completed */ } public boolean check (DataObject o, DataAttribute a, DataObject ol) { return false;
/* to be completed */ }
/* Data */ private String name;

Claims

What is claimed is:
1. A method for managing a web-site, comprising the steps of: receiving an information definition query for defining an integrated view of non-uniform information retrieved from a plurality of sources and stored in a plurality of formats; creating said integrated view according to said information definition query; receiving a site definition query for defining a site view for said non-uniform information at the website; creating said site view according to said site definition query; and presenting said non-uniform information on the website.
2. The method of claim 1, wherein said non-uniform information is graphically presented.
3. The method of claim 2, wherein sa^d non-uniform information is graphically presented using a Hypertext Markup Language format.
4. The method of claim 3, wherein said information is stored in at least one of a group of formats comprising a Hypertext Markup Language format, a Relational Database format, an Object Oriented Database format, and a uniform system format.
5. The method of claim 4, wherein said uniform system format is a STRUDEL format.
6. The method of claim 5, wherein said plurality of sources are accessible via a network.
" 7. The method of claim 6, wherein said network is a packet-switched network.
8. The method of claim 7, wherein said packet-switched network is a World Wide Web network.
9. The method of claim 8, wherein said non-uniform information is retrieved from each source utilizing a search mechanism appropriate for accessing information stored therein, and wherein said integrated view is created using said search mechanism.
10. The method of claim 9, wherein multiple site definition queries, and said integrated information is structured according to each site definition query.
11. The method of claim 1, wherein said integrated view is created using a data graph.
12. The method of claim 1, wherein said site view is created using a site graph.
13. The method of claim 1, wherein said non-uniform information is presented using a Hypertext Markup Language generator.
14. The method of claim 1, further comprising the step of processing a user defined query to generate said information definition query and site definition query.
15. An apparatus for managing a web-site, comprising: means for receiving an information definition query for defining an integrated view of non-uniform -5 information retrieved from a plurality of sources and stored in a plurality of formats; means for creating said integrated view according to said information definition query; means for receiving a site definition query for 0 defining a site view for said non-uniform information at the web-site; means for creating said site view according to said site definition query; and means for presenting said non-uniform information on 5 the web-site.
16. The apparatus of claim 15, wherein said non-uniform information is graphically presented.
0 17. The apparatus of claim 16, wherein said non-uniform information is graphically presented using a Hypertext Markup Language format.
18. The apparatus of claim 17, wherein said information 5 is stored in at least one of a group of formats comprising a Hypertext Markup Language format, a Relational Database format, an Object Oriented Database format, and a uniform system format.
0 19. The apparatus of claim 18, wherein said uniform system format is a STRUDEL format.
20. The apparatus of claim 19, wherein said plurality of sources are accessible via a network.
21. The apparatus of claim 20, wherein said network is a packet-switched network.
22. The apparatus of claim 21, wherein said packet- switched network is a World Wide Web network.
23. The apparatus of claim 22, wherein said non-uniform information is retrieved from each source utilizing a search mechanism appropriate for accessing information stored therein, and wherein said integrated view is created using said search mechanism.
24. The apparatus of claim 23, wherein multiple site definition queries, and said integrated information is structured according to each site definition query.
25. The apparatus of claim 15, wherein said integrated view is created using a data graph.
26. The apparatus of claim 15, wherein said site view is created using a site graph.
27. The apparatus of claim 15, wherein said non-uniform information is presented using a Hypertext Markup Language generator.
28. The apparatus of claim 15, further comprising a means for processing a user defined query to generate said information definition query and site definition query.
29. An apparatus for managing a web-site, comprising: a terminal; a network coupled to said terminal; a plurality of servers storing non-uniform data connected to said network and accessible via said terminal; a query processor coupled to said servers via said network for defining an integrated view of said non- uniform data; a mediator coupled to said query processor for receiving said definition via a site definition query, and creating said integrated view; a site definition module coupled to said mediator and said query processor for receiving a site definition query from said query processor for structuring said non- uniform data at the web-site; and a hypertext markup language generator for graphically presenting said structured non-uniform data at the web-site.
30. The method of claim 1, wherein said query statements are generated using StruQL.
31. The apparatus of claim 15, wherein said query statements are generated using StruQL.
32. A computer for managing a website, comprising: a memory containing: a program for receiving an information definition query for defining an integrated view of non- uniform information retrieved from a plurality of sources and stored in a plurality of formats; a program for creating said integrated view according to said information definition query;
a program for receiving a site definition query for defining a site view for said non-uniform information at the web-site; a program for creating said site view according to said site definition query; a program for presenting said non-uniform information on the web-site; and a processor coupled to said memory .for running said programs.
PCT/US1998/001897 1997-02-06 1998-02-03 Method and apparatus for web site management WO1998035305A1 (en)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
US3689897P 1997-02-06 1997-02-06
US60/036,898 1997-02-06
US08/931,667 US5956720A (en) 1997-02-06 1997-09-17 Method and apparatus for web site management
US08/931,667 1997-09-17

Publications (1)

Publication Number Publication Date
WO1998035305A1 true WO1998035305A1 (en) 1998-08-13

Family

ID=26713604

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/US1998/001897 WO1998035305A1 (en) 1997-02-06 1998-02-03 Method and apparatus for web site management

Country Status (2)

Country Link
US (1) US5956720A (en)
WO (1) WO1998035305A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
FR2793910A1 (en) * 2000-03-20 2000-11-24 Ibm Publication of dynamic web pages and a procedure for ensuring that such pages are up to date and refer only to other updated pages uses a software system that ensures referenced pages are also updated

Families Citing this family (74)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6684369B1 (en) 1997-06-19 2004-01-27 International Business Machines, Corporation Web site creator using templates
US6883020B1 (en) * 1997-06-26 2005-04-19 Hewlett-Packard Development Company, L.P. Apparatus and method for filtering downloaded network sites
JP3368804B2 (en) * 1997-07-08 2003-01-20 トヨタ自動車株式会社 Hypertext transmission method and hypertext transmission server device
US6571243B2 (en) * 1997-11-21 2003-05-27 Amazon.Com, Inc. Method and apparatus for creating extractors, field information objects and inheritance hierarchies in a framework for retrieving semistructured information
US6449646B1 (en) 1998-10-13 2002-09-10 Aspect Communications Corporation Method and apparatus for allocating mixed transaction type messages to resources via an integrated queuing mechanism
US7552166B2 (en) * 1999-02-22 2009-06-23 Chack Michael A Method of queuing requests to access a communications network
US6202062B1 (en) * 1999-02-26 2001-03-13 Ac Properties B.V. System, method and article of manufacture for creating a filtered information summary based on multiple profiles of each single user
US6556659B1 (en) 1999-06-02 2003-04-29 Accenture Llp Service level management in a hybrid network architecture
US6542593B1 (en) 1999-06-02 2003-04-01 Accenture Llp Rules database server in a hybrid communication system architecture
US6195697B1 (en) * 1999-06-02 2001-02-27 Ac Properties B.V. System, method and article of manufacture for providing a customer interface in a hybrid network
US6442547B1 (en) 1999-06-02 2002-08-27 Andersen Consulting System, method and article of manufacture for information service management in a hybrid communication system
US6356896B1 (en) * 1999-08-16 2002-03-12 International Business Machines Corporation Data visualization of queries over joins
EP1104905A1 (en) * 1999-11-09 2001-06-06 gaudia.com GmbH A system, method and computer program for defining products
US7117260B2 (en) 2000-01-27 2006-10-03 American Express Travel Related Services Company, Inc. Content management application for an interactive environment
US20010047397A1 (en) * 2000-02-18 2001-11-29 Jameson David H. Method and system for using pervasive device to access webpages
US7152062B1 (en) 2000-11-21 2006-12-19 Actuate Corporation Technique for encapsulating a query definition
US7124144B2 (en) * 2000-03-02 2006-10-17 Actuate Corporation Method and apparatus for storing semi-structured data in a structured manner
US7707159B2 (en) * 2000-03-02 2010-04-27 Actuate Corporation Method and apparatus for storing semi-structured data in a structured manner
US6449620B1 (en) * 2000-03-02 2002-09-10 Nimble Technology, Inc. Method and apparatus for generating information pages using semi-structured data stored in a structured manner
US6581062B1 (en) 2000-03-02 2003-06-17 Nimble Technology, Inc. Method and apparatus for storing semi-structured data in a structured manner
US6311194B1 (en) 2000-03-15 2001-10-30 Taalee, Inc. System and method for creating a semantic web and its applications in browsing, searching, profiling, personalization and advertising
US7539623B1 (en) 2000-04-06 2009-05-26 Medical Central Online Method and a system for providing bed availability information on a computer network
US20010054068A1 (en) * 2000-06-14 2001-12-20 Updatethis, Inc. System and method for maintaining a web site
WO2002027551A2 (en) 2000-08-01 2002-04-04 Nimble Technology, Inc. Nested conditional relations (ncr) model and algebra
WO2002021259A1 (en) * 2000-09-08 2002-03-14 The Regents Of The University Of California Data source integration system and method
US6889222B1 (en) * 2000-12-26 2005-05-03 Aspect Communications Corporation Method and an apparatus for providing personalized service
WO2002077871A1 (en) * 2001-02-26 2002-10-03 Walter Reed Army Institute Of Research Browser for an accident and incident registry
US20030014504A1 (en) * 2001-06-29 2003-01-16 Hess Christopher L. Method and apparatus for dynamic common gateway interface Web site management
EP1288793A1 (en) * 2001-08-27 2003-03-05 Sony NetServices GmbH Translation text management system
US6725212B2 (en) 2001-08-31 2004-04-20 International Business Machines Corporation Platform-independent method and system for graphically presenting the evaluation of a query in a database management system
US7028225B2 (en) * 2001-09-25 2006-04-11 Path Communications, Inc. Application manager for monitoring and recovery of software based application processes
US8195714B2 (en) 2002-12-11 2012-06-05 Leaper Technologies, Inc. Context instantiated application protocol
US7925246B2 (en) 2002-12-11 2011-04-12 Leader Technologies, Inc. Radio/telephony interoperability system
US7191431B2 (en) * 2002-12-20 2007-03-13 International Business Machines Corporation System and method for selecting a translator to translate a component request using semantic typing
US7062506B2 (en) * 2003-01-24 2006-06-13 The Cobalt Group, Inc. Staged publication and management of dynamic webpages
US20040168066A1 (en) * 2003-02-25 2004-08-26 Alden Kathryn A. Web site management system and method
US20050209996A1 (en) * 2004-03-17 2005-09-22 Stewart Kelsey B System and method for developing and implementing on-line marketing techniques
US20060112073A1 (en) * 2004-11-22 2006-05-25 Jensen David L Interface building/design tool for generating nested interface systems and displays
US7779049B1 (en) * 2004-12-20 2010-08-17 Tw Vericept Corporation Source level optimization of regular expressions
US7849104B2 (en) * 2007-03-01 2010-12-07 Microsoft Corporation Searching heterogeneous interrelated entities
US7681085B2 (en) * 2007-06-15 2010-03-16 Microsoft Corporation Software reliability analysis using alerts, asserts and user interface controls
US7870114B2 (en) 2007-06-15 2011-01-11 Microsoft Corporation Efficient data infrastructure for high dimensional data analysis
US7739666B2 (en) * 2007-06-15 2010-06-15 Microsoft Corporation Analyzing software users with instrumentation data and user group modeling and analysis
US7747988B2 (en) * 2007-06-15 2010-06-29 Microsoft Corporation Software feature usage analysis and reporting
US8321798B2 (en) * 2007-06-28 2012-11-27 International Business Machines Corporation Containing and accessing multiple web browsers
US7818681B2 (en) * 2007-06-28 2010-10-19 International Business Machines Corporation Method and system for internally identifying a specific web browser for displaying a specific web page
US8200578B2 (en) * 2008-07-09 2012-06-12 Hill Matthew D Methods and systems for account management and virtual agent design and implementation
US8156419B2 (en) * 2008-07-17 2012-04-10 International Business Machines Corporation Intelligent preloads of views and asynchronous loading of models using the MVC design pattern
US8909683B1 (en) 2009-07-17 2014-12-09 Open Invention Network, Llc Method and system for communicating with internet resources to identify and supply content for webpage construction
US9645996B1 (en) 2010-03-25 2017-05-09 Open Invention Network Llc Method and device for automatically generating a tag from a conversation in a social networking website
US9565298B1 (en) * 2010-03-25 2017-02-07 Open Invention Network Llc Method and device for appending information in a conversation in a voice based networking website
US20120198324A1 (en) * 2011-01-27 2012-08-02 Ruchi Mahajan Systems, Methods, and Apparatuses to Write on Web Pages
US10482475B2 (en) 2011-02-10 2019-11-19 Adp Dealer Services, Inc. Systems and methods for providing targeted advertising
US11080734B2 (en) 2013-03-15 2021-08-03 Cdk Global, Llc Pricing system for identifying prices for vehicles offered by vehicle dealerships and other entities
CN103729479A (en) * 2014-01-26 2014-04-16 北京北纬通信科技股份有限公司 Web page content statistical method and system based on distributed file storage
US9449346B1 (en) 2014-05-21 2016-09-20 Plaid Technologies, Inc. System and method for programmatically accessing financial data
US9595023B1 (en) 2014-05-21 2017-03-14 Plaid Technologies, Inc. System and method for facilitating programmatic verification of transactions
CA3119897C (en) 2015-09-08 2022-08-09 Plaid Inc. Secure permissioning of access to user accounts, including secure deauthorization of access to user accounts
US10726491B1 (en) 2015-12-28 2020-07-28 Plaid Inc. Parameter-based computer evaluation of user accounts based on user account data stored in one or more databases
US10984468B1 (en) 2016-01-06 2021-04-20 Plaid Inc. Systems and methods for estimating past and prospective attribute values associated with a user account
US10332068B2 (en) 2016-04-21 2019-06-25 Cdk Global, Llc Systems and methods for stocking an automobile
US10853769B2 (en) 2016-04-21 2020-12-01 Cdk Global Llc Scheduling an automobile service appointment in a dealer service bay based on diagnostic trouble codes and service bay attributes
US10867285B2 (en) 2016-04-21 2020-12-15 Cdk Global, Llc Automatic automobile repair service scheduling based on diagnostic trouble codes and service center attributes
US10326858B2 (en) 2017-05-23 2019-06-18 Cdk Global, Llc System and method for dynamically generating personalized websites
US11468085B2 (en) 2017-07-22 2022-10-11 Plaid Inc. Browser-based aggregation
US10878421B2 (en) 2017-07-22 2020-12-29 Plaid Inc. Data verified deposits
US11190608B2 (en) 2018-03-21 2021-11-30 Cdk Global Llc Systems and methods for an automotive commerce exchange
US11501351B2 (en) 2018-03-21 2022-11-15 Cdk Global, Llc Servers, systems, and methods for single sign-on of an automotive commerce exchange
US11316862B1 (en) 2018-09-14 2022-04-26 Plaid Inc. Secure authorization of access to user accounts by one or more authorization mechanisms
US11887069B2 (en) 2020-05-05 2024-01-30 Plaid Inc. Secure updating of allocations to user accounts
US11327960B1 (en) 2020-10-16 2022-05-10 Plaid Inc. Systems and methods for data parsing
US11080105B1 (en) 2020-11-18 2021-08-03 Cdk Global, Llc Systems, methods, and apparatuses for routing API calls
US11514021B2 (en) 2021-01-22 2022-11-29 Cdk Global, Llc Systems, methods, and apparatuses for scanning a legacy database
US11803535B2 (en) 2021-05-24 2023-10-31 Cdk Global, Llc Systems, methods, and apparatuses for simultaneously running parallel databases

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5600831A (en) * 1994-02-28 1997-02-04 Lucent Technologies Inc. Apparatus and methods for retrieving information by modifying query plan based on description of information sources
US5793964A (en) * 1995-06-07 1998-08-11 International Business Machines Corporation Web browser system
US5860071A (en) * 1997-02-07 1999-01-12 At&T Corp Querying and navigating changes in web repositories
US5870559A (en) * 1996-10-15 1999-02-09 Mercury Interactive Software system and associated methods for facilitating the analysis and management of web sites
US5867495A (en) * 1996-11-18 1999-02-02 Mci Communications Corporations System, method and article of manufacture for communications utilizing calling, plans in a hybrid network

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
HU J ET AL: "WEBINTOOL: A GENERIC WEB TO DATABASE INTERFACE BUILDING TOOL", PROCEEDINGS. INTERNATIONAL WORKSHOP ON DATABASE AND EXPERT SYSTEMS APPLICATIONS, 9 September 1996 (1996-09-09), pages 285 - 290, XP002036862 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
FR2793910A1 (en) * 2000-03-20 2000-11-24 Ibm Publication of dynamic web pages and a procedure for ensuring that such pages are up to date and refer only to other updated pages uses a software system that ensures referenced pages are also updated

Also Published As

Publication number Publication date
US5956720A (en) 1999-09-21

Similar Documents

Publication Publication Date Title
WO1998035305A1 (en) Method and apparatus for web site management
US7496599B2 (en) System and method for viewing relational data using a hierarchical schema
US6571232B1 (en) System and method for browsing database schema information
US6917935B2 (en) Manipulating schematized data in a database
US6263328B1 (en) Object oriented query model and process for complex heterogeneous database queries
US7657570B2 (en) Optimizing aggregate processing
US7444643B2 (en) Accessing a ERP application over the internet using strongly typed declarative language files
US6006224A (en) Crucible query system
US6704726B1 (en) Query processing method
US7383255B2 (en) Common query runtime system and application programming interface
US6085188A (en) Method of hierarchical LDAP searching with relational tables
US6128611A (en) Internet-enabled generic application program for accessing hierarchical data
US6658624B1 (en) Method and system for processing documents controlled by active documents with embedded instructions
US7055142B2 (en) Permutation nuances of the integration of processes and queries as processes at queues
US20040267760A1 (en) Query intermediate language method and system
WO2001052063A9 (en) System and method for translating to and from hierarchical information systems
WO2000075849A2 (en) Method and apparatus for data access to heterogeneous data sources
WO1997035254A9 (en) Computer system and computer implemented process for representing software system descriptions and for generating executable computer programs and computer system configurations from software system descriptions
US7831614B2 (en) System and method for generating SQL using templates
WO1997035254A1 (en) Computer system and computer implemented process for representing software system descriptions and for generating executable computer programs and computer system configurations from software system descriptions
Alexaki et al. Managing RDF metadata for community webs
WO2001033387A2 (en) Apparatus, systems and methods for electronic data development, management, control and integration in a global communications network environment
US7058620B1 (en) Cross-platform subselect metadata extraction
de Ferreira Rezende et al. A practical approach to access heterogeneous and distributed databases
Lo et al. XAS: A system for accessing componentized, virtual XML documents

Legal Events

Date Code Title Description
AK Designated states

Kind code of ref document: A1

Designated state(s): CA JP

AL Designated countries for regional patents

Kind code of ref document: A1

Designated state(s): AT BE CH DE DK ES FI FR GB GR IE IT LU MC NL PT SE

DFPE Request for preliminary examination filed prior to expiration of 19th month from priority date (pct application filed before 20040101)
121 Ep: the epo has been informed by wipo that ep was designated in this application
NENP Non-entry into the national phase

Ref country code: JP

Ref document number: 1998534812

Format of ref document f/p: F

122 Ep: pct application non-entry in european phase