2362N/A * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2362N/A * or visit www.oracle.com if you need additional information or have any 0N/A * @summary Test that QueryExp.toString() is reversible 0N/A * @author Eamonn McManus 0N/A * @run clean QueryExpStringTest 0N/A * @run build QueryExpStringTest 0N/A * @run main QueryExpStringTest 0N/A // Commented-out tests below require change to implementation 11N/A// qattr, "className.attr", 11N/A// Preceding form now appears as className#attr, an incompatible change 11N/A// which we don't mind much because nobody uses the two-arg Query.attr. 0N/A gt,
"(12345678) > (2.5)",
0N/A lt,
"(12345678) < (2.5)",
0N/A eq,
"(12345678) = (2.5)",
0N/A in,
"12345678 in (12345678, 2.5)",
0N/A and,
"((12345678) > (2.5)) and ((12345678) < (2.5))",
0N/A or,
"((12345678) > (2.5)) or ((12345678) < (2.5))",
0N/A not,
"not ((12345678) > (2.5))",
11N/A// aPlus_BPlusC, "(A + (B + C)) > (0)", 0N/A throw new Exception(
"Expected in or like after expression");
0N/A /* This is very ugly. We might have "(q1) and (q2)" here, or 0N/A we might have "(e1) < (e2)". Since the syntax for a query 0N/A (q1) is not the same as for an expression (e1), but can 0N/A begin with one, we try to parse the query, and if we get an 0N/A exception we then try to parse an expression. It's a hacky 0N/A kind of look-ahead. */ 0N/A /* Look ahead to see if we have an arithmetic operator. */ 0N/A throw new Exception(
"Expected arithmetic operator after space");
0N/A throw new Exception(
"Expected space after arithmetic operator");
0N/A throw new Exception(
"Empty string found, expression expected");
11N/A if (
space >=
0 &&
rpar >=
0)
// string has both space and ), stop at first 11N/A else // string has only one, stop at it 0N/A if (c ==
'.' || c ==
'e' || c ==
'E') {