001: package org.zilonis.network.adapter;
002:
003: import java.util.StringTokenizer;
004:
005: /**
006: * Copyright (c) 2005 Elie Levy <elie.levy@zilonis.org> All rights reserved
007: *
008: * This License governs use of the accompanying Software, and your use of the
009: * Software constitutes acceptance of this license.
010: *
011: * You may use this Software for any non-commercial purpose, subject to the
012: * restrictions in this license. Some purposes which can be non-commercial are
013: * teaching, academic research, and personal experimentation. You may also
014: * distribute this Software with books or other teaching materials, or publish
015: * the Software on websites, that are intended to teach the use of the Software.
016: *
017: *
018: * You may not use or distribute this Software or any derivative works in any
019: * form for commercial purposes. Examples of commercial purposes would be
020: * running business operations, licensing, leasing, or selling the Software, or
021: * distributing the Software for use with commercial products.
022: *
023: * You may modify this Software and distribute the modified Software for
024: * non-commercial purposes, however, you may not grant rights to the Software or
025: * derivative works that are broader than those provided by this License. For
026: * example, you may not distribute modifications of the Software under terms
027: * that would permit commercial use, or under terms that purport to require the
028: * Software or derivative works to be sublicensed to others.
029: *
030: * You may use any information in intangible form that you remember after
031: * accessing the Software. However, this right does not grant you a license to
032: * any of the copyrights or patents for anything you might create using such
033: * information.
034: *
035: * In return, we simply require that you agree:
036: *
037: * Not to remove any copyright or other notices from the Software.
038: *
039: *
040: * That if you distribute the Software in source or object form, you will
041: * include a verbatim copy of this license.
042: *
043: *
044: * That if you distribute derivative works of the Software in source code form
045: * you do so only under a license that includes all of the provisions of this
046: * License, and if you distribute derivative works of the Software solely in
047: * object form you do so only under a license that complies with this License.
048: *
049: *
050: * That if you have modified the Software or created derivative works, and
051: * distribute such modifications or derivative works, you will cause the
052: * modified files to carry prominent notices so that recipients know that they
053: * are not receiving the original Software. Such notices must state: (i) that
054: * you have changed the Software; and (ii) the date of any changes.
055: *
056: *
057: * THAT THE SOFTWARE COMES "AS IS", WITH NO WARRANTIES. THIS MEANS NO EXPRESS,
058: * IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF
059: * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR ANY WARRANTY OF TITLE
060: * OR NON-INFRINGEMENT. ALSO, YOU MUST PASS THIS DISCLAIMER ON WHENEVER YOU
061: * DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.
062: *
063: *
064: * THAT NEITHER ZILONIS NOR THE AUTHOR WILL BE LIABLE FOR ANY DAMAGES RELATED TO
065: * THE SOFTWARE OR THIS LICENSE, INCLUDING DIRECT, INDIRECT, SPECIAL,
066: * CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE MAXIMUM EXTENT THE LAW PERMITS,
067: * NO MATTER WHAT LEGAL THEORY IT IS BASED ON. ALSO, YOU MUST PASS THIS
068: * LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE
069: * WORKS.
070: *
071: *
072: * That if you sue anyone over patents that you think may apply to the Software
073: * or anyone's use of the Software, your license to the Software ends
074: * automatically.
075: *
076: *
077: * That your rights under the License end automatically if you breach it in any
078: * way.
079: *
080: *
081: * Elie Levy reserves all rights not expressly granted to you in this license.
082: *
083: */
084:
085: public class EvaluatorFactory {
086:
087: public static ZilonisEvaluator getEvaluator(String expression,
088: String variables[]) {
089: if (isBooleanExpression(expression))
090: return new BooleanZilonisEvaluator(expression, variables); // SISCEvaluator(expression,variables);
091: return new ZilonisPrintOutEvaluator(expression, variables);
092: }
093:
094: public static boolean isBooleanExpression(String expression) {
095: StringTokenizer st = new StringTokenizer(expression, "( )");
096: String token = st.nextToken();
097: return (("==".equals(token)) || ("!=".equals(token))
098: || ("<".equals(token)) || (">".equals(token)));
099: }
100: }
|