Example usage for java.util Locale SIMPLIFIED_CHINESE

List of usage examples for java.util Locale SIMPLIFIED_CHINESE

Introduction

In this page you can find the example usage for java.util Locale SIMPLIFIED_CHINESE.

Prototype

Locale SIMPLIFIED_CHINESE

To view the source code for java.util Locale SIMPLIFIED_CHINESE.

Click Source Link

Document

Useful constant for language.

Usage

From source file:org.hippoecm.frontend.plugins.login.LoginPanel.java

private Locale getSelectedLocale() {
    if (selectedLocale.equals(Locale.CHINESE.getLanguage())) {
        // always use simplified Chinese, Wicket does not known Chinese without a country
        return Locale.SIMPLIFIED_CHINESE;
    }//from ww  w  .  ja v  a 2  s  . c  o m
    return new Locale(selectedLocale);
}

From source file:org.mifos.config.Localization.java

private synchronized void setLocaleMap() {
    if (LOCALE_MAP.isEmpty()) {
        LOCALE_MAP.put((short) 1, Locale.UK); // These were the options in personnel language list (pre Mifos 2.2)
        LOCALE_MAP.put((short) 2, new Locale("is", "IS")); // Icelandic
        LOCALE_MAP.put((short) 3, SPANISH); // Spanish
        LOCALE_MAP.put((short) 4, Locale.FRANCE); // French
        LOCALE_MAP.put((short) 5, Locale.SIMPLIFIED_CHINESE); // Chinese
        LOCALE_MAP.put((short) 6, new Locale("sw", "KE")); // Swahili
        LOCALE_MAP.put((short) 7, new Locale("ar", "DZ")); // Arabic
        LOCALE_MAP.put((short) 8, new Locale("pt", "AO")); // Portuguese
        LOCALE_MAP.put((short) 9, new Locale("km", "KH")); // Khmer
        LOCALE_MAP.put((short) 10, new Locale("lo", "LA")); // Lola
        LOCALE_MAP.put((short) 11, new Locale("hu", "HU")); // Hungarian
        LOCALE_MAP.put((short) 12, new Locale("te", "IN")); // Tegulu
        LOCALE_MAP.put((short) 13, new Locale("hi", "IN")); // Hindi
        LOCALE_MAP.put((short) 14, Locale.GERMAN);
        LOCALE_MAP.put((short) 15, new Locale("ru")); // Georgian
        LOCALE_MAP.put((short) 16, new Locale("ka")); // Russian
    }/* w w  w. j  a va2 s. c  om*/
}

From source file:net.pms.configuration.PmsConfigurationTest.java

/**
 * Test Logging Configuration defaults// w ww.  j av a 2s .c  o m
 */
@Test
public void testLoggingConfigurationDefaults() {
    // Test defaults and valid values where applicable
    assertFalse("LogSearchCaseSensitiveDefault", configuration.getGUILogSearchCaseSensitive());
    assertFalse("LogSearchMultiLineDefault", configuration.getGUILogSearchMultiLine());
    assertFalse("LogSearchRegEx", configuration.getGUILogSearchRegEx());
    assertTrue("LogFileNameValid", FileUtil.isValidFileName(configuration.getDefaultLogFileName()));
    assertEquals("LogFileNameDefault", configuration.getDefaultLogFileName(), "debug.log");
    File file = new File(configuration.getDefaultLogFileFolder());
    assertTrue("DefaultLogFileFolder", file.isDirectory());
    file = new File(configuration.getDefaultLogFilePath());
    assertTrue("DefaultLogFilePath", configuration.getDefaultLogFilePath().endsWith("debug.log"));
    assertFalse("LoggingBufferedDefault", configuration.getLoggingBuffered());
    assertEquals("LoggingFilterConsoleDefault", configuration.getLoggingFilterConsole(), Level.INFO);
    assertEquals("LoggingFilterLogsTabDefault", configuration.getLoggingFilterLogsTab(), Level.INFO);
    assertEquals("LoggingLogsTabLinebufferDefault", configuration.getLoggingLogsTabLinebuffer(), 1000);
    assertTrue("LoggingLogsTabLinebufferLegal",
            configuration.getLoggingLogsTabLinebuffer() >= PmsConfiguration.LOGGING_LOGS_TAB_LINEBUFFER_MIN
                    && configuration
                            .getLoggingLogsTabLinebuffer() <= PmsConfiguration.LOGGING_LOGS_TAB_LINEBUFFER_MAX);
    assertEquals("LoggingSyslogFacilityDefault", configuration.getLoggingSyslogFacility(), "USER");
    assertEquals("LoggingSyslogHostDefault", configuration.getLoggingSyslogHost(), "");
    assertEquals("LoggingSyslogPortDefault", configuration.getLoggingSyslogPort(), 514);
    assertFalse("LoggingUseSyslogDefault", configuration.getLoggingUseSyslog());
    assertEquals("getLanguageLocaleDefault", configuration.getLanguageLocale(),
            Languages.toLocale(Locale.getDefault()));
    assertEquals("getLanguageTagDefault", configuration.getLanguageTag(),
            Languages.toLanguageTag(Locale.getDefault()));
    configuration.getConfiguration().setProperty("language", "");
    assertEquals("getLanguageLocaleDefault", configuration.getLanguageLocale(),
            Languages.toLocale(Locale.getDefault()));
    assertEquals("getLanguageTagDefault", configuration.getLanguageTag(),
            Languages.toLanguageTag(Locale.getDefault()));
    configuration.getConfiguration().setProperty("language", "en-GB");
    assertEquals("getLanguageLocaleBritishEnglish", configuration.getLanguageLocale(),
            Locale.forLanguageTag("en-GB"));
    assertEquals("getLanguageTagBritishEnglish", configuration.getLanguageTag(), "en-GB");
    configuration.getConfiguration().setProperty("language", "en");
    assertEquals("getLanguageLocaleEnglish", configuration.getLanguageLocale(), Locale.forLanguageTag("en-US"));
    assertEquals("getLanguageTagEnglish", configuration.getLanguageTag(), "en-US");
    configuration.getConfiguration().setProperty("language", "zh");
    assertEquals("getLanguageLocaleChinese", configuration.getLanguageLocale(),
            Locale.forLanguageTag("zh-Hant"));
    assertEquals("getLanguageTagChinese", configuration.getLanguageTag(), "zh-Hant");
    configuration.setLanguage(Locale.UK);
    assertEquals("setLanguageUK", configuration.getLanguageLocale(), Locale.forLanguageTag("en-GB"));
    configuration.setLanguage(Locale.SIMPLIFIED_CHINESE);
    assertEquals("setLanguageSimplifiedChinese", configuration.getLanguageLocale(),
            Locale.forLanguageTag("zh-Hans"));
    configuration.setLanguage(Locale.TRADITIONAL_CHINESE);
    assertEquals("setLanguageTraditionalChinese", configuration.getLanguageLocale(),
            Locale.forLanguageTag("zh-Hant"));
    Locale locale = null;
    configuration.setLanguage(locale);
    assertEquals("setLanguageNull", configuration.getLanguageLocale(), Locale.forLanguageTag("zh-Hant"));
    String code = null;
    configuration.setLanguage(code);
    assertEquals("setLanguageNull", configuration.getLanguageLocale(), Locale.forLanguageTag("zh-Hant"));
    configuration.setLanguage("");
    assertEquals("setLanguageEmpty", configuration.getLanguageLocale(), Locale.forLanguageTag("zh-Hant"));
    configuration.setLanguage("en");
    assertEquals("setLanguageEnglish", configuration.getLanguageLocale(), Locale.forLanguageTag("en-US"));
}

From source file:com.example.carsharing.LongWayActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    photouri = Uri/* www  .  j  a  va 2s  .  co m*/
            .fromFile(new File(this.getExternalFilesDir(Environment.DIRECTORY_PICTURES), IMAGE_FILE_NAME2));
    System.out.println("abc");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_long_way);

    activity_drawer = new Drawer(this, R.id.long_way_layout);
    mDrawerToggle = activity_drawer.newdrawer();
    mDrawerLayout = activity_drawer.setDrawerLayout();

    // 
    standard_date = new SimpleDateFormat("yyyy-MM-dd", Locale.SIMPLIFIED_CHINESE);
    primary_date = new SimpleDateFormat("yyyyMMdd", Locale.SIMPLIFIED_CHINESE);

    queue = Volley.newRequestQueue(this);
    exchange = (ImageView) findViewById(R.id.longway_exchange);
    exchange.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            String temp = startplace.getText().toString();

            startplace.setText(endplace.getText().toString());
            endplace.setText(temp);

        }
    });

    bdriver = true;

    datebutton = (Button) findViewById(R.id.longway_dates);
    increase = (Button) findViewById(R.id.longway_increase);
    decrease = (Button) findViewById(R.id.longway_decrease);
    s1 = (TextView) findViewById(R.id.longway_count);
    sure = (Button) findViewById(R.id.longway_sure);
    sure.setEnabled(false);
    startplace = (EditText) findViewById(R.id.longway_start_place);
    endplace = (EditText) findViewById(R.id.longway_end_place);
    noteinfo = (EditText) findViewById(R.id.longway_remarkText);
    commute = findViewById(R.id.drawer_commute);
    shortway = findViewById(R.id.drawer_shortway);
    longway = findViewById(R.id.drawer_longway);
    drawericon = (ImageView) findViewById(R.id.drawer_icon);
    drawername = (TextView) findViewById(R.id.drawer_name);
    drawernum = (TextView) findViewById(R.id.drawer_phone);
    carbrand = (EditText) findViewById(R.id.longway_CarBrand);
    model = (EditText) findViewById(R.id.longway_CarModel);
    color = (EditText) findViewById(R.id.longway_color);
    setting = findViewById(R.id.drawer_setting);
    licensenum = (EditText) findViewById(R.id.longway_Num);

    licensenum.addTextChangedListener(numTextWatcher);
    carbrand.addTextChangedListener(detTextWatcher);
    color.addTextChangedListener(coTextWatcher);
    model.addTextChangedListener(moTextWatcher);
    startplace.addTextChangedListener(spTextWatcher);
    endplace.addTextChangedListener(epTextWatcher);

    final TextView content = (TextView) findViewById(R.id.longway_content);
    longway_group = (RadioGroup) findViewById(R.id.longway_radiobutton);
    passangerRadioButton = (RadioButton) findViewById(R.id.longway_radioButton02);
    driverRadioButton = (RadioButton) findViewById(R.id.longway_radioButton01);
    personalcenter = findViewById(R.id.drawer_personalcenter);
    taxi = findViewById(R.id.drawer_taxi);

    // judge the value of "pre_page"
    Bundle bundle = this.getIntent().getExtras();
    String PRE_PAGE = bundle.getString("pre_page");
    if (PRE_PAGE.compareTo("ReOrder") == 0) { // 
        startplace.setText(bundle.getString("stpmapname"));
        bstart = true;
        endplace.setText(bundle.getString("epmapname"));
        bend = true;
        datebutton.setText(bundle.getString("re_longway_startdate"));
        bdate = true;
    }
    // judge the value of "pre_page"

    // 
    SharedPreferences sharedPref = this.getSharedPreferences(getString(R.string.PreferenceDefaultName),
            Context.MODE_PRIVATE);
    UserPhoneNumber = sharedPref.getString(getString(R.string.PreferenceUserPhoneNumber), "0");

    // database
    db = new DatabaseHelper(getApplicationContext(), UserPhoneNumber, null, 1);
    db1 = db.getWritableDatabase();
    about = findViewById(R.id.drawer_respond);
    about.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent about = new Intent(LongWayActivity.this, AboutActivity.class);
            startActivity(about);
        }
    });
    setting.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent setting = new Intent(LongWayActivity.this, SettingActivity.class);
            startActivity(setting);
        }
    });

    // database end

    taxi.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
        }
    });

    personalcenter.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent personalcenter = new Intent(LongWayActivity.this, PersonalCenterActivity.class);
            personalcenter.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(personalcenter);
        }
    });

    // RadioGroup

    longway_group.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup arg0, int checkedId) {
            // TODO Auto-generated method stub18
            // ID

            // """"textView
            if (checkedId == passangerRadioButton.getId()) {
                bpassenager = true;
                bdriver = false;

                licensenum.setEnabled(false);
                carbrand.setEnabled(false);
                color.setEnabled(false);
                model.setEnabled(false);

                licensenum.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                carbrand.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                color.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                model.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                content.setText(getString(R.string.warningInfo_seatNeed));
                licensenum.setHintTextColor(Color.parseColor("#cccccc"));
                carbrand.setHintTextColor(Color.parseColor("#cccccc"));
                color.setHintTextColor(Color.parseColor("#cccccc"));
                model.setHintTextColor(Color.parseColor("#cccccc"));
                licensenum.setInputType(InputType.TYPE_NULL);
                carbrand.setInputType(InputType.TYPE_NULL);
                color.setInputType(InputType.TYPE_NULL);
                model.setInputType(InputType.TYPE_NULL);
            } else {
                bpassenager = false;
                bdriver = true;

                licensenum.setEnabled(true);
                carbrand.setEnabled(true);
                color.setEnabled(true);
                model.setEnabled(true);

                licensenum.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {

                        return null;
                    }
                } });
                carbrand.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return null;
                    }
                } });
                color.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {

                        return null;
                    }
                } });
                model.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {

                        return null;
                    }
                } });
                content.setText(getString(R.string.warningInfo_seatOffer));
                licensenum.setHintTextColor(Color.parseColor("#9F35FF"));
                carbrand.setHintTextColor(Color.parseColor("#9F35FF"));
                color.setHintTextColor(Color.parseColor("#9F35FF"));
                model.setHintTextColor(Color.parseColor("#9F35FF"));
                // licensenum.setText("");
                // carbrand.setText("");
                // color.setText("");
                // model.setText("");
                licensenum.setInputType(InputType.TYPE_CLASS_TEXT);
                carbrand.setInputType(InputType.TYPE_CLASS_TEXT);
                color.setInputType(InputType.TYPE_CLASS_TEXT);
                model.setInputType(InputType.TYPE_CLASS_TEXT);

                // start!
                selectcarinfo(UserPhoneNumber);
                // end!
            }
            confirm();
        }

        private void selectcarinfo(final String phonenum) {
            // TODO Auto-generated method stub
            String carinfo_selectrequest_baseurl = getString(R.string.uri_base)
                    + getString(R.string.uri_CarInfo) + getString(R.string.uri_selectcarinfo_action);

            Log.d("carinfo_selectrequest_baseurl", carinfo_selectrequest_baseurl);
            StringRequest stringRequest = new StringRequest(Request.Method.POST, carinfo_selectrequest_baseurl,
                    new Response.Listener<String>() {

                        @Override
                        public void onResponse(String response) {
                            // TODO Auto-generated method stub
                            Log.d("carinfo_select", response);
                            String jas_id = null;
                            JSONObject json1 = null;
                            try {
                                json1 = new JSONObject(response);
                                JSONObject json = json1.getJSONObject("result");
                                jas_id = json.getString("id");

                                if (jas_id.compareTo("") != 0) { // 

                                    carinfochoosing_type = 2;

                                    carbrand.setText(json.getString("carBrand"));
                                    model.setText(json.getString("carModel"));
                                    licensenum.setText(json.getString("carNum"));
                                    color.setText(json.getString("carColor"));

                                }
                                {
                                    carinfochoosing_type = 1;
                                }

                            } catch (JSONException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                        }

                    }, new Response.ErrorListener() {

                        @Override
                        public void onErrorResponse(VolleyError error) {
                            // TODO Auto-generated method stub
                            Log.e("carinfo_selectresult_result", error.getMessage(), error);
                        }
                    }) {
                protected Map<String, String> getParams() {
                    Map<String, String> params = new HashMap<String, String>();
                    params.put("phonenum", phonenum);
                    return params;
                }
            };

            queue.add(stringRequest);
        }
    });

    sure.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

            if (longway_group.getCheckedRadioButtonId() == passangerRadioButton.getId())
                userrole = "p";
            else
                userrole = "d";

            // start!
            Context phonenumber = LongWayActivity.this;
            SharedPreferences filename = phonenumber
                    .getSharedPreferences(getString(R.string.PreferenceDefaultName), Context.MODE_PRIVATE);
            username = filename.getString("refreshfilename", "0");
            longway_request(username, userrole, datebutton.getText().toString(),
                    startplace.getText().toString(), endplace.getText().toString(),
                    noteinfo.getText().toString());
            // end!
        }

        private void longway_request(final String longway_phonenum, final String longway_userrole,
                final String longway_startdate, final String longway_startplace,
                final String longway_destination, final String longway_noteinfo) {
            // TODO Auto-generated method stub

            String longway_addrequest_baseurl = getString(R.string.uri_base)
                    + getString(R.string.uri_LongwayPublish) + getString(R.string.uri_addpublish_action);
            // + "phonenum=" + longway_phonenum
            // + "&userrole=" + longway_userrole
            // + "&startdate=" + standard_longway_startdate
            // + "&startplace=" + longway_startplace
            // + "&destination=" + longway_destination
            // + "&noteinfo=" + longway_noteinfo;

            // Log.d("longway_baseurl",longway_addrequest_baseurl);

            StringRequest stringRequest = new StringRequest(Request.Method.POST, longway_addrequest_baseurl,
                    new Response.Listener<String>() {

                        @Override
                        public void onResponse(String response) {
                            Log.d("longway_result", response);
                            JSONObject json1 = null;
                            try {
                                json1 = new JSONObject(response);
                                requestok = json1.getBoolean("result");
                            } catch (JSONException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                            if (requestok == true) {

                                if (carinfochoosing_type == 1) {
                                    // add
                                    // start!
                                    carinfo(longway_phonenum, licensenum.getText().toString(),
                                            carbrand.getText().toString(), model.getText().toString(),
                                            color.getText().toString(), String.valueOf(sum), 1);
                                    // end!
                                } else {
                                    // update
                                    // start!
                                    carinfo(longway_phonenum, licensenum.getText().toString(),
                                            carbrand.getText().toString(), model.getText().toString(),
                                            color.getText().toString(), String.valueOf(sum), 2);
                                    // end!
                                }

                                Intent sure = new Intent(LongWayActivity.this, OrderResponseActivity.class);
                                sure.putExtra(getString(R.string.request_response), "true");
                                sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                                startActivity(sure);
                            } else {
                                // Toast errorinfo =
                                // Toast.makeText(getApplicationContext(),
                                // "", Toast.LENGTH_LONG);
                                // errorinfo.show();
                                Intent sure = new Intent(LongWayActivity.this, OrderResponseActivity.class);
                                sure.putExtra(getString(R.string.request_response), "false");
                                sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                                startActivity(sure);
                            }
                        }
                    }, new Response.ErrorListener() {
                        @Override
                        public void onErrorResponse(VolleyError error) {
                            Log.e("longway_result", error.getMessage(), error);
                            // Toast errorinfo = Toast.makeText(null,
                            // "", Toast.LENGTH_LONG);
                            // errorinfo.show();
                            Intent sure = new Intent(LongWayActivity.this, OrderResponseActivity.class);
                            sure.putExtra(getString(R.string.request_response), "false");
                            sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                            startActivity(sure);
                        }
                    }) {
                protected Map<String, String> getParams() {
                    // POSTgetParams

                    // start
                    try {
                        test_date = primary_date.parse(longway_startdate);
                        standard_longway_startdate = standard_date.format(test_date);
                    } catch (ParseException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                    // end!

                    Map<String, String> params = new HashMap<String, String>();
                    params.put(getString(R.string.uri_phonenum), longway_phonenum);
                    params.put(getString(R.string.uri_userrole), longway_userrole);
                    params.put(getString(R.string.uri_startplace), longway_startplace);
                    params.put(getString(R.string.uri_destination), longway_destination);
                    params.put(getString(R.string.uri_startdate), standard_longway_startdate);
                    params.put(getString(R.string.uri_noteinfo), longway_noteinfo);

                    return params;
                }
            };
            queue.add(stringRequest);
        }
    });

    // start!
    shortway.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent shortway = new Intent(LongWayActivity.this, ShortWayActivity.class);
            startActivity(shortway);
        }
    });

    longway.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
        }
    });

    commute.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent commute = new Intent(LongWayActivity.this, CommuteActivity.class);
            startActivity(commute);
        }
    });

    // end!

    increase.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            sum++;
            s1.setText("" + sum);
            confirm();
        }
    });

    decrease.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            sum--;
            if (sum < 0) {
                sum = 0;
            }
            s1.setText("" + sum);
            confirm();
        }
    });

    datebutton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            showDialog(DATE_DIALOG);
        }
    });
}

From source file:org.alfresco.repo.domain.locale.LocaleDAOTest.java

/**
 * Forces a bunch of threads to attempt Locale creation.
 *//*from w  w w .j a  va  2 s . co  m*/
public void testConcurrentLocale() throws Throwable {
    final Locale locale = Locale.SIMPLIFIED_CHINESE;

    int threadCount = 50;
    final CountDownLatch readyLatch = new CountDownLatch(threadCount);
    final CountDownLatch startLatch = new CountDownLatch(1);
    final CountDownLatch doneLatch = new CountDownLatch(threadCount);
    final List<Throwable> errors = Collections.synchronizedList(new ArrayList<Throwable>(0));
    final RetryingTransactionCallback<Long> callback = new RetryingTransactionCallback<Long>() {
        public Long execute() throws Throwable {
            String threadName = Thread.currentThread().getName();

            // Notify that we are ready
            logger.debug("Thread " + threadName + " is READY");
            readyLatch.countDown();
            // Wait for start signal
            startLatch.await();
            logger.debug("Thread " + threadName + " is GO");
            // Go
            Pair<Long, Locale> localePair = null;
            try {
                // This could fail with concurrency, but that's what we're testing
                logger.debug("Thread " + threadName + " is CREATING " + locale);
                localePair = localeDAO.getOrCreateLocalePair(locale);
            } catch (Throwable e) {
                logger.debug("Failed to create LocaleEntity.  Might retry.", e);
                throw e;
            }
            // Notify the counter that this thread is done
            logger.debug("Thread " + threadName + " is DONE");
            doneLatch.countDown();
            // Done
            return localePair.getFirst();
        }
    };
    Runnable runnable = new Runnable() {
        public void run() {
            try {
                txnHelper.doInTransaction(callback);
            } catch (Throwable e) {
                logger.error("Error escaped from retry", e);
                errors.add(e);
            }
        }
    };
    // Fire a bunch of threads off
    for (int i = 0; i < threadCount; i++) {
        Thread thread = new Thread(runnable, getName() + "-" + i);
        thread.setDaemon(true); // Just in case there are complications
        thread.start();
    }
    // Wait for threads to be ready
    readyLatch.await(5, TimeUnit.SECONDS);
    // Let the threads go
    startLatch.countDown();
    // Wait for them all to be done (within limit of 10 seconds per thread)
    if (doneLatch.await(threadCount * 10, TimeUnit.SECONDS)) {
        logger.warn("Still waiting for threads to finish after " + threadCount + " seconds.");
    }
    // Check if there are errors
    if (errors.size() > 0) {
        throw errors.get(0);
    }
}

From source file:org.structr.schema.action.ActionContextTest.java

public void testVariableReplacement() {

    final Date now = new Date();
    final SimpleDateFormat format1 = new SimpleDateFormat("dd.MM.yyyy");
    final SimpleDateFormat format2 = new SimpleDateFormat("HH:mm:ss");
    final SimpleDateFormat format3 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
    final String nowString1 = format1.format(now);
    final String nowString2 = format2.format(now);
    final String nowString3 = format3.format(now);
    final DecimalFormat numberFormat1 = new DecimalFormat("###0.00",
            DecimalFormatSymbols.getInstance(Locale.ENGLISH));
    final DecimalFormat numberFormat2 = new DecimalFormat("0000.0000",
            DecimalFormatSymbols.getInstance(Locale.GERMAN));
    final DecimalFormat numberFormat3 = new DecimalFormat("####",
            DecimalFormatSymbols.getInstance(Locale.SIMPLIFIED_CHINESE));
    final String numberString1 = numberFormat1.format(2.234);
    final String numberString2 = numberFormat2.format(2.234);
    final String numberString3 = numberFormat3.format(2.234);
    MailTemplate template = null;/*from   w  w w  . j av a2s .c om*/
    MailTemplate template2 = null;
    TestOne testOne = null;
    TestTwo testTwo = null;
    TestThree testThree = null;
    TestFour testFour = null;
    List<TestSix> testSixs = null;
    int index = 0;
    final Object nullValue1 = null;
    final Object nullValue2 = null;
    final String nullString1 = null;
    final String nullString2 = null;
    final String emptyString1 = "";
    final String emptyString2 = "";

    try (final Tx tx = app.tx()) {

        testOne = createTestNode(TestOne.class);
        testTwo = createTestNode(TestTwo.class);
        testThree = createTestNode(TestThree.class);
        testFour = createTestNode(TestFour.class);
        testSixs = createTestNodes(TestSix.class, 20);

        // set string array on test four
        testFour.setProperty(TestFour.stringArrayProperty, new String[] { "one", "two", "three", "four" });

        for (final TestSix testSix : testSixs) {

            testSix.setProperty(TestSix.name, "TestSix" + StringUtils.leftPad(Integer.toString(index), 2, "0"));
            testSix.setProperty(TestSix.index, index);

            index++;
        }

        // create mail template
        template = createTestNode(MailTemplate.class);
        template.setProperty(MailTemplate.name, "TEST");
        template.setProperty(MailTemplate.locale, "en_EN");
        template.setProperty(MailTemplate.text, "This is a template for ${this.name}");

        // create mail template
        template2 = createTestNode(MailTemplate.class);
        template2.setProperty(MailTemplate.name, "TEST2");
        template2.setProperty(MailTemplate.locale, "en_EN");
        template2.setProperty(MailTemplate.text, "${this.aDouble}");

        // check existance
        assertNotNull(testOne);

        testOne.setProperty(TestOne.name, "A-nice-little-name-for-my-test-object");
        testOne.setProperty(TestOne.anInt, 1);
        testOne.setProperty(TestOne.aString, "String");
        testOne.setProperty(TestOne.anotherString, "{\n\ttest: test,\n\tnum: 3\n}");
        testOne.setProperty(TestOne.replaceString, "${this.name}");
        testOne.setProperty(TestOne.aLong, 235242522552L);
        testOne.setProperty(TestOne.aDouble, 2.234);
        testOne.setProperty(TestOne.aDate, now);
        testOne.setProperty(TestOne.anEnum, TestOne.Status.One);
        testOne.setProperty(TestOne.aBoolean, true);
        testOne.setProperty(TestOne.testTwo, testTwo);
        testOne.setProperty(TestOne.testThree, testThree);
        testOne.setProperty(TestOne.testFour, testFour);
        testOne.setProperty(TestOne.manyToManyTestSixs, testSixs);
        testOne.setProperty(TestOne.cleanTestString,
                "a<b>c.d'e?f(g)h{i}j[k]l+m/no\\p\\q|r's!t,u-v_w`x-y-zABCDEFGH");
        testOne.setProperty(TestOne.stringWithQuotes, "A'B\"C");

        testTwo.setProperty(TestTwo.name, "testTwo_name");
        testThree.setProperty(TestThree.name, "testThree_name");

        tx.success();

    } catch (FrameworkException fex) {

        fex.printStackTrace();

        fail("Unexpected exception");
    }

    try (final Tx tx = app.tx()) {

        final ActionContext ctx = new ActionContext(securityContext, null);

        // test quotes etc.
        assertEquals("Invalid result for quoted template expression", "''",
                Scripting.replaceVariables(ctx, testOne, "'${err}'"));
        assertEquals("Invalid result for quoted template expression", " '' ",
                Scripting.replaceVariables(ctx, testOne, " '${err}' "));
        assertEquals("Invalid result for quoted template expression", "\"\"",
                Scripting.replaceVariables(ctx, testOne, "\"${this.error}\""));
        assertEquals("Invalid result for quoted template expression", "''''''",
                Scripting.replaceVariables(ctx, testOne, "'''${this.this.this.error}'''"));
        assertEquals("Invalid result for quoted template expression", "''",
                Scripting.replaceVariables(ctx, testOne, "'${parent.error}'"));
        assertEquals("Invalid result for quoted template expression", "''",
                Scripting.replaceVariables(ctx, testOne, "'${this.owner}'"));
        assertEquals("Invalid result for quoted template expression", "''",
                Scripting.replaceVariables(ctx, testOne, "'${this.alwaysNull}'"));
        assertEquals("Invalid result for quoted template expression", "''",
                Scripting.replaceVariables(ctx, testOne, "'${parent.owner}'"));

        // test for "empty" return value
        assertEquals("Invalid expressions should yield an empty result", "",
                Scripting.replaceVariables(ctx, testOne, "${err}"));
        assertEquals("Invalid expressions should yield an empty result", "",
                Scripting.replaceVariables(ctx, testOne, "${this.error}"));
        assertEquals("Invalid expressions should yield an empty result", "",
                Scripting.replaceVariables(ctx, testOne, "${this.this.this.error}"));
        assertEquals("Invalid expressions should yield an empty result", "",
                Scripting.replaceVariables(ctx, testOne, "${parent.error}"));
        assertEquals("Invalid expressions should yield an empty result", "",
                Scripting.replaceVariables(ctx, testOne, "${this.owner}"));
        assertEquals("Invalid expressions should yield an empty result", "",
                Scripting.replaceVariables(ctx, testOne, "${this.alwaysNull}"));
        assertEquals("Invalid expressions should yield an empty result", "",
                Scripting.replaceVariables(ctx, testOne, "${parent.owner}"));

        assertEquals("${this} should evaluate to the current node", testOne.toString(),
                Scripting.replaceVariables(ctx, testOne, "${this}"));
        //assertEquals("${parent} should evaluate to the context parent node", testOne.toString(), Scripting.replaceVariables(ctx, testOne, "${parent}"));

        assertEquals("${this} should evaluate to the current node", testTwo.toString(),
                Scripting.replaceVariables(ctx, testTwo, "${this}"));
        //assertEquals("${parent} should evaluate to the context parent node", testOne.toString(), Scripting.replaceVariables(ctx, testOne, "${parent}"));

        assertEquals("Invalid variable reference", testTwo.toString(),
                Scripting.replaceVariables(ctx, testOne, "${this.testTwo}"));
        assertEquals("Invalid variable reference", testThree.toString(),
                Scripting.replaceVariables(ctx, testOne, "${this.testThree}"));
        assertEquals("Invalid variable reference", testFour.toString(),
                Scripting.replaceVariables(ctx, testOne, "${this.testFour}"));

        assertEquals("Invalid variable reference", testTwo.getUuid(),
                Scripting.replaceVariables(ctx, testOne, "${this.testTwo.id}"));
        assertEquals("Invalid variable reference", testThree.getUuid(),
                Scripting.replaceVariables(ctx, testOne, "${this.testThree.id}"));
        assertEquals("Invalid variable reference", testFour.getUuid(),
                Scripting.replaceVariables(ctx, testOne, "${this.testFour.id}"));

        assertEquals("Invalid size result", "20",
                Scripting.replaceVariables(ctx, testOne, "${this.manyToManyTestSixs.size}"));

        try {

            Scripting.replaceVariables(ctx, testOne, "${(this.alwaysNull.size}");
            fail("A mismatched opening bracket should throw an exception.");

        } catch (FrameworkException fex) {
            assertEquals("Invalid expression: mismatched closing bracket after this.alwaysNull.size",
                    fex.getMessage());
        }

        assertEquals("Invalid size result", "",
                Scripting.replaceVariables(ctx, testOne, "${this.alwaysNull.size}"));

        assertEquals("Invalid variable reference", "1",
                Scripting.replaceVariables(ctx, testOne, "${this.anInt}"));
        assertEquals("Invalid variable reference", "String",
                Scripting.replaceVariables(ctx, testOne, "${this.aString}"));
        assertEquals("Invalid variable reference", "235242522552",
                Scripting.replaceVariables(ctx, testOne, "${this.aLong}"));
        assertEquals("Invalid variable reference", "2.234",
                Scripting.replaceVariables(ctx, testOne, "${this.aDouble}"));

        // test with property
        assertEquals("Invalid md5() result", "27118326006d3829667a400ad23d5d98",
                Scripting.replaceVariables(ctx, testOne, "${md5(this.aString)}"));
        assertEquals("Invalid upper() result", "27118326006D3829667A400AD23D5D98",
                Scripting.replaceVariables(ctx, testOne, "${upper(md5(this.aString))}"));
        assertEquals("Invalid upper(lower() result", "27118326006D3829667A400AD23D5D98",
                Scripting.replaceVariables(ctx, testOne, "${upper(lower(upper(md5(this.aString))))}"));

        assertEquals("Invalid md5() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${md5(this.alwaysNull)}"));
        assertEquals("Invalid upper() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${upper(this.alwaysNull)}"));
        assertEquals("Invalid lower() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${lower(this.alwaysNull)}"));

        // test literal value as well
        assertEquals("Invalid md5() result", "cc03e747a6afbbcbf8be7668acfebee5",
                Scripting.replaceVariables(ctx, testOne, "${md5(\"test123\")}"));

        assertEquals("Invalid lower() result", "string",
                Scripting.replaceVariables(ctx, testOne, "${lower(this.aString)}"));
        assertEquals("Invalid upper() result", "STRING",
                Scripting.replaceVariables(ctx, testOne, "${upper(this.aString)}"));

        // merge
        assertEquals("Invalid merge() result", "[one, two, three]",
                Scripting.replaceVariables(ctx, testOne, "${merge('one', 'two', 'three')}"));
        assertEquals("Invalid merge() result", "[one, two, three, two, one, two, three]",
                Scripting.replaceVariables(ctx, testOne,
                        "${merge(merge('one', 'two', 'three'), 'two', merge('one', 'two', 'three'))}"));
        assertEquals("Invalid merge() result", "[1, 2, 3, 4, 5, 6, 7, 8]", Scripting.replaceVariables(ctx,
                testOne, "${merge(merge('1', '2', '3'), merge('4', '5', merge('6', '7', '8')))}"));
        assertEquals("Invalid merge() result", "[1, 2, 3, 4, 5, 6, 1, 2, 3, 8]", Scripting.replaceVariables(ctx,
                testOne,
                "${ ( store('list', merge('1', '2', '3')), merge(retrieve('list'), merge('4', '5', merge('6', retrieve('list'), '8'))) )}"));

        // merge_unique
        assertEquals("Invalid merge_unique() result", "[one, two, three]",
                Scripting.replaceVariables(ctx, testOne, "${merge_unique('one', 'two', 'three', 'two')}"));
        assertEquals("Invalid merge_unique() result", "[one, two, three]", Scripting.replaceVariables(ctx,
                testOne,
                "${merge_unique(merge_unique('one', 'two', 'three'), 'two', merge_unique('one', 'two', 'three'))}"));
        assertEquals("Invalid merge_unique() result", "[1, 2, 3, 4, 5, 6, 7, 8]", Scripting.replaceVariables(
                ctx, testOne,
                "${merge_unique(merge_unique('1', '2', '3'), merge_unique('4', '5', merge_unique('6', '7', '8')))}"));
        assertEquals("Invalid merge_unique() result", "[1, 2, 3, 4, 5, 6, 8]", Scripting.replaceVariables(ctx,
                testOne,
                "${ ( store('list', merge_unique('1', '2', '3')), merge_unique(retrieve('list'), merge_unique('4', '5', merge_unique('6', retrieve('list'), '8'))) )}"));

        // complement
        assertEquals("Invalid complement() result", "[]", Scripting.replaceVariables(ctx, testOne,
                "${complement(merge('one', 'two', 'three'), 'one', merge('two', 'three', 'four'))}"));
        assertEquals("Invalid complement() result", "[two]", Scripting.replaceVariables(ctx, testOne,
                "${complement(merge('one', 'two', 'three'), merge('one', 'four', 'three'))}"));

        // join
        assertEquals("Invalid join() result", "one,two,three",
                Scripting.replaceVariables(ctx, testOne, "${join(merge(\"one\", \"two\", \"three\"), \",\")}"));

        // concat
        assertEquals("Invalid concat() result", "onetwothree",
                Scripting.replaceVariables(ctx, testOne, "${concat(\"one\", \"two\", \"three\")}"));
        assertEquals("Invalid concat() result", "oneStringthree",
                Scripting.replaceVariables(ctx, testOne, "${concat(\"one\", this.aString, \"three\")}"));
        assertEquals("Invalid concat() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${concat(this.alwaysNull, this.alwaysNull)}"));

        // split
        assertEquals("Invalid split() result", "onetwothree",
                Scripting.replaceVariables(ctx, testOne, "${concat(split(\"one,two,three\"))}"));
        assertEquals("Invalid split() result", "onetwothree",
                Scripting.replaceVariables(ctx, testOne, "${concat(split(\"one;two;three\"))}"));
        assertEquals("Invalid split() result", "onetwothree",
                Scripting.replaceVariables(ctx, testOne, "${concat(split(\"one;two;three\", \";\"))}"));
        assertEquals("Invalid split() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${split(this.alwaysNull)}"));

        // abbr
        assertEquals("Invalid abbr() result", "oneStringt", Scripting.replaceVariables(ctx, testOne,
                "${abbr(concat(\"one\", this.aString, \"three\"), 10)}"));
        assertEquals("Invalid abbr() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${abbr(this.alwaysNull, 10)}"));

        // capitalize..
        assertEquals("Invalid capitalize() result", "One_two_three", Scripting.replaceVariables(ctx, testOne,
                "${capitalize(concat(\"one_\", \"two_\", \"three\"))}"));
        assertEquals("Invalid capitalize() result", "One_Stringthree", Scripting.replaceVariables(ctx, testOne,
                "${capitalize(concat(\"one_\", this.aString, \"three\"))}"));
        assertEquals("Invalid capitalize() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${capitalize(this.alwaysNull)}"));

        // titleize
        assertEquals("Invalid titleize() result", "One Two Three", Scripting.replaceVariables(ctx, testOne,
                "${titleize(concat(\"one_\", \"two_\", \"three\"), \"_\")}"));
        assertEquals("Invalid titleize() result", "One Stringthree", Scripting.replaceVariables(ctx, testOne,
                "${titleize(concat(\"one_\", this.aString, \"three\"), \"_\")}"));
        assertEquals("Invalid titleize() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${titleize(this.alwaysNull)}"));

        // num (explicit number conversion)
        assertEquals("Invalid num() result", "2.234",
                Scripting.replaceVariables(ctx, testOne, "${num(2.234)}"));
        assertEquals("Invalid num() result", "2.234",
                Scripting.replaceVariables(ctx, testOne, "${num(this.aDouble)}"));
        assertEquals("Invalid num() result", "1.0",
                Scripting.replaceVariables(ctx, testOne, "${num(this.anInt)}"));
        assertEquals("Invalid num() result", "", Scripting.replaceVariables(ctx, testOne, "${num(\"abc\")}"));
        assertEquals("Invalid num() result", "",
                Scripting.replaceVariables(ctx, testOne, "${num(this.aString)}"));
        assertEquals("Invalid num() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${num(this.alwaysNull)}"));

        // index_of
        assertEquals("Invalid index_of() result", "19",
                Scripting.replaceVariables(ctx, testOne, "${index_of(this.name, 'for')}"));
        assertEquals("Invalid index_of() result", "-1",
                Scripting.replaceVariables(ctx, testOne, "${index_of(this.name, 'entity')}"));
        assertEquals("Invalid index_of() result", "19", Scripting.replaceVariables(ctx, testOne,
                "${index_of('a-nice-little-name-for-my-test-object', 'for')}"));
        assertEquals("Invalid index_of() result", "-1", Scripting.replaceVariables(ctx, testOne,
                "${index_of('a-nice-little-name-for-my-test-object', 'entity')}"));

        // contains
        assertEquals("Invalid contains() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${contains(this.name, 'for')}"));
        assertEquals("Invalid contains() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${contains(this.name, 'entity')}"));
        assertEquals("Invalid contains() result", "true", Scripting.replaceVariables(ctx, testOne,
                "${contains('a-nice-little-name-for-my-test-object', 'for')}"));
        assertEquals("Invalid contains() result", "false", Scripting.replaceVariables(ctx, testOne,
                "${contains('a-nice-little-name-for-my-test-object', 'entity')}"));

        // contains with collection / entity
        assertEquals("Invalid contains() result", "true", Scripting.replaceVariables(ctx, testOne,
                "${contains(this.manyToManyTestSixs, first(find('TestSix')))}"));
        assertEquals("Invalid contains() result", "false", Scripting.replaceVariables(ctx, testOne,
                "${contains(this.manyToManyTestSixs, first(find('TestFive')))}"));

        // substring
        assertEquals("Invalid substring() result", "for",
                Scripting.replaceVariables(ctx, testOne, "${substring(this.name, 19, 3)}"));
        assertEquals("Invalid substring() result", "",
                Scripting.replaceVariables(ctx, testOne, "${substring(this.name, -1, -1)}"));
        assertEquals("Invalid substring() result", "",
                Scripting.replaceVariables(ctx, testOne, "${substring(this.name, 100, -1)}"));
        assertEquals("Invalid substring() result", "",
                Scripting.replaceVariables(ctx, testOne, "${substring(this.name, 5, -2)}"));
        assertEquals("Invalid substring() result", "for", Scripting.replaceVariables(ctx, testOne,
                "${substring('a-nice-little-name-for-my-test-object', 19, 3)}"));
        assertEquals("Invalid substring() result", "ice-little-name-for-my-test-object", Scripting
                .replaceVariables(ctx, testOne, "${substring('a-nice-little-name-for-my-test-object', 3)}"));
        assertEquals("Invalid substring() result", "ice", Scripting.replaceVariables(ctx, testOne,
                "${substring('a-nice-little-name-for-my-test-object', 3, 3)}"));
        assertEquals("Invalid substring() result", "", Scripting.replaceVariables(ctx, testOne,
                "${substring('a-nice-little-name-for-my-test-object', -1, -1)}"));
        assertEquals("Invalid substring() result", "", Scripting.replaceVariables(ctx, testOne,
                "${substring('a-nice-little-name-for-my-test-object', 100, -1)}"));
        assertEquals("Invalid substring() result", "", Scripting.replaceVariables(ctx, testOne,
                "${substring('a-nice-little-name-for-my-test-object', 5, -2)}"));

        // length
        assertEquals("Invalid length() result", "37",
                Scripting.replaceVariables(ctx, testOne, "${length(this.name)}"));
        assertEquals("Invalid length() result", "37",
                Scripting.replaceVariables(ctx, testOne, "${length('a-nice-little-name-for-my-test-object')}"));
        assertEquals("Invalid length() result", "4",
                Scripting.replaceVariables(ctx, testOne, "${length('test')}"));
        assertEquals("Invalid length() result", "",
                Scripting.replaceVariables(ctx, testOne, "${length(this.alwaysNull)}"));

        // clean
        assertEquals("Invalid clean() result", "abcd-efghijkl-m-n-o-p-q-r-stu-v-w-x-y-zoauabcdefgh",
                Scripting.replaceVariables(ctx, testOne, "${clean(this.cleanTestString)}"));
        assertEquals("Invalid clean() result", "abcd-efghijkl-m-n-o-p-q-r-stu-v-w-x-y-zoauabcdefgh",
                Scripting.replaceVariables(ctx, testOne, "${clean(get(this, \"cleanTestString\"))}"));
        assertEquals("Invalid clean() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${clean(this.alwaysNull)}"));

        // urlencode
        assertEquals("Invalid urlencode() result",
                "a%3Cb%3Ec.d%27e%3Ff%28g%29h%7Bi%7Dj%5Bk%5Dl%2Bm%2Fn%E2%80%93o%5Cp%5Cq%7Cr%27s%21t%2Cu-v_w%60x-y-z%C3%B6%C3%A4%C3%BC%C3%9FABCDEFGH",
                Scripting.replaceVariables(ctx, testOne, "${urlencode(this.cleanTestString)}"));
        assertEquals("Invalid urlencode() result",
                "a%3Cb%3Ec.d%27e%3Ff%28g%29h%7Bi%7Dj%5Bk%5Dl%2Bm%2Fn%E2%80%93o%5Cp%5Cq%7Cr%27s%21t%2Cu-v_w%60x-y-z%C3%B6%C3%A4%C3%BC%C3%9FABCDEFGH",
                Scripting.replaceVariables(ctx, testOne, "${urlencode(get(this, \"cleanTestString\"))}"));
        assertEquals("Invalid urlencode() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${urlencode(this.alwaysNull)}"));

        // escape_javascript
        assertEquals("Invalid escape_javascript() result", "A\\'B\\\"C",
                Scripting.replaceVariables(ctx, testOne, "${escape_javascript(this.stringWithQuotes)}"));
        assertEquals("Invalid escape_javascript() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${escape_javascript(this.alwaysNull)}"));

        // escape_json
        assertEquals("Invalid escape_json() result", "A'B\\\"C",
                Scripting.replaceVariables(ctx, testOne, "${escape_json(this.stringWithQuotes)}"));
        assertEquals("Invalid escape_json() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${escape_json(this.alwaysNull)}"));

        // if etc.
        assertEquals("Invalid if() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(\"true\", \"true\", \"false\")}"));
        assertEquals("Invalid if() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(\"false\", \"true\", \"false\")}"));

        // empty
        assertEquals("Invalid empty() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${empty(\"\")}"));
        assertEquals("Invalid empty() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${empty(\" \")}"));
        assertEquals("Invalid empty() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${empty(\"   \")}"));
        assertEquals("Invalid empty() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${empty(\"xyz\")}"));
        assertEquals("Invalid empty() result with null value", "true",
                Scripting.replaceVariables(ctx, testOne, "${empty(this.alwaysNull)}"));

        assertEquals("Invalid if(empty()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(empty(\"test\"), true, false)}"));
        assertEquals("Invalid if(empty()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(empty(\"test\n\"), true, false)}"));

        // functions can NOT handle literal strings containing newlines  (disabled for now, because literal strings pose problems in the matching process)
        assertEquals("Invalid if(empty()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(empty(\"\n\"), true, false)}"));
        assertEquals("Invalid if(empty()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(empty(\"\n\"), \"true\", \"false\")}"));

        // functions CAN handle variable values with newlines!
        assertEquals("Invalid if(empty()) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(empty(this.anotherString), \"true\", \"false\")}"));

        // equal
        assertEquals("Invalid equal() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${equal(this.id, this.id)}"));
        assertEquals("Invalid equal() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${equal(\"1\", this.anInt)}"));
        assertEquals("Invalid equal() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${equal(1, this.anInt)}"));
        assertEquals("Invalid equal() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${equal(1.0, this.anInt)}"));
        assertEquals("Invalid equal() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${equal(this.anInt, \"1\")}"));
        assertEquals("Invalid equal() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${equal(this.anInt, 1)}"));
        assertEquals("Invalid equal() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${equal(this.anInt, 1.0)}"));
        assertEquals("Invalid equal() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${equal(this.aBoolean, \"true\")}"));
        assertEquals("Invalid equal() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${equal(this.aBoolean, \"false\")}"));
        assertEquals("Invalid equal() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${equal(this.aBoolean, true)}"));
        assertEquals("Invalid equal() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${equal(this.aBoolean, false)}"));
        assertEquals("Invalid equal() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${equal(this.anEnum, 'One')}"));

        // if + equal
        assertEquals("Invalid if(equal()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(this.id, this.id), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(\"abc\", \"abc\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(3, 3), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(\"3\", \"3\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(3.1414, 3.1414), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(\"3.1414\", \"3.1414\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(23.44242222243633337234623462, 23.44242222243633337234623462), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(\"23.44242222243633337234623462\", \"23.44242222243633337234623462\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(13, 013), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(13, \"013\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(\"13\", \"013\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal()) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(\"13\", \"00013\"), \"true\", \"false\")}"));

        // disabled: java StreamTokenizer can NOT handle scientific notation
        //         assertEquals("Invalid if(equal()) result", "true",  Scripting.replaceVariables(ctx, testOne, "${equal(23.4462, 2.34462e1)}"));
        //         assertEquals("Invalid if(equal()) result", "true",  Scripting.replaceVariables(ctx, testOne, "${equal(0.00234462, 2.34462e-3)}"));
        //         assertEquals("Invalid if(equal()) result with null value", "false",  Scripting.replaceVariables(ctx, testOne, "${equal(this.alwaysNull, 2.34462e-3)}"));
        assertEquals("Invalid if(equal()) result with null value", "false",
                Scripting.replaceVariables(ctx, testOne, "${equal(0.00234462, this.alwaysNull)}"));
        assertEquals("Invalid if(equal()) result with null value", "true",
                Scripting.replaceVariables(ctx, testOne, "${equal(this.alwaysNull, this.alwaysNull)}"));

        // if + equal + add
        assertEquals("Invalid if(equal(add())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(\"2\", add(\"1\", \"1\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(add())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2, add(\"1\", \"1\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(add())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(2, add(1, 1)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(add())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2, add(\"1\", 1)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(add())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2, add(1, \"1\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(add())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(2, add(1, 1.0)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(add())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2.0, add(\"1\", \"1\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(add())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(2.0, add(1, 1)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(add())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2.0, add(\"1\", 1)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(add())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2.0, add(1, \"1\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(add())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2.0, add(1, 1.0)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(add())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(20, add(\"10\", \"10\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(add())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(20, add(\"10\", \"010\")), \"true\", \"false\")}"));

        // eq
        assertEquals("Invalideq) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${eq(this.id, this.id)}"));
        assertEquals("Invalid eq() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${eq(\"1\", this.anInt)}"));
        assertEquals("Invalid eq() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${eq(1, this.anInt)}"));
        assertEquals("Invalid eq() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${eq(1.0, this.anInt)}"));
        assertEquals("Invalid eq() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${eq(this.anInt, \"1\")}"));
        assertEquals("Invalid eq() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${eq(this.anInt, 1)}"));
        assertEquals("Invalid eq() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${eq(this.anInt, 1.0)}"));
        assertEquals("Invalid eq() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${eq(this.aBoolean, \"true\")}"));
        assertEquals("Invalid eq() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${eq(this.aBoolean, \"false\")}"));
        assertEquals("Invalid eq() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${eq(this.aBoolean, true)}"));
        assertEquals("Invalid eq() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${eq(this.aBoolean, false)}"));
        assertEquals("Invalid eq() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${eq(this.anEnum, 'One')}"));
        assertEquals("Invalid eq() result", "true", Scripting.replaceVariables(ctx, testOne, "${eq('', '')}"));

        // eq with empty string and number
        assertEquals("Invalid eq() result", "false", Scripting.replaceVariables(ctx, testOne, "${eq(3, '')}"));
        assertEquals("Invalid eq() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${eq('', 12.3456)}"));

        // eq with null
        assertEquals("Invalid eq() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${eq(this.alwaysNull, this.alwaysNull)}"));
        assertEquals("Invalid eq() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${eq(this.alwaysNull, 'xyz')}"));
        assertEquals("Invalid eq() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${eq('xyz', this.alwaysNull)}"));

        // if + eq
        assertEquals("Invalid if(eq()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(eq(this.id, this.id), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(eq(\"abc\", \"abc\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(eq(3, 3), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(eq(\"3\", \"3\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(eq(3.1414, 3.1414), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(eq(\"3.1414\", \"3.1414\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(eq(23.44242222243633337234623462, 23.44242222243633337234623462), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(eq(\"23.44242222243633337234623462\", \"23.44242222243633337234623462\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(eq(13, 013), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(eq(13, \"013\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(eq(\"13\", \"013\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(eq(\"13\", \"00013\"), \"true\", \"false\")}"));

        // disabled: java StreamTokenizer can NOT handle scientific notation
        //         assertEquals("Invalid if(eq()) result", "true",  Scripting.replaceVariables(ctx, testOne, "${eq(23.4462, 2.34462e1)}"));
        //         assertEquals("Invalid if(eq()) result", "true",  Scripting.replaceVariables(ctx, testOne, "${eq(0.00234462, 2.34462e-3)}"));
        //         assertEquals("Invalid if(eq()) result with null value", "false",  Scripting.replaceVariables(ctx, testOne, "${eq(this.alwaysNull, 2.34462e-3)}"));
        assertEquals("Invalid if(eq()) result with null value", "false",
                Scripting.replaceVariables(ctx, testOne, "${eq(0.00234462, this.alwaysNull)}"));
        assertEquals("Invalid if(eq()) result with null value", "true",
                Scripting.replaceVariables(ctx, testOne, "${eq(this.alwaysNull, this.alwaysNull)}"));

        // if + eq + add
        assertEquals("Invalid if(eq(add())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(eq(\"2\", add(\"1\", \"1\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq(add())) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(eq(\"2\", add(\"2\", \"1\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq(add())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(eq(2, add(\"1\", \"1\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq(add())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(eq(2, add(1, 1)), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq(add())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(eq(2, add(\"1\", 1)), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq(add())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(eq(2, add(1, \"1\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq(add())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(eq(2, add(1, 1.0)), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq(add())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(eq(2.0, add(\"1\", \"1\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq(add())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(eq(2.0, add(1, 1)), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq(add())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(eq(2.0, add(\"1\", 1)), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq(add())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(eq(2.0, add(1, \"1\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq(add())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(eq(2.0, add(1, 1.0)), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq(add())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(eq(20, add(\"10\", \"10\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(eq(add())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(eq(20, add(\"10\", \"010\")), \"true\", \"false\")}"));

        // add with null
        assertEquals("Invalid add() result with null value", "10.0",
                Scripting.replaceVariables(ctx, testOne, "${add(\"10\", this.alwaysNull)}"));
        assertEquals("Invalid add() result with null value", "11.0",
                Scripting.replaceVariables(ctx, testOne, "${add(this.alwaysNull, \"11\")}"));
        assertEquals("Invalid add() result with null value", "0.0",
                Scripting.replaceVariables(ctx, testOne, "${add(this.alwaysNull, this.alwaysNull)}"));

        // if + lt
        assertEquals("Invalid if(lt()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(lt(\"2\", \"2\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(lt()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(lt(\"2\", \"3\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(lt()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(lt(\"2000000\", \"3000000\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(lt()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(lt(\"2.0\", \"3.0\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(lt()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(lt(\"2000000.0\", \"3000000.0\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(lt()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(lt(\"12\", \"3\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(lt()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(lt(\"12000000\", \"3000000\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(lt()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(lt(\"12.0\", \"3.0\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(lt()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(lt(\"12000000.0\", \"3000000.0\"), \"true\", \"false\")}"));

        assertEquals("Invalid if(lt()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(lt(2, 2), \"true\", \"false\")}"));
        assertEquals("Invalid if(lt()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(lt(2, 3), \"true\", \"false\")}"));
        assertEquals("Invalid if(lt()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(lt(2000000, 3000000), \"true\", \"false\")}"));
        assertEquals("Invalid if(lt()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(lt(2.0, 3.0), \"true\", \"false\")}"));
        assertEquals("Invalid if(lt()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(lt(2000000.0, 3000000.0), \"true\", \"false\")}"));
        assertEquals("Invalid if(lt()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(lt(12, 3), \"true\", \"false\")}"));
        assertEquals("Invalid if(lt()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(lt(1200000, 3000000), \"true\", \"false\")}"));
        assertEquals("Invalid if(lt()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(lt(12000000, 3000000), \"true\", \"false\")}"));
        assertEquals("Invalid if(lt()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(lt(12.0, 3.0), \"true\", \"false\")}"));
        assertEquals("Invalid if(lt()) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(lt(12000000.0, 3000000.0), \"true\", \"false\")}"));

        // compare numbers written as strings as numbers
        assertEquals("Invalid if(lt()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${lt(\"1200\", \"30\")}"));

        // lt with numbers and empty string
        assertEquals("Invalid lt() result with null value", "false",
                Scripting.replaceVariables(ctx, testOne, "${lt(10, '')}"));
        assertEquals("Invalid lt() result with null value", "true",
                Scripting.replaceVariables(ctx, testOne, "${lt('', 11)}"));
        assertEquals("Invalid lt() result with null value", "false",
                Scripting.replaceVariables(ctx, testOne, "${lt('', '')}"));

        // lt with null
        assertEquals("Invalid lt() result with null value", "false",
                Scripting.replaceVariables(ctx, testOne, "${lt(\"10\", this.alwaysNull)}"));
        assertEquals("Invalid lt() result with null value", "true",
                Scripting.replaceVariables(ctx, testOne, "${lt(this.alwaysNull, \"11\")}"));
        assertEquals("Invalid lt() result with null value", "false",
                Scripting.replaceVariables(ctx, testOne, "${lt(this.alwaysNull, this.alwaysNull)}"));

        // if + gt
        assertEquals("Invalid if(gt()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(gt(\"2\", \"2\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(gt()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(gt(\"2\", \"3\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(gt()) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(gt(\"2000000\", \"3000000\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(gt()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(gt(\"2.0\", \"3.0\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(gt()) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(gt(\"2000000.0\", \"3000000.0\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(gt()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(gt(\"12\", \"3\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(gt()) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(gt(\"12000000\", \"3000000\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(gt()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(gt(\"12.0\", \"3.0\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(gt()) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(gt(\"12000000.0\", \"3000000.0\"), \"true\", \"false\")}"));

        assertEquals("Invalid if(gt()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(gt(2, 2), \"true\", \"false\")}"));
        assertEquals("Invalid if(gt()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(gt(2, 3), \"true\", \"false\")}"));
        assertEquals("Invalid if(gt()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(gt(2000000, 3000000), \"true\", \"false\")}"));
        assertEquals("Invalid if(gt()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(gt(2.0, 3.0), \"true\", \"false\")}"));
        assertEquals("Invalid if(gt()) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(gt(2000000.0, 3000000.0), \"true\", \"false\")}"));
        assertEquals("Invalid if(gt()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(gt(12, 3), \"true\", \"false\")}"));
        assertEquals("Invalid if(gt()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(gt(12000000, 3000000), \"true\", \"false\")}"));
        assertEquals("Invalid if(gt()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(gt(12.0, 3.0), \"true\", \"false\")}"));
        assertEquals("Invalid if(gt()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(gt(12000000.0, 3000000.0), \"true\", \"false\")}"));

        // gt with null
        assertEquals("Invalid gt() result with null value", "true",
                Scripting.replaceVariables(ctx, testOne, "${gt(\"10\", this.alwaysNull)}"));
        assertEquals("Invalid gt() result with null value", "false",
                Scripting.replaceVariables(ctx, testOne, "${gt(this.alwaysNull, \"11\")}"));
        assertEquals("Invalid gt() result with null value", "false",
                Scripting.replaceVariables(ctx, testOne, "${gt(this.alwaysNull, this.alwaysNull)}"));

        // gt with numbers and empty string
        assertEquals("Invalid gt() result with null value", "true",
                Scripting.replaceVariables(ctx, testOne, "${gt(10, '')}"));
        assertEquals("Invalid gt() result with null value", "false",
                Scripting.replaceVariables(ctx, testOne, "${gt('', 11)}"));
        assertEquals("Invalid gt() result with null value", "false",
                Scripting.replaceVariables(ctx, testOne, "${gt('', '')}"));

        // if + lte
        assertEquals("Invalid if(lte()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(lte(\"2\", \"2\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(lte()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(lte(\"2\", \"3\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(lte()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(lte(\"2000000\", \"3000000\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(lte()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(lte(\"2.0\", \"3.0\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(lte()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(lte(\"2000000.0\", \"3000000.0\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(lte()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(lte(\"12\", \"3\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(lte()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(lte(\"12000000\", \"3000000\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(lte()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(lte(\"12.0\", \"3.0\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(lte()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(lte(\"12000000.0\", \"3000000.0\"), \"true\", \"false\")}"));

        assertEquals("Invalid if(lte()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(lte(2, 2), \"true\", \"false\")}"));
        assertEquals("Invalid if(lte()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(lte(2, 3), \"true\", \"false\")}"));
        assertEquals("Invalid if(lte()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(lte(2000000, 3000000), \"true\", \"false\")}"));
        assertEquals("Invalid if(lte()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(lte(2.0, 3.0), \"true\", \"false\")}"));
        assertEquals("Invalid if(lte()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(lte(2000000.0, 3000000.0), \"true\", \"false\")}"));
        assertEquals("Invalid if(lte()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(lte(12, 3), \"true\", \"false\")}"));
        assertEquals("Invalid if(lte()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(lte(12000000, 3000000), \"true\", \"false\")}"));
        assertEquals("Invalid if(lte()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(lte(12.0, 3.0), \"true\", \"false\")}"));
        assertEquals("Invalid if(lte()) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(lte(12000000.0, 3000000.0), \"true\", \"false\")}"));

        // lte with null
        assertEquals("Invalid lte() result with null value", "false",
                Scripting.replaceVariables(ctx, testOne, "${lte(\"10\", this.alwaysNull)}"));
        assertEquals("Invalid lte() result with null value", "true",
                Scripting.replaceVariables(ctx, testOne, "${lte(this.alwaysNull, \"11\")}"));
        assertEquals("Invalid lte() result with null value", "true",
                Scripting.replaceVariables(ctx, testOne, "${lte(this.alwaysNull, this.alwaysNull)}"));

        // if + gte
        assertEquals("Invalid if(gte()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(gte(\"2\", \"2\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(gte()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(gte(\"2\", \"3\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(gte()) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(gte(\"2000000\", \"3000000\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(gte()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(gte(\"2.0\", \"3.0\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(gte()) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(gte(\"2000000.0\", \"3000000.0\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(gte()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(gte(\"12\", \"3\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(gte()) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(gte(\"12000000\", \"3000000\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(gte()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(gte(\"12.0\", \"3.0\"), \"true\", \"false\")}"));
        assertEquals("Invalid if(gte()) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(gte(\"12000000.0\", \"3000000.0\"), \"true\", \"false\")}"));

        assertEquals("Invalid if(gte()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(gte(2, 2), \"true\", \"false\")}"));
        assertEquals("Invalid if(gte()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(gte(2, 3), \"true\", \"false\")}"));
        assertEquals("Invalid if(gte()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(gte(2000000, 3000000), \"true\", \"false\")}"));
        assertEquals("Invalid if(gte()) result", "false",
                Scripting.replaceVariables(ctx, testOne, "${if(gte(2.0, 3.0), \"true\", \"false\")}"));
        assertEquals("Invalid if(gte()) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(gte(2000000.0, 3000000.0), \"true\", \"false\")}"));
        assertEquals("Invalid if(gte()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(gte(12, 3), \"true\", \"false\")}"));
        assertEquals("Invalid if(gte()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(gte(12000000, 3000000), \"true\", \"false\")}"));
        assertEquals("Invalid if(gte()) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(gte(12.0, 3.0), \"true\", \"false\")}"));
        assertEquals("Invalid if(gte()) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(gte(12000000.0, 3000000.0), \"true\", \"false\")}"));

        // gte with null
        assertEquals("Invalid gte() result with null value", "true",
                Scripting.replaceVariables(ctx, testOne, "${gte(\"10\", this.alwaysNull)}"));
        assertEquals("Invalid gte() result with null value", "false",
                Scripting.replaceVariables(ctx, testOne, "${gte(this.alwaysNull, \"11\")}"));
        assertEquals("Invalid gte() result with null value", "true",
                Scripting.replaceVariables(ctx, testOne, "${gte(this.alwaysNull, this.alwaysNull)}"));

        // if + equal + subt
        assertEquals("Invalid if(equal(subt())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(\"2\", subt(\"3\", \"1\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(subt())) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(\"2\", subt(\"4\", \"1\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(subt())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2, subt(\"3\", \"1\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(subt())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(2, subt(3, 1)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(subt())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2, subt(\"3\", 1)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(subt())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2, subt(3, \"1\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(subt())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(2, subt(3, 1.0)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(subt())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2.0, subt(\"3\", \"1\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(subt())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(2.0, subt(3, 1)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(subt())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2.0, subt(\"3\", 1)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(subt())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2.0, subt(3, \"1\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(subt())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2.0, subt(3, 1.0)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(subt())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(20, subt(\"30\", \"10\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(subt())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(20, subt(\"30\", \"010\")), \"true\", \"false\")}"));

        // subt with null
        assertEquals("Invalid subt() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${subt(\"10\", this.alwaysNull)}"));
        assertEquals("Invalid subt() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${subt(this.alwaysNull, \"11\")}"));
        assertEquals("Invalid subt() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${subt(this.alwaysNull, this.alwaysNull)}"));

        // if + equal + mult
        assertEquals("Invalid if(equal(mult())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(\"6\", mult(\"3\", \"2\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(mult())) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(\"6\", mult(\"4\", \"2\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(mult())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(6, mult(\"3\", \"2\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(mult())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(6, mult(3, 2)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(mult())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(6, mult(\"3\", 2)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(mult())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(6, mult(3, \"2\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(mult())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(6, mult(3, 2.0)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(mult())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(6.0, mult(\"3\", \"2\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(mult())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(6.0, mult(3, 2)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(mult())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(6.0, mult(\"3\", 2)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(mult())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(6.0, mult(3, \"2\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(mult())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(6.0, mult(3, 2.0)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(mult())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(600, mult(\"30\", \"20\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(mult())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(600, mult(\"30\", \"020\")), \"true\", \"false\")}"));

        // mult with null
        assertEquals("Invalid mult() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${mult(\"10\", this.alwaysNull)}"));
        assertEquals("Invalid mult() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${mult(this.alwaysNull, \"11\")}"));
        assertEquals("Invalid mult() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${mult(this.alwaysNull, this.alwaysNull)}"));

        // if + equal + quot
        assertEquals("Invalid if(equal(quot())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(\"1.5\", quot(\"3\", \"2\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(quot())) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(\"1.5\", quot(\"5\", \"2\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(quot())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(1.5, quot(\"3\", \"2\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(quot())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(1.5, quot(3, 2)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(quot())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(1.5, quot(\"3\", 2)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(quot())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(1.5, quot(3, \"2\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(quot())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(1.5, quot(3, 2.0)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(quot())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(15, quot(\"30\", \"2\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(quot())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(15, quot(\"30\", \"02\")), \"true\", \"false\")}"));

        // quot with null
        assertEquals("Invalid quot() result with null value", "10.0",
                Scripting.replaceVariables(ctx, testOne, "${quot(10, this.alwaysNull)}"));
        assertEquals("Invalid quot() result with null value", "10.0",
                Scripting.replaceVariables(ctx, testOne, "${quot(\"10\", this.alwaysNull)}"));
        assertEquals("Invalid quot() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${quot(this.alwaysNull, \"11\")}"));
        assertEquals("Invalid quot() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${quot(this.alwaysNull, this.alwaysNull)}"));

        // if + equal + round
        assertEquals("Invalid if(equal(round())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(\"1.9\", round(\"1.9\", \"2\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(\"2\", round(\"2.5\", \"2\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(\"2\", round(\"1.999999\", \"2\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(\"2\", round(\"2.499999\", \"2\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2, round(1.9, 2)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2, round(2.5, 2)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2, round(1.999999, 2)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2, round(2.499999, 2)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(2, round(2, 2)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2.4, round(2.4, 2)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2.23, round(2.225234, 2)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2, round(1.9, 8)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2, round(2.5, 8)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2, round(1.999999, 8)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "false", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2, round(2.499999, 8)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(1.999999, round(1.999999, 8)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2.499999, round(2.499999, 8)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2, round(1.999999999, 8)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(2, round(2, 8)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2.4, round(2.4, 8)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(round())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2.225234, round(2.225234, 8)), \"true\", \"false\")}"));

        // disabled because scientific notation is not supported :(
        //assertEquals("Invalid if(equal(round())) result", "true",  Scripting.replaceVariables(ctx, testOne, "${if(equal(0.00245, round(2.45e-3, 8)), \"true\", \"false\")}"));
        //assertEquals("Invalid if(equal(round())) result", "true",  Scripting.replaceVariables(ctx, testOne, "${if(equal(245, round(2.45e2, 8)), \"true\", \"false\")}"));

        // round with null
        assertEquals("Invalid round() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${round(\"10\")}"));
        assertEquals("Invalid round() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${round(this.alwaysNull)}"));
        assertEquals("Invalid round() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${round(this.alwaysNull, this.alwaysNull)}"));

        // if + equal + max
        assertEquals("Invalid if(equal(max())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(\"2\", max(\"1.9\", \"2\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(max())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(2, max(1.9, 2)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(max())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2.0, max(1.9, 2)), \"true\", \"false\")}"));

        // max with null
        assertEquals("Invalid max() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${max(\"10\", this.alwaysNull)}"));
        assertEquals("Invalid max() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${max(this.alwaysNull, \"11\")}"));
        assertEquals("Invalid max() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${max(this.alwaysNull, this.alwaysNull)}"));

        // if + equal + min
        assertEquals("Invalid if(equal(min())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(\"1.9\", min(\"1.9\", \"2\")), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(min())) result", "true", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(1.9, min(1.9, 2)), \"true\", \"false\")}"));
        assertEquals("Invalid if(equal(min())) result", "true",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(1, min(1, 2)), \"true\", \"false\")}"));

        // min with null
        assertEquals("Invalid min() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${min(\"10\", this.alwaysNull)}"));
        assertEquals("Invalid min() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${min(this.alwaysNull, \"11\")}"));
        assertEquals("Invalid min() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${min(this.alwaysNull, this.alwaysNull)}"));

        // date_format
        assertEquals("Invalid date_format() result", nowString1, Scripting.replaceVariables(ctx, testOne,
                "${date_format(this.aDate, \"" + format1.toPattern() + "\")}"));
        assertEquals("Invalid date_format() result", nowString2, Scripting.replaceVariables(ctx, testOne,
                "${date_format(this.aDate, \"" + format2.toPattern() + "\")}"));
        assertEquals("Invalid date_format() result", nowString3, Scripting.replaceVariables(ctx, testOne,
                "${date_format(this.aDate, \"" + format3.toPattern() + "\")}"));

        // date_format with null
        assertEquals("Invalid date_format() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${date_format(\"10\", this.alwaysNull)}"));
        assertEquals("Invalid date_format() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${date_format(this.alwaysNull, this.alwaysNull)}"));

        // date_format error messages
        assertEquals("Invalid date_format() result for wrong number of parameters",
                DateFormatFunction.ERROR_MESSAGE_DATE_FORMAT,
                Scripting.replaceVariables(ctx, testOne, "${date_format()}"));
        assertEquals("Invalid date_format() result for wrong number of parameters",
                DateFormatFunction.ERROR_MESSAGE_DATE_FORMAT,
                Scripting.replaceVariables(ctx, testOne, "${date_format(this.aDouble)}"));
        assertEquals("Invalid date_format() result for wrong number of parameters",
                DateFormatFunction.ERROR_MESSAGE_DATE_FORMAT, Scripting.replaceVariables(ctx, testOne,
                        "${date_format(this.aDouble, this.aDouble, this.aDouble)}"));

        // number_format error messages
        assertEquals("Invalid date_format() result for wrong number of parameters",
                NumberFormatFunction.ERROR_MESSAGE_NUMBER_FORMAT,
                Scripting.replaceVariables(ctx, testOne, "${number_format()}"));
        assertEquals("Invalid date_format() result for wrong number of parameters",
                NumberFormatFunction.ERROR_MESSAGE_NUMBER_FORMAT,
                Scripting.replaceVariables(ctx, testOne, "${number_format(this.aDouble)}"));
        assertEquals("Invalid date_format() result for wrong number of parameters",
                NumberFormatFunction.ERROR_MESSAGE_NUMBER_FORMAT,
                Scripting.replaceVariables(ctx, testOne, "${number_format(this.aDouble, this.aDouble)}"));
        assertEquals("Invalid date_format() result for wrong number of parameters",
                NumberFormatFunction.ERROR_MESSAGE_NUMBER_FORMAT, Scripting.replaceVariables(ctx, testOne,
                        "${number_format(this.aDouble, this.aDouble, \"\", \"\")}"));
        assertEquals("Invalid date_format() result for wrong number of parameters",
                NumberFormatFunction.ERROR_MESSAGE_NUMBER_FORMAT, Scripting.replaceVariables(ctx, testOne,
                        "${number_format(this.aDouble, this.aDouble, \"\", \"\", \"\")}"));

        assertEquals("Invalid date_format() result", numberString1, Scripting.replaceVariables(ctx, testOne,
                "${number_format(this.aDouble, \"en\", \"" + numberFormat1.toPattern() + "\")}"));
        assertEquals("Invalid date_format() result", numberString2, Scripting.replaceVariables(ctx, testOne,
                "${number_format(this.aDouble, \"de\", \"" + numberFormat2.toPattern() + "\")}"));
        assertEquals("Invalid date_format() result", numberString3, Scripting.replaceVariables(ctx, testOne,
                "${number_format(this.aDouble, \"zh\", \"" + numberFormat3.toPattern() + "\")}"));
        assertEquals("Invalid date_format() result", "123456.79",
                Scripting.replaceVariables(ctx, testOne, "${number_format(123456.789012, \"en\", \"0.00\")}"));
        assertEquals("Invalid date_format() result", "123456.7890", Scripting.replaceVariables(ctx, testOne,
                "${number_format(123456.789012, \"en\", \"0.0000\")}"));
        assertEquals("Invalid date_format() result", "123456,79",
                Scripting.replaceVariables(ctx, testOne, "${number_format(123456.789012, \"de\", \"0.00\")}"));
        assertEquals("Invalid date_format() result", "123456,7890", Scripting.replaceVariables(ctx, testOne,
                "${number_format(123456.789012, \"de\", \"0.0000\")}"));
        assertEquals("Invalid date_format() result", "123456.79",
                Scripting.replaceVariables(ctx, testOne, "${number_format(123456.789012, \"zh\", \"0.00\")}"));
        assertEquals("Invalid date_format() result", "123456.7890", Scripting.replaceVariables(ctx, testOne,
                "${number_format(123456.789012, \"zh\", \"0.0000\")}"));

        // number_format with null
        assertEquals("Invalid number_format() result with null value", "", Scripting.replaceVariables(ctx,
                testOne, "${number_format(this.alwaysNull, this.alwaysNull, this.alwaysNull)}"));
        assertEquals("Invalid number_format() result with null value", "", Scripting.replaceVariables(ctx,
                testOne, "${number_format(\"10\", this.alwaysNull, this.alwaysNull)}"));
        assertEquals("Invalid number_format() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${number_format(\"10\", \"de\", this.alwaysNull)}"));

        // not
        assertEquals("Invalid not() result", "true", Scripting.replaceVariables(ctx, testOne, "${not(false)}"));
        assertEquals("Invalid not() result", "false", Scripting.replaceVariables(ctx, testOne, "${not(true)}"));
        assertEquals("Invalid not() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${not(\"false\")}"));
        assertEquals("Invalid not() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${not(\"true\")}"));

        // not with null
        assertEquals("Invalid not() result with null value", "true",
                Scripting.replaceVariables(ctx, testOne, "${not(this.alwaysNull)}"));

        // and
        assertEquals("Invalid and() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${and(true, true)}"));
        assertEquals("Invalid and() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${and(true, false)}"));
        assertEquals("Invalid and() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${and(false, true)}"));
        assertEquals("Invalid and() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${and(false, false)}"));

        // and with null
        assertEquals("Invalid and() result with null value", "false",
                Scripting.replaceVariables(ctx, testOne, "${and(this.alwaysNull, this.alwaysNull)}"));

        // or
        assertEquals("Invalid or() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${or(true, true)}"));
        assertEquals("Invalid or() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${or(true, false)}"));
        assertEquals("Invalid or() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${or(false, true)}"));
        assertEquals("Invalid or() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${and(false, false)}"));

        // or with null
        assertEquals("Invalid or() result with null value", "false",
                Scripting.replaceVariables(ctx, testOne, "${or(this.alwaysNull, this.alwaysNull)}"));

        // get
        assertEquals("Invalid get() result", "1",
                Scripting.replaceVariables(ctx, testOne, "${get(this, \"anInt\")}"));
        assertEquals("Invalid get() result", "String",
                Scripting.replaceVariables(ctx, testOne, "${get(this, \"aString\")}"));
        assertEquals("Invalid get() result", "2.234",
                Scripting.replaceVariables(ctx, testOne, "${get(this, \"aDouble\")}"));
        assertEquals("Invalid get() result", testTwo.toString(),
                Scripting.replaceVariables(ctx, testOne, "${get(this, \"testTwo\")}"));
        assertEquals("Invalid get() result", testTwo.getUuid(),
                Scripting.replaceVariables(ctx, testOne, "${get(get(this, \"testTwo\"), \"id\")}"));
        assertEquals("Invalid get() result", testSixs.get(0).getUuid(), Scripting.replaceVariables(ctx, testOne,
                "${get(first(get(this, \"manyToManyTestSixs\")), \"id\")}"));

        // size
        assertEquals("Invalid size() result", "20",
                Scripting.replaceVariables(ctx, testOne, "${size(this.manyToManyTestSixs)}"));
        assertEquals("Invalid size() result", "0", Scripting.replaceVariables(ctx, testOne, "${size(null)}"));
        assertEquals("Invalid size() result", "0", Scripting.replaceVariables(ctx, testOne, "${size(xyz)}"));

        // is_collection
        assertEquals("Invalid is_collection() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${is_collection(this.manyToManyTestSixs)}"));
        assertEquals("Invalid is_collection() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${is_collection(this.name)}"));
        assertEquals("Invalid is_collection() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${is_collection(null)}"));
        assertEquals("Invalid is_collection() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${is_collection(xyz)}"));

        // is_entity
        assertEquals("Invalid is_entity() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${is_entity(this.testFour)}"));
        assertEquals("Invalid is_entity() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${is_entity(this.manyToManyTestSixs)}"));
        assertEquals("Invalid is_entity() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${is_entity(this.name)}"));
        assertEquals("Invalid is_entity() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${is_entity(null)}"));
        assertEquals("Invalid is_entity() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${is_entity(xyz)}"));

        // first / last / nth
        assertEquals("Invalid first() result", testSixs.get(0).toString(),
                Scripting.replaceVariables(ctx, testOne, "${first(this.manyToManyTestSixs)}"));
        assertEquals("Invalid last() result", testSixs.get(19).toString(),
                Scripting.replaceVariables(ctx, testOne, "${last(this.manyToManyTestSixs)}"));
        assertEquals("Invalid nth() result", testSixs.get(2).toString(),
                Scripting.replaceVariables(ctx, testOne, "${nth(this.manyToManyTestSixs,  2)}"));
        assertEquals("Invalid nth() result", testSixs.get(7).toString(),
                Scripting.replaceVariables(ctx, testOne, "${nth(this.manyToManyTestSixs,  7)}"));
        assertEquals("Invalid nth() result", testSixs.get(9).toString(),
                Scripting.replaceVariables(ctx, testOne, "${nth(this.manyToManyTestSixs,  9)}"));
        assertEquals("Invalid nth() result", testSixs.get(12).toString(),
                Scripting.replaceVariables(ctx, testOne, "${nth(this.manyToManyTestSixs, 12)}"));
        assertEquals("Invalid nth() result", "",
                Scripting.replaceVariables(ctx, testOne, "${nth(this.manyToManyTestSixs, 21)}"));

        // first / last / nth with null
        assertEquals("Invalid first() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${first(this.alwaysNull)}"));
        assertEquals("Invalid last() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${last(this.alwaysNull)}"));
        assertEquals("Invalid nth() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${nth(this.alwaysNull,  2)}"));
        assertEquals("Invalid nth() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${nth(this.alwaysNull,  7)}"));
        assertEquals("Invalid nth() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${nth(this.alwaysNull,  9)}"));
        assertEquals("Invalid nth() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${nth(this.alwaysNull, 12)}"));
        assertEquals("Invalid nth() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${nth(this.alwaysNull, this.alwaysNull)}"));
        assertEquals("Invalid nth() result with null value", "",
                Scripting.replaceVariables(ctx, testOne, "${nth(this.alwaysNull, blah)}"));

        // each with null

        // get with null

        // set with null

        // set date (JS scripting)
        assertEquals("Setting the current date/time should not produce output (JS)", "", Scripting
                .replaceVariables(ctx, testOne, "${{var t = Structr.get('this'); t.aDate = new Date();}}"));

        try {

            // set date (old scripting)
            Scripting.replaceVariables(ctx, testOne, "${set(this, 'aDate', now)}");

        } catch (FrameworkException fex) {
            fail("Setting the current date/time should not cause an Exception (StructrScript)");
        }

        Scripting.replaceVariables(ctx, testOne,
                "${if(empty(this.alwaysNull), set(this, \"doResult\", true), set(this, \"doResult\", false))}");
        assertEquals("Invalid do() result", "true",
                Scripting.replaceVariables(ctx, testOne, "${this.doResult}"));

        Scripting.replaceVariables(ctx, testOne,
                "${if(empty(this.name), set(this, \"doResult\", true), set(this, \"doResult\", false))}");
        assertEquals("Invalid do() result", "false",
                Scripting.replaceVariables(ctx, testOne, "${this.doResult}"));

        // template method
        assertEquals("Invalid template() result",
                "This is a template for A-nice-little-name-for-my-test-object",
                Scripting.replaceVariables(ctx, testOne, "${template(\"TEST\", \"en_EN\", this)}"));

        // more complex tests
        Scripting.replaceVariables(ctx, testOne,
                "${each(split(\"setTestInteger1,setTestInteger2,setTestInteger3\"), set(this, data, 1))}");
        assertEquals("Invalid each() result", "1",
                Scripting.replaceVariables(ctx, testOne, "${get(this, \"setTestInteger1\")}"));
        assertEquals("Invalid each() result", "1",
                Scripting.replaceVariables(ctx, testOne, "${get(this, \"setTestInteger2\")}"));
        assertEquals("Invalid each() result", "1",
                Scripting.replaceVariables(ctx, testOne, "${get(this, \"setTestInteger3\")}"));

        // complex each expression, sets the value of "testString" to the concatenated IDs of all testSixs that are linked to "this"
        Scripting.replaceVariables(ctx, testOne,
                "${each(this.manyToManyTestSixs, set(this, \"testString\", concat(get(this, \"testString\"), data.id)))}");
        assertEquals("Invalid each() result", "640",
                Scripting.replaceVariables(ctx, testOne, "${length(this.testString)}"));

        assertEquals("Invalid if(equal()) result", "String", Scripting.replaceVariables(ctx, testOne,
                "${if(empty(this.alwaysNull), titleize(this.aString, '-'), this.alwaysNull)}"));
        assertEquals("Invalid if(equal()) result", "String", Scripting.replaceVariables(ctx, testOne,
                "${if(empty(this.aString), titleize(this.alwaysNull, '-'), this.aString)}"));

        assertNull("Invalid result for special null value",
                Scripting.replaceVariables(ctx, testOne, "${null}"));
        assertNull("Invalid result for special null value",
                Scripting.replaceVariables(ctx, testOne, "${if(equal(this.anInt, 15), \"selected\", null)}"));

        // tests from real-life examples
        assertEquals("Invalid replacement result", "tile plan ",
                Scripting.replaceVariables(ctx, testOne, "tile plan ${plan.bannerTag}"));

        // more tests with pre- and postfixes
        assertEquals("Invalid replacement result", "abcdefghijklmnop",
                Scripting.replaceVariables(ctx, testOne, "abcdefgh${blah}ijklmnop"));
        assertEquals("Invalid replacement result", "abcdefghStringijklmnop",
                Scripting.replaceVariables(ctx, testOne, "abcdefgh${this.aString}ijklmnop"));
        assertEquals("Invalid replacement result", "#String",
                Scripting.replaceVariables(ctx, testOne, "#${this.aString}"));
        assertEquals("Invalid replacement result",
                "doc_sections/" + testOne.getUuid() + "/childSections?sort=pos",
                Scripting.replaceVariables(ctx, testOne, "doc_sections/${this.id}/childSections?sort=pos"));
        assertEquals("Invalid replacement result", "A Nice Little Name For My Test Object",
                Scripting.replaceVariables(ctx, testOne, "${titleize(this.name, '-')}"));
        assertEquals("Invalid replacement result", "STRINGtrueFALSE", Scripting.replaceVariables(ctx, testOne,
                "${upper(this.aString)}${lower(true)}${upper(false)}"));

        // test store and retrieve
        assertEquals("Invalid store() result", "",
                Scripting.replaceVariables(ctx, testOne, "${store('tmp', this.name)}"));
        assertEquals("Invalid stored value", "A-nice-little-name-for-my-test-object", ctx.retrieve("tmp"));
        assertEquals("Invalid retrieve() result", "A-nice-little-name-for-my-test-object",
                Scripting.replaceVariables(ctx, testOne, "${retrieve('tmp')}"));
        assertEquals("Invalid retrieve() result", "",
                Scripting.replaceVariables(new ActionContext(securityContext), testOne, "${retrieve('tmp')}"));

        // test store and retrieve within filter expression
        assertEquals("Invalid store() result", "",
                Scripting.replaceVariables(ctx, testOne, "${store('tmp', 10)}"));
        assertEquals("Invalid retrieve() result in filter expression", "9", Scripting.replaceVariables(ctx,
                testOne, "${size(filter(this.manyToManyTestSixs, gt(data.index, 10)))}"));
        assertEquals("Invalid retrieve() result in filter expression", "9", Scripting.replaceVariables(ctx,
                testOne, "${size(filter(this.manyToManyTestSixs, gt(data.index, retrieve('tmp'))))}"));

        // retrieve object and access attribute
        assertEquals("Invalid store() result", "",
                Scripting.replaceVariables(ctx, testOne, "${store('testOne', this)}"));
        assertEquals("Invalid retrieve() result", "A-nice-little-name-for-my-test-object",
                Scripting.replaceVariables(ctx, testOne, "${retrieve('testOne').name}"));

        // retrieve stored object attribute in if() expression via get() function
        assertEquals("Invalid retrieve() result", "A-nice-little-name-for-my-test-object", Scripting
                .replaceVariables(ctx, testOne, "${if(false,'true', get(retrieve('testOne'), 'name'))}"));

        // retrieve stored object attribute in if() expression via 'dot-name'
        assertEquals("Invalid retrieve() result", "A-nice-little-name-for-my-test-object",
                Scripting.replaceVariables(ctx, testOne, "${if(false,'true', retrieve('testOne').name)}"));

        // test replace() method
        assertEquals("Invalid replace() result", "A-nice-little-name-for-my-test-object",
                Scripting.replaceVariables(ctx, testOne, "${replace(this.replaceString, this)}"));

        // test error method
        try {
            Actions.execute(securityContext, testTwo, "${error(\"base\", \"test1\")}");
            fail("error() should throw an exception.");

        } catch (FrameworkException fex) {
        }

        try {
            Actions.execute(securityContext, testTwo, "${error(\"base\", \"test1\", \"test2\")}");
            fail("error() should throw an exception.");

        } catch (FrameworkException fex) {
        }

        // test multiline statements
        assertEquals("Invalid replace() result", "equal", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2, 2),\n    (\"equal\"),\n    (\"not equal\")\n)}"));
        assertEquals("Invalid replace() result", "not equal", Scripting.replaceVariables(ctx, testOne,
                "${if(equal(2, 3),\n    (\"equal\"),\n    (\"not equal\")\n)}"));

        assertEquals("Invalid keys() / join() result",
                "id,name,owner,type,createdBy,deleted,hidden,createdDate,lastModifiedDate,visibleToPublicUsers,visibleToAuthenticatedUsers,visibilityStartDate,visibilityEndDate",
                Scripting.replaceVariables(ctx, testOne, "${join(keys(this, 'ui'), ',')}"));

        // test default values
        assertEquals("Invalid string default value", "blah",
                Scripting.replaceVariables(ctx, testOne, "${this.alwaysNull!blah}"));
        assertEquals("Invalid numeric default value", "12",
                Scripting.replaceVariables(ctx, testOne, "${this.alwaysNull!12}"));

        // Number default value
        assertEquals("true", Scripting.replaceVariables(ctx, testOne, "${equal(42, this.alwaysNull!42)}"));

        // complex multi-statement tests
        Scripting.replaceVariables(ctx, testOne,
                "${(set(this, \"isValid\", true), each(this.manyToManyTestSixs, set(this, \"isValid\", and(this.isValid, equal(length(data.id), 32)))))}");
        assertEquals("Invalid multiline statement test result", "true",
                Scripting.replaceVariables(ctx, testOne, "${this.isValid}"));

        Scripting.replaceVariables(ctx, testOne,
                "${(set(this, \"isValid\", true), each(this.manyToManyTestSixs, set(this, \"isValid\", and(this.isValid, gte(now, data.createdDate)))))}");
        assertEquals("Invalid multiline statement test result", "true",
                Scripting.replaceVariables(ctx, testOne, "${this.isValid}"));

        Scripting.replaceVariables(ctx, testOne,
                "${(set(this, \"isValid\", false), each(this.manyToManyTestSixs, set(this, \"isValid\", and(this.isValid, gte(now, data.createdDate)))))}");
        assertEquals("Invalid multiline statement test result", "false",
                Scripting.replaceVariables(ctx, testOne, "${this.isValid}"));

        // test multiple nested dot-separated properties (this.parent.parent.parent)
        assertEquals("Invalid multilevel property expression result", "false",
                Scripting.replaceVariables(ctx, testOne, "${empty(this.testThree.testOne.testThree)}"));

        // test extract() with additional evaluation function
        assertEquals("Invalid filter() result", "1", Scripting.replaceVariables(ctx, testOne,
                "${size(filter(this.manyToManyTestSixs, equal(data.index, 4)))}"));
        assertEquals("Invalid filter() result", "9", Scripting.replaceVariables(ctx, testOne,
                "${size(filter(this.manyToManyTestSixs, gt(data.index, 10)))}"));
        assertEquals("Invalid filter() result", "10", Scripting.replaceVariables(ctx, testOne,
                "${size(filter(this.manyToManyTestSixs, gte(data.index, 10)))}"));

        // test complex multiline statement replacement
        final String test = "${if(lte(template('TEST2', 'en_EN', this), 2), '<2', '>2')}\n" + // first expression should evaluate to ">2"
                "${if(lte(template('TEST2', 'en_EN', this), 3), '<3', '>3')}" // second expression should evaluate to "<3"
        ;

        final String result = Scripting.replaceVariables(ctx, testOne, test);

        assertEquals("Invalid multiline and template() result", ">2\n<3", result);

        // incoming
        assertEquals("Invalid number of incoming relationships", "20",
                Scripting.replaceVariables(ctx, testOne, "${size(incoming(this))}"));
        assertEquals("Invalid number of incoming relationships", "20",
                Scripting.replaceVariables(ctx, testOne, "${size(incoming(this, 'MANY_TO_MANY'))}"));
        assertEquals("Invalid number of incoming relationships", "1",
                Scripting.replaceVariables(ctx, testTwo, "${size(incoming(this))}"));
        assertEquals("Invalid number of incoming relationships", "1",
                Scripting.replaceVariables(ctx, testThree, "${size(incoming(this))}"));
        assertEquals("Invalid relationship type", "IS_AT",
                Scripting.replaceVariables(ctx, testTwo, "${get(incoming(this), 'relType')}"));
        assertEquals("Invalid relationship type", "OWNS",
                Scripting.replaceVariables(ctx, testThree, "${get(incoming(this), 'relType')}"));

        // outgoing
        assertEquals("Invalid number of outgoing relationships", "3",
                Scripting.replaceVariables(ctx, testOne, "${size(outgoing(this))}"));
        assertEquals("Invalid number of outgoing relationships", "2",
                Scripting.replaceVariables(ctx, testOne, "${size(outgoing(this, 'IS_AT'))}"));
        assertEquals("Invalid number of outgoing relationships", "1",
                Scripting.replaceVariables(ctx, testOne, "${size(outgoing(this, 'OWNS' ))}"));
        assertEquals("Invalid relationship type", "IS_AT",
                Scripting.replaceVariables(ctx, testOne, "${get(first(outgoing(this, 'IS_AT')), 'relType')}"));
        assertEquals("Invalid relationship type", "OWNS",
                Scripting.replaceVariables(ctx, testOne, "${get(outgoing(this, 'OWNS'), 'relType')}"));

        // has_relationships
        assertEquals("Invalid result of has_relationship", "false",
                Scripting.replaceVariables(ctx, testOne, "${has_relationship(this, this)}"));

        assertEquals("Invalid result of has_relationship", "true", Scripting.replaceVariables(ctx, testOne,
                "${has_relationship(this, first(find('TestTwo', 'name', 'testTwo_name')))}"));
        assertEquals("Invalid result of has_relationship", "true", Scripting.replaceVariables(ctx, testOne,
                "${has_relationship(this, first(find('TestTwo', 'name', 'testTwo_name')), 'IS_AT')}"));
        assertEquals("Invalid result of has_relationship", "true", Scripting.replaceVariables(ctx, testOne,
                "${has_relationship(first(find('TestTwo', 'name', 'testTwo_name')), this, 'IS_AT')}"));
        assertEquals("Invalid result of has_relationship", "false", Scripting.replaceVariables(ctx, testOne,
                "${has_relationship(this, first(find('TestTwo', 'name', 'testTwo_name')), 'THIS_DOES_NOT_EXIST')}"));

        assertEquals("Invalid result of has_relationship", "true", Scripting.replaceVariables(ctx, testTwo,
                "${has_relationship(first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')), this)}"));
        assertEquals("Invalid result of has_relationship", "true", Scripting.replaceVariables(ctx, testTwo,
                "${has_relationship(this, first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')))}"));

        assertEquals("Invalid result of has_relationship", "true", Scripting.replaceVariables(ctx, testOne,
                "${has_relationship(this, first(find('TestThree', 'name', 'testThree_name')))}"));
        assertEquals("Invalid result of has_relationship", "true", Scripting.replaceVariables(ctx, testOne,
                "${has_relationship(this, first(find('TestThree', 'name', 'testThree_name')), 'OWNS')}"));

        assertEquals("Invalid result of has_relationship", "false", Scripting.replaceVariables(ctx, testTwo,
                "${has_relationship(first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')), this, 'THIS_DOES_NOT_EXIST')}"));
        assertEquals("Invalid result of has_relationship", "false", Scripting.replaceVariables(ctx, testOne,
                "${has_relationship(this, first(find('TestThree', 'name', 'testThree_name')), 'THIS_DOES_NOT_EXIST')}"));

        // has_incoming_relationship
        assertEquals("Invalid result of has_incoming_relationship", "false",
                Scripting.replaceVariables(ctx, testOne, "${has_incoming_relationship(this, this)}"));

        assertEquals("Invalid result of has_incoming_relationship", "true", Scripting.replaceVariables(ctx,
                testOne, "${has_incoming_relationship(first(find('TestTwo', 'name', 'testTwo_name')), this)}"));
        assertEquals("Invalid result of has_incoming_relationship", "false", Scripting.replaceVariables(ctx,
                testOne, "${has_incoming_relationship(this, first(find('TestTwo', 'name', 'testTwo_name')))}"));

        assertEquals("Invalid result of has_incoming_relationship", "true", Scripting.replaceVariables(ctx,
                testOne,
                "${has_incoming_relationship(first(find('TestTwo', 'name', 'testTwo_name')), this, 'IS_AT')}"));
        assertEquals("Invalid result of has_incoming_relationship", "false", Scripting.replaceVariables(ctx,
                testOne,
                "${has_incoming_relationship(this, first(find('TestTwo', 'name', 'testTwo_name')), 'IS_AT')}"));

        assertEquals("Invalid result of has_incoming_relationship", "true", Scripting.replaceVariables(ctx,
                testOne,
                "${has_incoming_relationship(first(find('TestTwo', 'name', 'testTwo_name')), this, 'IS_AT')}"));
        assertEquals("Invalid result of has_incoming_relationship", "false", Scripting.replaceVariables(ctx,
                testOne,
                "${has_incoming_relationship(this, first(find('TestTwo', 'name', 'testTwo_name')), 'THIS_DOES_NOT_EXIST')}"));
        assertEquals("Invalid result of has_incoming_relationship", "false", Scripting.replaceVariables(ctx,
                testOne,
                "${has_incoming_relationship(first(find('TestTwo', 'name', 'testTwo_name')), this, 'THIS_DOES_NOT_EXIST')}"));

        assertEquals("Invalid result of has_incoming_relationship", "true", Scripting.replaceVariables(ctx,
                testTwo,
                "${has_incoming_relationship(this, first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')))}"));
        assertEquals("Invalid result of has_incoming_relationship", "false", Scripting.replaceVariables(ctx,
                testTwo,
                "${has_incoming_relationship(first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')), this)}"));

        assertEquals("Invalid result of has_incoming_relationship", "false", Scripting.replaceVariables(ctx,
                testOne,
                "${has_incoming_relationship(this, first(find('TestThree', 'name', 'testThree_name')))}"));
        assertEquals("Invalid result of has_incoming_relationship", "true", Scripting.replaceVariables(ctx,
                testOne,
                "${has_incoming_relationship(first(find('TestThree', 'name', 'testThree_name')), this)}"));

        assertEquals("Invalid result of has_incoming_relationship", "false", Scripting.replaceVariables(ctx,
                testOne,
                "${has_incoming_relationship(this, first(find('TestThree', 'name', 'testThree_name')), 'OWNS')}"));
        assertEquals("Invalid result of has_incoming_relationship", "true", Scripting.replaceVariables(ctx,
                testOne,
                "${has_incoming_relationship(first(find('TestThree', 'name', 'testThree_name')), this, 'OWNS')}"));

        assertEquals("Invalid result of has_incoming_relationship", "false", Scripting.replaceVariables(ctx,
                testOne,
                "${has_incoming_relationship(this, first(find('TestThree', 'name', 'testThree_name')), 'THIS_DOES_NOT_EXIST')}"));
        assertEquals("Invalid result of has_incoming_relationship", "false", Scripting.replaceVariables(ctx,
                testOne,
                "${has_incoming_relationship(first(find('TestThree', 'name', 'testThree_name')), this, 'THIS_DOES_NOT_EXIST')}"));

        assertEquals("Invalid result of has_incoming_relationship", "false", Scripting.replaceVariables(ctx,
                testTwo,
                "${has_incoming_relationship(first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')), this, 'THIS_DOES_NOT_EXIST')}"));
        assertEquals("Invalid result of has_incoming_relationship", "false", Scripting.replaceVariables(ctx,
                testTwo,
                "${has_incoming_relationship(this, first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')), 'THIS_DOES_NOT_EXIST')}"));
        assertEquals("Invalid result of has_incoming_relationship", "false", Scripting.replaceVariables(ctx,
                testOne,
                "${has_incoming_relationship(this, first(find('TestThree', 'name', 'testThree_name')), 'THIS_DOES_NOT_EXIST')}"));
        assertEquals("Invalid result of has_incoming_relationship", "false", Scripting.replaceVariables(ctx,
                testOne,
                "${has_incoming_relationship(first(find('TestThree', 'name', 'testThree_name')), this, 'THIS_DOES_NOT_EXIST')}"));

        // has_outgoing_relationship (since has_outgoing_relationship is just the inverse method to has_outgoing_relationship we can basically reuse the tests and just invert the result - except for the always-false or always-true tests)
        assertEquals("Invalid result of has_outgoing_relationship", "false",
                Scripting.replaceVariables(ctx, testOne, "${has_outgoing_relationship(this, this)}"));

        assertEquals("Invalid result of has_outgoing_relationship", "false", Scripting.replaceVariables(ctx,
                testOne, "${has_outgoing_relationship(first(find('TestTwo', 'name', 'testTwo_name')), this)}"));
        assertEquals("Invalid result of has_outgoing_relationship", "true", Scripting.replaceVariables(ctx,
                testOne, "${has_outgoing_relationship(this, first(find('TestTwo', 'name', 'testTwo_name')))}"));

        assertEquals("Invalid result of has_outgoing_relationship", "false", Scripting.replaceVariables(ctx,
                testOne,
                "${has_outgoing_relationship(first(find('TestTwo', 'name', 'testTwo_name')), this, 'IS_AT')}"));
        assertEquals("Invalid result of has_outgoing_relationship", "true", Scripting.replaceVariables(ctx,
                testOne,
                "${has_outgoing_relationship(this, first(find('TestTwo', 'name', 'testTwo_name')), 'IS_AT')}"));

        assertEquals("Invalid result of has_outgoing_relationship", "false", Scripting.replaceVariables(ctx,
                testOne,
                "${has_outgoing_relationship(first(find('TestTwo', 'name', 'testTwo_name')), this, 'IS_AT')}"));
        assertEquals("Invalid result of has_outgoing_relationship", "false", Scripting.replaceVariables(ctx,
                testOne,
                "${has_outgoing_relationship(this, first(find('TestTwo', 'name', 'testTwo_name')), 'THIS_DOES_NOT_EXIST')}"));
        assertEquals("Invalid result of has_outgoing_relationship", "false", Scripting.replaceVariables(ctx,
                testOne,
                "${has_outgoing_relationship(first(find('TestTwo', 'name', 'testTwo_name')), this, 'THIS_DOES_NOT_EXIST')}"));

        assertEquals("Invalid result of has_outgoing_relationship", "false", Scripting.replaceVariables(ctx,
                testTwo,
                "${has_outgoing_relationship(this, first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')))}"));
        assertEquals("Invalid result of has_outgoing_relationship", "true", Scripting.replaceVariables(ctx,
                testTwo,
                "${has_outgoing_relationship(first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')), this)}"));

        assertEquals("Invalid result of has_outgoing_relationship", "true", Scripting.replaceVariables(ctx,
                testOne,
                "${has_outgoing_relationship(this, first(find('TestThree', 'name', 'testThree_name')))}"));
        assertEquals("Invalid result of has_outgoing_relationship", "false", Scripting.replaceVariables(ctx,
                testOne,
                "${has_outgoing_relationship(first(find('TestThree', 'name', 'testThree_name')), this)}"));

        assertEquals("Invalid result of has_outgoing_relationship", "true", Scripting.replaceVariables(ctx,
                testOne,
                "${has_outgoing_relationship(this, first(find('TestThree', 'name', 'testThree_name')), 'OWNS')}"));
        assertEquals("Invalid result of has_outgoing_relationship", "false", Scripting.replaceVariables(ctx,
                testOne,
                "${has_outgoing_relationship(first(find('TestThree', 'name', 'testThree_name')), this, 'OWNS')}"));

        assertEquals("Invalid result of has_outgoing_relationship", "false", Scripting.replaceVariables(ctx,
                testOne,
                "${has_outgoing_relationship(this, first(find('TestThree', 'name', 'testThree_name')), 'THIS_DOES_NOT_EXIST')}"));
        assertEquals("Invalid result of has_outgoing_relationship", "false", Scripting.replaceVariables(ctx,
                testOne,
                "${has_outgoing_relationship(first(find('TestThree', 'name', 'testThree_name')), this, 'THIS_DOES_NOT_EXIST')}"));

        assertEquals("Invalid result of has_outgoing_relationship", "false", Scripting.replaceVariables(ctx,
                testTwo,
                "${has_outgoing_relationship(first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')), this, 'THIS_DOES_NOT_EXIST')}"));
        assertEquals("Invalid result of has_outgoing_relationship", "false", Scripting.replaceVariables(ctx,
                testTwo,
                "${has_outgoing_relationship(this, first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')), 'THIS_DOES_NOT_EXIST')}"));
        assertEquals("Invalid result of has_outgoing_relationship", "false", Scripting.replaceVariables(ctx,
                testOne,
                "${has_outgoing_relationship(this, first(find('TestThree', 'name', 'testThree_name')), 'THIS_DOES_NOT_EXIST')}"));
        assertEquals("Invalid result of has_outgoing_relationship", "false", Scripting.replaceVariables(ctx,
                testOne,
                "${has_outgoing_relationship(first(find('TestThree', 'name', 'testThree_name')), this, 'THIS_DOES_NOT_EXIST')}"));

        // get_relationships (CAUTION! If the method returns a string (error-case) the size-method returns "1" => it seems like there is one relationsh)
        assertEquals("Invalid number of relationships", "0",
                Scripting.replaceVariables(ctx, testOne, "${size(get_relationships(this, this))}"));

        // non-existent relType between nodes which have a relationship
        assertEquals("Invalid number of relationships", "0", Scripting.replaceVariables(ctx, testOne,
                "${size(get_relationships(first(find('TestTwo', 'name', 'testTwo_name')), this, 'THIS_DOES_NOT_EXIST'))}"));
        // non-existent relType between a node and itself
        assertEquals("Invalid number of relationships", "0", Scripting.replaceVariables(ctx, testOne,
                "${size(get_relationships(first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')), this, 'THIS_DOES_NOT_EXIST'))}"));

        // identical result test (from and to are just switched around)
        assertEquals("Invalid number of relationships", "1", Scripting.replaceVariables(ctx, testTwo,
                "${size(get_relationships(first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')), this, 'IS_AT'))}"));
        assertEquals("Invalid number of relationships", "1", Scripting.replaceVariables(ctx, testTwo,
                "${size(get_relationships(this, first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')), 'IS_AT'))}"));

        // get_incoming_relationships (CAUTION! If the method returns a string (error-case) the size-method returns "1" => it seems like there is one relationsh)
        assertEquals("Invalid number of incoming relationships", "0",
                Scripting.replaceVariables(ctx, testOne, "${size(get_incoming_relationships(this, this))}"));

        assertEquals("Invalid number of incoming relationships", "0", Scripting.replaceVariables(ctx, testOne,
                "${size(get_incoming_relationships(this, first(find('TestTwo', 'name', 'testTwo_name'))))}"));
        assertEquals("Invalid number of incoming relationships", "1", Scripting.replaceVariables(ctx, testOne,
                "${size(get_incoming_relationships(first(find('TestTwo', 'name', 'testTwo_name')), this))}"));
        assertEquals("Invalid number of incoming relationships", "0", Scripting.replaceVariables(ctx, testOne,
                "${size(get_incoming_relationships(this, first(find('TestTwo', 'name', 'testTwo_name')), 'IS_AT'))}"));
        assertEquals("Invalid number of incoming relationships", "1", Scripting.replaceVariables(ctx, testOne,
                "${size(get_incoming_relationships(first(find('TestTwo', 'name', 'testTwo_name')), this, 'IS_AT'))}"));

        assertEquals("Invalid number of incoming relationships", "1", Scripting.replaceVariables(ctx, testTwo,
                "${size(get_incoming_relationships(this, first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object'))))}"));
        assertEquals("Invalid number of incoming relationships", "1", Scripting.replaceVariables(ctx, testThree,
                "${size(get_incoming_relationships(this, first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object'))))}"));
        assertEquals("Invalid relationship type", "IS_AT", Scripting.replaceVariables(ctx, testTwo,
                "${get(first(get_incoming_relationships(this, first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')))), 'relType')}"));

        assertEquals("Invalid relationship type", "OWNS", Scripting.replaceVariables(ctx, testThree,
                "${get(first(get_incoming_relationships(this, first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')))), 'relType')}"));

        // get_outgoing_relationships (CAUTION! If the method returns a string (error-case) the size-method returns "1" => it seems like there is one relationsh)
        assertEquals("Invalid number of outgoing relationships", "0", Scripting.replaceVariables(ctx, testOne,
                "${size(get_outgoing_relationships(first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')), this))}"));

        assertEquals("Invalid number of outgoing relationships", "0", Scripting.replaceVariables(ctx, testTwo,
                "${size(get_outgoing_relationships(this, first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object'))))}"));

        assertEquals("Invalid number of outgoing relationships", "1", Scripting.replaceVariables(ctx, testTwo,
                "${size(get_outgoing_relationships(first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')), this))}"));
        assertEquals("Invalid number of outgoing relationships", "0", Scripting.replaceVariables(ctx, testTwo,
                "${size(get_outgoing_relationships(first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')), this, 'THIS_DOES_NOT_EXIST'))}"));

        assertEquals("Invalid number of outgoing relationships", "1", Scripting.replaceVariables(ctx, testThree,
                "${size(get_outgoing_relationships(first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')), this))}"));
        assertEquals("Invalid relationship type", "IS_AT", Scripting.replaceVariables(ctx, testTwo,
                "${get(first(get_outgoing_relationships(first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')), this)), 'relType')}"));

        assertEquals("Invalid relationship type", "OWNS", Scripting.replaceVariables(ctx, testThree,
                "${get(first(get_outgoing_relationships(first(find('TestOne', 'name', 'A-nice-little-name-for-my-test-object')), this)), 'relType')}"));

        // create_relationship
        // lifecycle for relationship t1-[:NEW_RELATIONSHIP_NAME]->t1
        assertEquals("Invalid number of relationships", "0", Scripting.replaceVariables(ctx, testOne,
                "${size(get_outgoing_relationships(this, this, 'IS_AT'))}"));
        assertEquals("unexpected result of create_relationship", "",
                Scripting.replaceVariables(ctx, testOne, "${create_relationship(this, this, 'IS_AT')}"));
        assertEquals("Invalid number of relationships", "1", Scripting.replaceVariables(ctx, testOne,
                "${size(get_outgoing_relationships(this, this, 'IS_AT'))}"));
        assertEquals("unexpected result of delete", "", Scripting.replaceVariables(ctx, testOne,
                "${delete(first(get_outgoing_relationships(this, this, 'IS_AT')))}"));
        assertEquals("Invalid number of relationships", "0", Scripting.replaceVariables(ctx, testOne,
                "${size(get_outgoing_relationships(this, this, 'IS_AT'))}"));

        // lifecycle for relationship t2-[:NEW_RELATIONSHIP_NAME]->t1
        assertEquals("Invalid number of relationships", "0", Scripting.replaceVariables(ctx, testOne,
                "${size(get_outgoing_relationships(first(find('TestTwo', 'name', 'testTwo_name')), this, 'IS_AT'))}"));
        assertEquals("unexpected result of create_relationship", "", Scripting.replaceVariables(ctx, testOne,
                "${create_relationship(first(find('TestTwo', 'name', 'testTwo_name')), this, 'IS_AT')}"));
        assertEquals("Invalid number of relationships", "1", Scripting.replaceVariables(ctx, testOne,
                "${size(get_outgoing_relationships(first(find('TestTwo', 'name', 'testTwo_name')), this, 'IS_AT'))}"));
        assertEquals("unexpected result of delete", "", Scripting.replaceVariables(ctx, testOne,
                "${delete(first(get_outgoing_relationships(first(find('TestTwo', 'name', 'testTwo_name')), this, 'IS_AT')))}"));
        assertEquals("Invalid number of relationships", "0", Scripting.replaceVariables(ctx, testOne,
                "${size(get_outgoing_relationships(first(find('TestTwo', 'name', 'testTwo_name')), this, 'IS_AT'))}"));

        // array index access
        assertEquals("Invalid array index accessor result", testSixs.get(0).getUuid(),
                Scripting.replaceVariables(ctx, testOne, "${this.manyToManyTestSixs[0]}"));
        assertEquals("Invalid array index accessor result", testSixs.get(2).getUuid(),
                Scripting.replaceVariables(ctx, testOne, "${this.manyToManyTestSixs[2]}"));
        assertEquals("Invalid array index accessor result", testSixs.get(4).getUuid(),
                Scripting.replaceVariables(ctx, testOne, "${this.manyToManyTestSixs[4]}"));

        // test new dot notation
        assertEquals("Invalid dot notation result", testSixs.get(0).getProperty(AbstractNode.name),
                Scripting.replaceVariables(ctx, testOne, "${this.manyToManyTestSixs[0].name}"));
        assertEquals("Invalid dot notation result", testSixs.get(0).getProperty(AbstractNode.name),
                Scripting.replaceVariables(ctx, testOne, "${sort(find('TestSix'), 'name')[0].name}"));
        assertEquals("Invalid dot notation result", testSixs.get(15).getProperty(AbstractNode.name),
                Scripting.replaceVariables(ctx, testOne, "${sort(find('TestSix'), 'name')[15].name}"));
        assertEquals("Invalid dot notation result", "20",
                Scripting.replaceVariables(ctx, testOne, "${this.manyToManyTestSixs.size}"));

        // test array property access
        assertEquals("Invalid string array access result", "one",
                Scripting.replaceVariables(ctx, testFour, "${this.stringArrayProperty[0]}"));
        assertEquals("Invalid string array access result", "two",
                Scripting.replaceVariables(ctx, testFour, "${this.stringArrayProperty[1]}"));
        assertEquals("Invalid string array access result", "three",
                Scripting.replaceVariables(ctx, testFour, "${this.stringArrayProperty[2]}"));
        assertEquals("Invalid string array access result", "four",
                Scripting.replaceVariables(ctx, testFour, "${this.stringArrayProperty[3]}"));

        // test string array property support in collection access methods
        assertEquals("Invalid string array access result with join()", "one,two,three,four",
                Scripting.replaceVariables(ctx, testFour, "${join(this.stringArrayProperty, ',')}"));
        assertEquals("Invalid string array access result with concat()", "onetwothreefour",
                Scripting.replaceVariables(ctx, testFour, "${concat(this.stringArrayProperty)}"));
        assertEquals("Invalid string array access result with first()", "one",
                Scripting.replaceVariables(ctx, testFour, "${first(this.stringArrayProperty)}"));
        assertEquals("Invalid string array access result with last()", "four",
                Scripting.replaceVariables(ctx, testFour, "${last(this.stringArrayProperty)}"));
        assertEquals("Invalid string array access result with size()", "4",
                Scripting.replaceVariables(ctx, testFour, "${size(this.stringArrayProperty)}"));
        assertEquals("Invalid string array access result with .size", "4",
                Scripting.replaceVariables(ctx, testFour, "${this.stringArrayProperty.size}"));
        assertEquals("Invalid string array access result with nth", "one",
                Scripting.replaceVariables(ctx, testFour, "${nth(this.stringArrayProperty, 0)}"));
        assertEquals("Invalid string array access result with nth", "two",
                Scripting.replaceVariables(ctx, testFour, "${nth(this.stringArrayProperty, 1)}"));
        assertEquals("Invalid string array access result with nth", "three",
                Scripting.replaceVariables(ctx, testFour, "${nth(this.stringArrayProperty, 2)}"));
        assertEquals("Invalid string array access result with nth", "four",
                Scripting.replaceVariables(ctx, testFour, "${nth(this.stringArrayProperty, 3)}"));
        assertEquals("Invalid string array access result with contains()", "true",
                Scripting.replaceVariables(ctx, testFour, "${contains(this.stringArrayProperty, 'two')}"));
        assertEquals("Invalid string array access result with contains()", "false",
                Scripting.replaceVariables(ctx, testFour, "${contains(this.stringArrayProperty, 'five')}"));

        // find
        assertEquals("Invalid find() result for empty values", testThree.getUuid(), Scripting
                .replaceVariables(ctx, testOne, "${first(find('TestThree', 'oneToOneTestSix', null))}"));
        assertEquals("Invalid find() result for empty values", testThree.getUuid(), Scripting
                .replaceVariables(ctx, testOne, "${first(find('TestThree', 'oneToManyTestSix', null))}"));

        // search
        assertEquals("Invalid search() result", testOne.getUuid(), Scripting.replaceVariables(ctx, testTwo,
                "${first(search('TestOne', 'name', 'A-nice-little-name-for-my-test-object'))}"));
        assertEquals("Invalid search() result", testOne.getUuid(), Scripting.replaceVariables(ctx, testTwo,
                "${first(search('TestOne', 'name', '*little-name-for-my-test-object'))}"));
        assertEquals("Invalid search() result", testOne.getUuid(), Scripting.replaceVariables(ctx, testTwo,
                "${first(search('TestOne', 'name', 'A-nice-little-name-for*'))}"));

        // negative test for find()
        assertEquals("Invalid find() result", "", Scripting.replaceVariables(ctx, testTwo,
                "${first(find('TestOne', 'name', '*little-name-for-my-test-object'))}"));
        assertEquals("Invalid find() result", "", Scripting.replaceVariables(ctx, testTwo,
                "${first(find('TestOne', 'name', 'A-nice-little-name-for*'))}"));

        // create
        Integer noOfOnes = 1;
        assertEquals("Invalid number of TestOne's", "" + noOfOnes,
                Scripting.replaceVariables(ctx, testOne, "${size(find('TestOne'))}"));

        // currently the creation of nodes must take place in a node of another type
        Scripting.replaceVariables(ctx, testFour, "${create('TestOne', 'name', 'createTestOne1')}");
        noOfOnes++;
        assertEquals("Invalid number of TestOne's", "" + noOfOnes,
                Scripting.replaceVariables(ctx, testOne, "${size(find('TestOne'))}"));
        assertEquals("Invalid number of TestOne's", "1",
                Scripting.replaceVariables(ctx, testOne, "${size(find('TestOne', 'name', 'createTestOne1'))}"));

        Scripting.replaceVariables(ctx, testFour, "${create('TestOne', 'name', 'createTestOne1')}");
        noOfOnes++;
        assertEquals("Invalid number of TestOne's", "" + noOfOnes,
                Scripting.replaceVariables(ctx, testOne, "${size(find('TestOne'))}"));
        assertEquals("Invalid number of TestOne's", "2",
                Scripting.replaceVariables(ctx, testOne, "${size(find('TestOne', 'name', 'createTestOne1'))}"));

        // currently this must be executed on another node type
        Scripting.replaceVariables(ctx, testFour,
                "${create('TestOne', 'name', 'createTestOne2', 'aCreateString', 'newCreateString1')}");
        noOfOnes++;
        assertEquals("Invalid number of TestOne's", "" + noOfOnes,
                Scripting.replaceVariables(ctx, testOne, "${size(find('TestOne'))}"));
        assertEquals("Invalid number of TestOne's", "1",
                Scripting.replaceVariables(ctx, testOne, "${size(find('TestOne', 'name', 'createTestOne2'))}"));
        assertEquals("Invalid number of TestOne's", "0", Scripting.replaceVariables(ctx, testOne,
                "${size(find('TestOne', 'aCreateString', 'DOES_NOT_EXIST'))}"));
        assertEquals("Invalid number of TestOne's", "1", Scripting.replaceVariables(ctx, testOne,
                "${size(find('TestOne', 'aCreateString', 'newCreateString1'))}"));
        assertEquals("Invalid number of TestOne's", "0", Scripting.replaceVariables(ctx, testOne,
                "${size(find('TestOne', 'name', 'createTestOne2', 'aCreateString', 'NOT_newCreateString1'))}"));
        assertEquals("Invalid number of TestOne's", "1", Scripting.replaceVariables(ctx, testOne,
                "${size(find('TestOne', 'name', 'createTestOne2', 'aCreateString', 'newCreateString1'))}"));

        // currently this must be executed on another node type
        Scripting.replaceVariables(ctx, testFour,
                "${create('TestOne', 'name', 'createTestOne2', 'aCreateInt', '256')}");
        noOfOnes++;
        assertEquals("Invalid number of TestOne's", "" + noOfOnes,
                Scripting.replaceVariables(ctx, testOne, "${size(find('TestOne'))}"));
        assertEquals("Invalid number of TestOne's", "2",
                Scripting.replaceVariables(ctx, testOne, "${size(find('TestOne', 'name', 'createTestOne2'))}"));
        assertEquals("Invalid number of TestOne's", "1",
                Scripting.replaceVariables(ctx, testOne, "${size(find('TestOne', 'aCreateInt', '256'))}"));
        assertEquals("Invalid number of TestOne's", "0", Scripting.replaceVariables(ctx, testOne,
                "${size(find('TestOne', 'name', 'createTestOne2', 'aCreateInt', '255'))}"));
        assertEquals("Invalid number of TestOne's", "1", Scripting.replaceVariables(ctx, testOne,
                "${size(find('TestOne', 'name', 'createTestOne2', 'aCreateInt', '256'))}"));

        tx.success();

    } catch (FrameworkException fex) {

        fex.printStackTrace();

        fail(fex.getMessage());
    }
}

From source file:com.erudika.scoold.utils.LanguageUtils.java

/**
 * Returns a non-null locale for a given language code.
 * @param langCode the 2-letter language code
 * @return a locale. default is English/*from   w ww .  jav  a2s  .  c  om*/
 */
public Locale getProperLocale(String langCode) {
    if (StringUtils.startsWith(langCode, "zh")) {
        if ("zh_tw".equalsIgnoreCase(langCode)) {
            return Locale.TRADITIONAL_CHINESE;
        } else {
            return Locale.SIMPLIFIED_CHINESE;
        }
    }
    String lang = StringUtils.substring(langCode, 0, 2);
    lang = (StringUtils.isBlank(lang) || !ALL_LOCALES.containsKey(lang)) ? "en" : lang.trim().toLowerCase();
    return ALL_LOCALES.get(lang);
}

From source file:com.example.carsharing.ShortWayActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    photouri = Uri//from   w  ww . ja  va 2 s  .co m
            .fromFile(new File(this.getExternalFilesDir(Environment.DIRECTORY_PICTURES), IMAGE_FILE_NAME2));
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_short_way);

    activity_drawer = new Drawer(this, R.id.short_way_layout);
    mDrawerToggle = activity_drawer.newdrawer();
    mDrawerLayout = activity_drawer.setDrawerLayout();

    bdriver = true;

    // 
    SharedPreferences sharedPref = this.getSharedPreferences(getString(R.string.PreferenceDefaultName),
            Context.MODE_PRIVATE);
    UserPhoneNumber = sharedPref.getString(getString(R.string.PreferenceUserPhoneNumber), "0");

    // 
    standard_date = new SimpleDateFormat("yyyy-MM-dd", Locale.SIMPLIFIED_CHINESE);
    primary_date = new SimpleDateFormat("yyyyMMdd", Locale.SIMPLIFIED_CHINESE);
    standard_time = new SimpleDateFormat("HH:mm:ss", Locale.SIMPLIFIED_CHINESE);
    primary_time = new SimpleDateFormat("HHmmss", Locale.SIMPLIFIED_CHINESE);

    queue = Volley.newRequestQueue(this);

    exchange = (ImageView) findViewById(R.id.shortway_exchange);
    exchange.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            String temp = startplace.getText().toString();
            if (!temp.equals("") && !endplace.getText().toString().equals("")) {
                startplace.setText(endplace.getText().toString());
                endplace.setText(temp);
                float a, b;
                a = startplace_longitude;
                b = startplace_latitude;
                startplace_longitude = destination_longitude;
                startplace_latitude = destination_latitude;
                destination_longitude = a;
                destination_latitude = b;

            }
        }
    });

    datebutton = (Button) findViewById(R.id.shortway_dates);
    earlystarttime = (Button) findViewById(R.id.shortway_earliest_start_time);
    latestarttime = (Button) findViewById(R.id.shortway_latest_start_time);
    increase = (Button) findViewById(R.id.shortway_increase);
    decrease = (Button) findViewById(R.id.shortway_decrease);
    s2 = (TextView) findViewById(R.id.shortway_count);
    startplace = (Button) findViewById(R.id.shortway_startplace);
    endplace = (Button) findViewById(R.id.shortway_endplace);
    sure = (Button) findViewById(R.id.shortway_sure);

    commute = findViewById(R.id.drawer_commute);
    shortway = findViewById(R.id.drawer_shortway);
    longway = findViewById(R.id.drawer_longway);
    setting = findViewById(R.id.drawer_setting);
    personalcenter = findViewById(R.id.drawer_personalcenter);
    about = findViewById(R.id.drawer_respond);
    taxi = findViewById(R.id.drawer_taxi);

    drawericon = (ImageView) findViewById(R.id.drawer_icon);
    drawername = (TextView) findViewById(R.id.drawer_name);
    drawernum = (TextView) findViewById(R.id.drawer_phone);
    carbrand = (EditText) findViewById(R.id.shortway_CarBrand);
    model = (EditText) findViewById(R.id.shortway_CarModel);
    color = (EditText) findViewById(R.id.shortway_color);
    licensenum = (EditText) findViewById(R.id.shortway_Num);

    licensenum.addTextChangedListener(numTextWatcher);
    carbrand.addTextChangedListener(detTextWatcher);
    color.addTextChangedListener(coTextWatcher);
    model.addTextChangedListener(moTextWatcher);

    next = (Button) findViewById(R.id.shortway_sure);
    next.setEnabled(false);
    db = new DatabaseHelper(ShortWayActivity.this, "test", null, 1);
    db1 = db.getWritableDatabase();

    final TextView content = (TextView) findViewById(R.id.shortway_content);
    mRadio1 = (RadioButton) findViewById(R.id.shortway_radioButton1);
    mRadio2 = (RadioButton) findViewById(R.id.shortway_radioButton2);
    shortway_group = (RadioGroup) findViewById(R.id.shortway_radiobutton01);
    star1 = (ImageView) findViewById(R.id.shortway_star);
    star2 = (ImageView) findViewById(R.id.shortway_star01);

    // judge the value of "pre_page"
    Bundle bundle = this.getIntent().getExtras();
    String PRE_PAGE = bundle.getString("pre_page");
    if (PRE_PAGE.compareTo("ReOrder") == 0) { // 
        startplace.setText(bundle.getString("stpusername") + "," + bundle.getString("stpmapname"));
        bstart = true;
        endplace.setText(bundle.getString("epusername") + "," + bundle.getString("epmapname"));
        bend = true;
        startplace_longitude = bundle.getFloat("stpx");
        Log.e("startplace_longitude", String.valueOf(startplace_longitude));
        startplace_latitude = bundle.getFloat("stpy");
        Log.e("startplace_latitude", String.valueOf(startplace_latitude));
        destination_longitude = bundle.getFloat("epx");
        Log.e("destination_longitude", String.valueOf(destination_longitude));
        destination_latitude = bundle.getFloat("epy");
        Log.e("destination_latitude", String.valueOf(destination_latitude));
        datebutton.setText(bundle.getString("re_short_startdate"));
        bdate = true;
        earlystarttime.setText(bundle.getString("re_short_starttime"));
        best = true;
        latestarttime.setText(bundle.getString("re_short_endtime"));
        blst = true;
    }
    // judge the value of "pre_page"

    about.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent about = new Intent(ShortWayActivity.this, AboutActivity.class);
            startActivity(about);
        }
    });
    setting.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent setting = new Intent(ShortWayActivity.this, SettingActivity.class);
            startActivity(setting);
        }
    });

    // database
    db = new DatabaseHelper(getApplicationContext(), UserPhoneNumber, null, 1);
    db1 = db.getWritableDatabase();

    // database end

    star1.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {

            if (bstart) {
                if (Pointisliked(StartPointMapName)) {
                    // Define 'where' part of query.
                    String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?";
                    // Specify arguments in placeholder order.
                    String[] selelectionArgs = { StartPointMapName };
                    // Issue SQL statement.
                    db1.delete(getString(R.string.dbtable_placeliked), selection, selelectionArgs);
                    star1.setImageResource(R.drawable.ic_action_not_important);

                } else {
                    ContentValues content = new ContentValues();
                    content.put(getString(R.string.dbstring_PlaceUserName), StartPointUserName);
                    content.put(getString(R.string.dbstring_PlaceMapName), StartPointMapName);
                    content.put(getString(R.string.dbstring_longitude), startplace_longitude);
                    content.put(getString(R.string.dbstring_latitude), startplace_latitude);
                    db1.insert(getString(R.string.dbtable_placeliked), null, content);

                    // Define 'where' part of query.
                    String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?";
                    // Specify arguments in placeholder order.
                    String[] selelectionArgs = { StartPointMapName };
                    // Issue SQL statement.
                    db1.delete(getString(R.string.dbtable_placehistory), selection, selelectionArgs);
                    star1.setImageResource(R.drawable.ic_action_important);
                }

            }

        }
    });
    star2.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {

            if (bend) {
                if (Pointisliked(EndPointMapName)) {
                    // Define 'where' part of query.
                    String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?";
                    // Specify arguments in placeholder order.
                    String[] selelectionArgs = { EndPointMapName };
                    // Issue SQL statement.
                    db1.delete(getString(R.string.dbtable_placeliked), selection, selelectionArgs);
                    star2.setImageResource(R.drawable.ic_action_not_important);

                } else {
                    ContentValues content = new ContentValues();
                    content.put(getString(R.string.dbstring_PlaceUserName), EndPointUserName);
                    content.put(getString(R.string.dbstring_PlaceMapName), EndPointMapName);
                    content.put(getString(R.string.dbstring_longitude), destination_longitude);
                    content.put(getString(R.string.dbstring_latitude), destination_latitude);
                    db1.insert(getString(R.string.dbtable_placeliked), null, content);

                    // Define 'where' part of query.
                    String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?";
                    // Specify arguments in placeholder order.
                    String[] selelectionArgs = { EndPointMapName };
                    // Issue SQL statement.
                    db1.delete(getString(R.string.dbtable_placehistory), selection, selelectionArgs);
                    star2.setImageResource(R.drawable.ic_action_important);
                }

            }

        }
    });

    taxi.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
        }
    });

    personalcenter.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent personalcenter = new Intent(ShortWayActivity.this, PersonalCenterActivity.class);

            startActivity(personalcenter);
        }
    });

    shortway.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
        }
    });

    longway.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent longway = new Intent(ShortWayActivity.this, MainActivity.class);
            startActivity(longway);
        }
    });

    commute.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent commute = new Intent(ShortWayActivity.this, CommuteActivity.class);
            commute.putExtra("pre_page", "Drawer");
            startActivity(commute);
        }
    });

    // RadioGroup
    shortway_group.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup arg0, int checkedId) {
            // TODO Auto-generated method stub18
            // ID

            // """"textView
            if (checkedId == mRadio2.getId()) {
                bpassenager = true;
                bdriver = false;

                licensenum.setEnabled(false);
                carbrand.setEnabled(false);
                color.setEnabled(false);
                model.setEnabled(false);

                licensenum.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                carbrand.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                color.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                model.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                content.setText(getString(R.string.warningInfo_seatNeed));
                licensenum.setHintTextColor(Color.parseColor("#cccccc"));
                carbrand.setHintTextColor(Color.parseColor("#cccccc"));
                color.setHintTextColor(Color.parseColor("#cccccc"));
                model.setHintTextColor(Color.parseColor("#cccccc"));
                licensenum.setInputType(InputType.TYPE_NULL);
                carbrand.setInputType(InputType.TYPE_NULL);
                color.setInputType(InputType.TYPE_NULL);
                model.setInputType(InputType.TYPE_NULL);
            } else {
                bpassenager = false;
                bdriver = true;

                licensenum.setEnabled(true);
                carbrand.setEnabled(true);
                color.setEnabled(true);
                model.setEnabled(true);

                licensenum.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {

                        return null;
                    }
                } });
                carbrand.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return null;
                    }
                } });
                color.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {

                        return null;
                    }
                } });
                model.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {

                        return null;
                    }
                } });
                content.setText(getString(R.string.warningInfo_seatOffer));
                licensenum.setHintTextColor(Color.parseColor("#9F35FF"));
                carbrand.setHintTextColor(Color.parseColor("#9F35FF"));
                color.setHintTextColor(Color.parseColor("#9F35FF"));
                model.setHintTextColor(Color.parseColor("#9F35FF"));
                // licensenum.setText("");
                // carbrand.setText("");
                // color.setText("");
                // model.setText("");
                licensenum.setInputType(InputType.TYPE_CLASS_TEXT);
                carbrand.setInputType(InputType.TYPE_CLASS_TEXT);
                color.setInputType(InputType.TYPE_CLASS_TEXT);
                model.setInputType(InputType.TYPE_CLASS_TEXT);

                // start!
                selectcarinfo(UserPhoneNumber);
                // end!
            }
            confirm();
        }

    });

    sure.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            if (shortway_group.getCheckedRadioButtonId() == mRadio1.getId())
                userrole = "d";
            else
                userrole = "p";

            // start!
            shortway_request(UserPhoneNumber, datebutton.getText().toString(),
                    earlystarttime.getText().toString(), latestarttime.getText().toString());
            // end!

        }

        private void shortway_request(final String shortway_phonenum, final String shortway_date,
                final String shortway_starttime, final String shortway_endtime) {
            // TODO Auto-generated method stub

            // start
            try {
                test_date = primary_date.parse(shortway_date);
                standard_shortway_startdate = standard_date.format(test_date);
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            try {
                test_date = primary_time.parse(shortway_starttime);
                standard_shortway_starttime = standard_time.format(test_date);
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            try {
                test_date = primary_time.parse(shortway_endtime);
                standard_shortway_endtime = standard_time.format(test_date);
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            // end!

            String shortway_baseurl = getString(R.string.uri_base) + getString(R.string.uri_ShortwayRequest)
                    + getString(R.string.uri_addrequest_action);
            // "http://192.168.1.111:8080/CarsharingServer/ShortwayRequest!addrequest.action?";

            Log.w("URL", shortway_baseurl);
            StringRequest stringRequest = new StringRequest(Request.Method.POST, shortway_baseurl,
                    new Response.Listener<String>() {

                        @Override
                        public void onResponse(String response) {
                            Log.d("shortway_result", response);
                            JSONObject json1 = null;
                            try {
                                json1 = new JSONObject(response);
                                requestok = json1.getBoolean("result");
                            } catch (JSONException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                            if (requestok == true) {

                                if (carinfochoosing_type == 1) {
                                    // add
                                    // start!
                                    carinfo(shortway_phonenum, licensenum.getText().toString(),
                                            carbrand.getText().toString(), model.getText().toString(),
                                            color.getText().toString(), String.valueOf(sum), 1);
                                    // end!
                                } else {
                                    // update
                                    // start!
                                    carinfo(shortway_phonenum, licensenum.getText().toString(),
                                            carbrand.getText().toString(), model.getText().toString(),
                                            color.getText().toString(), String.valueOf(sum), 2);
                                    // end!
                                }

                                Intent sure = new Intent(ShortWayActivity.this, OrderResponseActivity.class);
                                sure.putExtra(getString(R.string.request_response), "true");
                                sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                                startActivity(sure);
                            } else {
                                // Toast errorinfo =
                                // Toast.makeText(getApplicationContext(),
                                // "", Toast.LENGTH_LONG);
                                // errorinfo.show();
                                Intent sure = new Intent(ShortWayActivity.this, OrderResponseActivity.class);
                                sure.putExtra(getString(R.string.request_response), "false");
                            }
                        }

                    }, new Response.ErrorListener() {
                        @Override
                        public void onErrorResponse(VolleyError error) {
                            Log.e("shortway_result", error.getMessage(), error);
                            // Toast errorinfo = Toast.makeText(null,
                            // "", Toast.LENGTH_LONG);
                            // errorinfo.show();
                            Intent sure = new Intent(ShortWayActivity.this, OrderResponseActivity.class);
                            sure.putExtra(getString(R.string.request_response), "false");
                            sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                            startActivity(sure);
                        }
                    }) {
                protected Map<String, String> getParams() {
                    // POSTgetParams

                    // start
                    try {
                        test_date = primary_date.parse(shortway_date);
                        standard_shortway_startdate = standard_date.format(test_date);
                    } catch (ParseException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                    try {
                        test_date = primary_time.parse(shortway_starttime);
                        standard_shortway_starttime = standard_time.format(test_date);
                    } catch (ParseException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                    try {
                        test_date = primary_time.parse(shortway_endtime);
                        standard_shortway_endtime = standard_time.format(test_date);
                    } catch (ParseException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    // end!

                    Map<String, String> params = new HashMap<String, String>();
                    params.put("phonenum", shortway_phonenum);
                    params.put("userrole", userrole);
                    params.put("startplacex", String.valueOf(startplace_longitude));
                    params.put("startplacey", String.valueOf(startplace_latitude));
                    params.put(getString(R.string.uri_startplace), startplace.getText().toString());
                    params.put("destinationx", String.valueOf(destination_longitude));
                    params.put("destinationy", String.valueOf(destination_latitude));
                    params.put(getString(R.string.uri_destination), endplace.getText().toString());
                    params.put("startdate", standard_shortway_startdate);
                    params.put("starttime", standard_shortway_starttime);
                    params.put("endtime", standard_shortway_endtime);

                    return params;
                }
            };

            queue.add(stringRequest);
        }
    });

    startplace.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            startActivityForResult(new Intent(ShortWayActivity.this, ChooseAddressActivity.class), 1);
        }
    });

    endplace.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            startActivityForResult(new Intent(ShortWayActivity.this, ChooseArrivalActivity.class), 2);
        }
    });

    increase.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            sum++;
            s2.setText("" + sum);
            confirm();
        }
    });

    decrease.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            sum--;
            if (sum < 0) {
                sum = 0;
            }
            s2.setText("" + sum);
            confirm();
        }
    });

    datebutton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            showDialog(DATE_DIALOG);
        }
    });

    earlystarttime.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            showDialog(TIME_DIALOG);
        }
    });
    latestarttime.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            showDialog(TIME_DIALOG1);

        }
    });

}

From source file:hk.idv.kenson.jrconsole.Console.java

/**
 * /*from w  w w  . jav a 2  s.com*/
 * @param localeString
 * @return
 */
private static Locale getLocale(String localeString) {
    if ("default".equals(localeString))
        return Locale.getDefault();
    if ("canada".equals(localeString))
        return Locale.CANADA;
    if ("canada_french".equals(localeString))
        return Locale.CANADA_FRENCH;
    if ("china".equals(localeString))
        return Locale.CHINA;
    if ("chinese".equals(localeString))
        return Locale.CHINESE;
    if ("english".equals(localeString))
        return Locale.ENGLISH;
    if ("franch".equals(localeString))
        return Locale.FRANCE;
    if ("german".equals(localeString))
        return Locale.GERMAN;
    if ("germany".equals(localeString))
        return Locale.GERMANY;
    if ("italian".equals(localeString))
        return Locale.ITALIAN;
    if ("italy".equals(localeString))
        return Locale.ITALY;
    if ("japan".equals(localeString))
        return Locale.JAPAN;
    if ("japanese".equals(localeString))
        return Locale.JAPANESE;
    if ("korea".equals(localeString))
        return Locale.KOREA;
    if ("korean".equals(localeString))
        return Locale.KOREAN;
    if ("prc".equals(localeString))
        return Locale.PRC;
    if ("simplified_chinese".equals(localeString))
        return Locale.SIMPLIFIED_CHINESE;
    if ("taiwan".equals(localeString))
        return Locale.TAIWAN;
    if ("traditional_chinese".equals(localeString))
        return Locale.TRADITIONAL_CHINESE;
    if ("uk".equals(localeString))
        return Locale.UK;
    if ("us".equals(localeString))
        return Locale.US;

    String parts[] = localeString.split("_", -1);
    if (parts.length == 1)
        return new Locale(parts[0]);
    else if (parts.length == 2)
        return new Locale(parts[0], parts[1]);
    else
        return new Locale(parts[0], parts[1], parts[2]);
}

From source file:com.example.carsharing.CommuteActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    photouri = Uri//from  www. j  av  a  2  s  .  com
            .fromFile(new File(this.getExternalFilesDir(Environment.DIRECTORY_PICTURES), IMAGE_FILE_NAME2));
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_commute);

    activity_drawer = new Drawer(this, R.id.commute_layout);
    mDrawerToggle = activity_drawer.newdrawer();
    mDrawerLayout = activity_drawer.setDrawerLayout();

    // 
    standard_date = new SimpleDateFormat("yyyy-MM-dd", Locale.SIMPLIFIED_CHINESE);
    primary_date = new SimpleDateFormat("yyyyMMdd", Locale.SIMPLIFIED_CHINESE);
    standard_time = new SimpleDateFormat("HH:mm:ss", Locale.SIMPLIFIED_CHINESE);
    primary_time = new SimpleDateFormat("HHmmss", Locale.SIMPLIFIED_CHINESE);

    drawername = (TextView) findViewById(R.id.drawer_name);
    drawernum = (TextView) findViewById(R.id.drawer_phone);
    queue = Volley.newRequestQueue(this);
    exchange = (ImageView) findViewById(R.id.commute_exchange);
    exchange.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            String temp = startplace.getText().toString();
            if (!temp.equals("") && !endplace.getText().toString().equals("")) {
                startplace.setText(endplace.getText().toString());
                endplace.setText(temp);
                float a, b;
                a = startplace_longitude;
                b = startplace_latitude;
                startplace_longitude = destination_longitude;
                startplace_latitude = destination_latitude;
                destination_longitude = a;
                destination_latitude = b;

            }
        }
    });

    bdriver = true;
    bmon = true;
    btue = true;
    bwed = true;
    bthu = true;
    bfri = true;

    startdate = (Button) findViewById(R.id.commute_startdate);
    earlystarttime = (Button) findViewById(R.id.commute_earliest_start_time);
    enddate = (Button) findViewById(R.id.commute_enddate);
    latestarttime = (Button) findViewById(R.id.commute_latest_start_time);
    increase = (Button) findViewById(R.id.commute_increase);
    decrease = (Button) findViewById(R.id.commute_decrease);
    s1 = (TextView) findViewById(R.id.commute_count);
    drawericon = (ImageView) findViewById(R.id.drawer_icon);
    startplace = (Button) findViewById(R.id.commute_startplace);
    endplace = (Button) findViewById(R.id.commute_endplace);
    sure = (Button) findViewById(R.id.commute_sure);
    sure.setEnabled(false);

    carbrand = (EditText) findViewById(R.id.commute_CarBrand);
    model = (EditText) findViewById(R.id.commute_CarModel);
    color = (EditText) findViewById(R.id.commute_color);
    licensenum = (EditText) findViewById(R.id.commute_Num);

    licensenum.addTextChangedListener(numTextWatcher);
    carbrand.addTextChangedListener(detTextWatcher);
    color.addTextChangedListener(coTextWatcher);
    model.addTextChangedListener(moTextWatcher);

    final TextView content = (TextView) findViewById(R.id.commute_content);

    commute_group = (RadioGroup) findViewById(R.id.commute_radiobutton);
    mRadio1 = (RadioButton) findViewById(R.id.commute_radioButton1);
    mRadio2 = (RadioButton) findViewById(R.id.commute_radioButton2);// RadioGroup

    mon = (CheckBox) findViewById(R.id.commute_checkBox1);
    tue = (CheckBox) findViewById(R.id.commute_checkBox2);
    wed = (CheckBox) findViewById(R.id.commute_checkBox3);
    thu = (CheckBox) findViewById(R.id.commute_checkBox4);
    fri = (CheckBox) findViewById(R.id.commute_checkBox5);
    sat = (CheckBox) findViewById(R.id.commute_checkBox6);
    sun = (CheckBox) findViewById(R.id.commute_checkBox7);

    commute = findViewById(R.id.drawer_commute);
    shortway = findViewById(R.id.drawer_shortway);
    longway = findViewById(R.id.drawer_longway);
    setting = findViewById(R.id.drawer_setting);
    personalcenter = findViewById(R.id.drawer_personalcenter);
    taxi = findViewById(R.id.drawer_taxi);

    star1 = (ImageView) findViewById(R.id.cummute_star);
    star2 = (ImageView) findViewById(R.id.commute_star01);

    // 
    SharedPreferences sharedPref = this.getSharedPreferences(getString(R.string.PreferenceDefaultName),
            Context.MODE_PRIVATE);
    UserPhoneNumber = sharedPref.getString(getString(R.string.PreferenceUserPhoneNumber), "0");

    // judge the value of "pre_page"
    Bundle bundle = this.getIntent().getExtras();
    String PRE_PAGE = bundle.getString("pre_page");
    if (PRE_PAGE.compareTo("ReOrder") == 0) { // 
        startplace.setText(bundle.getString("stpusername") + "," + bundle.getString("stpmapname"));
        bstart = true;
        endplace.setText(bundle.getString("epusername") + "," + bundle.getString("epmapname"));
        bend = true;
        startplace_longitude = bundle.getFloat("stpx");
        Log.e("startplace_longitude", String.valueOf(startplace_longitude));
        startplace_latitude = bundle.getFloat("stpy");
        Log.e("startplace_latitude", String.valueOf(startplace_latitude));
        destination_longitude = bundle.getFloat("epx");
        Log.e("destination_longitude", String.valueOf(destination_longitude));
        destination_latitude = bundle.getFloat("epy");
        Log.e("destination_latitude", String.valueOf(destination_latitude));
        startdate.setText(bundle.getString("re_commute_startdate"));
        bstartdate = true;
        enddate.setText(bundle.getString("re_commute_enddate"));
        benddate = true;
        weekrepeat = bundle.getString("weekrepeat");
        earlystarttime.setText(bundle.getString("re_commute_starttime"));
        bearlystarttime = true;
        latestarttime.setText(bundle.getString("re_commute_endtime"));
        blatestarttime = true;

        // weekrepeatcheckbox
        int len = weekrepeat.length();
        for (int i = 0; i < len; i++) {
            if (weekrepeat.charAt(i) == '1') {
                mon.setChecked(true);
                bmon = true;
            }
            if (weekrepeat.charAt(i) == '2') {
                tue.setChecked(true);
                btue = true;
            }
            if (weekrepeat.charAt(i) == '3') {
                wed.setChecked(true);
                bwed = true;
            }
            if (weekrepeat.charAt(i) == '4') {
                thu.setChecked(true);
                bthu = true;
            }
            if (weekrepeat.charAt(i) == '5') {
                fri.setChecked(true);
                bfri = true;
            }
            if (weekrepeat.charAt(i) == '6') {
                sat.setChecked(true);
                bsat = true;
            }
            if (weekrepeat.charAt(i) == '7') {
                sun.setChecked(true);
                bsun = true;
            }
        }
        // end
    }
    // judge the value of "pre_page"

    // database
    db = new DatabaseHelper(getApplicationContext(), UserPhoneNumber, null, 1);
    db1 = db.getWritableDatabase();
    about = findViewById(R.id.drawer_respond);
    about.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent about = new Intent(CommuteActivity.this, AboutActivity.class);
            startActivity(about);
        }
    });
    setting.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent setting = new Intent(CommuteActivity.this, SettingActivity.class);
            startActivity(setting);
        }
    });

    // database end

    star1.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {

            if (bstart) {
                if (Pointisliked(StartPointMapName)) {
                    // Define 'where' part of query.
                    String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?";
                    // Specify arguments in placeholder order.
                    String[] selelectionArgs = { StartPointMapName };
                    // Issue SQL statement.
                    db1.delete(getString(R.string.dbtable_placeliked), selection, selelectionArgs);
                    star1.setImageResource(R.drawable.ic_action_not_important);

                } else {
                    ContentValues content = new ContentValues();
                    content.put(getString(R.string.dbstring_PlaceUserName), StartPointUserName);
                    content.put(getString(R.string.dbstring_PlaceMapName), StartPointMapName);
                    content.put(getString(R.string.dbstring_longitude), startplace_longitude);
                    content.put(getString(R.string.dbstring_latitude), startplace_latitude);
                    db1.insert(getString(R.string.dbtable_placeliked), null, content);

                    // Define 'where' part of query.
                    String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?";
                    // Specify arguments in placeholder order.
                    String[] selelectionArgs = { StartPointMapName };
                    // Issue SQL statement.
                    db1.delete(getString(R.string.dbtable_placehistory), selection, selelectionArgs);
                    star1.setImageResource(R.drawable.ic_action_important);
                }

            }

        }
    });

    star2.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {

            if (bend) {
                if (Pointisliked(EndPointMapName)) {
                    // Define 'where' part of query.
                    String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?";
                    // Specify arguments in placeholder order.
                    String[] selelectionArgs = { EndPointMapName };
                    // Issue SQL statement.
                    db1.delete(getString(R.string.dbtable_placeliked), selection, selelectionArgs);
                    star2.setImageResource(R.drawable.ic_action_not_important);

                } else {
                    ContentValues content = new ContentValues();
                    content.put(getString(R.string.dbstring_PlaceUserName), EndPointUserName);
                    content.put(getString(R.string.dbstring_PlaceMapName), EndPointMapName);
                    content.put(getString(R.string.dbstring_longitude), destination_longitude);
                    content.put(getString(R.string.dbstring_latitude), destination_latitude);
                    db1.insert(getString(R.string.dbtable_placeliked), null, content);

                    // Define 'where' part of query.
                    String selection = getString(R.string.dbstring_PlaceMapName) + " LIKE ?";
                    // Specify arguments in placeholder order.
                    String[] selelectionArgs = { EndPointMapName };
                    // Issue SQL statement.
                    db1.delete(getString(R.string.dbtable_placehistory), selection, selelectionArgs);
                    star2.setImageResource(R.drawable.ic_action_important);
                }

            }

        }
    });

    taxi.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
        }
    });

    personalcenter.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent personalcenter = new Intent(CommuteActivity.this, PersonalCenterActivity.class);
            startActivity(personalcenter);
        }
    });

    shortway.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent shortway = new Intent(CommuteActivity.this, ShortWayActivity.class);
            shortway.putExtra("pre_page", "Drawer");
            startActivity(shortway);
        }
    });

    longway.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));
            Intent longway = new Intent(CommuteActivity.this, MainActivity.class);
            startActivity(longway);
        }
    });

    commute.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer));

        }
    });

    mon.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                bmon = true;
            } else {
                bmon = false;
            }
            confirm();
        }
    });
    tue.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                btue = true;
            } else {
                btue = false;
            }
            confirm();
        }
    });
    wed.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                bwed = true;
            } else {
                bwed = false;
            }
            confirm();
        }
    });
    thu.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                bthu = true;
            } else {
                bthu = false;
            }
            confirm();
        }
    });
    fri.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                bfri = true;
            } else {
                bfri = false;
            }
            confirm();
        }
    });
    sat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                bsat = true;
            } else {
                bsat = false;
            }
            confirm();
        }
    });
    sun.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            // TODO Auto-generated method stub
            if (isChecked) {
                bsun = true;
            } else {
                bsun = false;
            }
            confirm();
        }
    });

    commute_group.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup arg0, int checkedId) {
            // TODO Auto-generated method stub18
            // ID

            // """"textView
            if (checkedId == mRadio2.getId()) {

                bpassenager = true;
                bdriver = false;

                licensenum.setEnabled(false);
                carbrand.setEnabled(false);
                color.setEnabled(false);
                model.setEnabled(false);

                licensenum.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                carbrand.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                color.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                model.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
                    }
                } });
                content.setText(getString(R.string.warningInfo_seatNeed));
                licensenum.setHintTextColor(getResources().getColor(R.color.gray_cccccc));
                carbrand.setHintTextColor(getResources().getColor(R.color.gray_cccccc));
                color.setHintTextColor(getResources().getColor(R.color.gray_cccccc));
                model.setHintTextColor(getResources().getColor(R.color.gray_cccccc));
                licensenum.setInputType(InputType.TYPE_NULL);
                carbrand.setInputType(InputType.TYPE_NULL);
                color.setInputType(InputType.TYPE_NULL);
                model.setInputType(InputType.TYPE_NULL);
            } else {

                bpassenager = false;
                bdriver = true;

                licensenum.setEnabled(true);
                carbrand.setEnabled(true);
                color.setEnabled(true);
                model.setEnabled(true);

                licensenum.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {

                        return null;
                    }
                } });
                carbrand.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {
                        return null;
                    }
                } });
                color.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {

                        return null;
                    }
                } });
                model.setFilters(new InputFilter[] { new InputFilter() {
                    @Override
                    public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
                            int dstart, int dend) {

                        return null;
                    }
                } });
                content.setText(getString(R.string.warningInfo_seatOffer));
                licensenum.setHintTextColor(getResources().getColor(R.color.purple_9F35FF));
                carbrand.setHintTextColor(getResources().getColor(R.color.purple_9F35FF));
                color.setHintTextColor(getResources().getColor(R.color.purple_9F35FF));
                model.setHintTextColor(getResources().getColor(R.color.purple_9F35FF));
                // licensenum.setText("");
                // carbrand.setText("");
                // color.setText("");
                // model.setText("");
                licensenum.setInputType(InputType.TYPE_CLASS_TEXT);
                carbrand.setInputType(InputType.TYPE_CLASS_TEXT);
                color.setInputType(InputType.TYPE_CLASS_TEXT);
                model.setInputType(InputType.TYPE_CLASS_TEXT);

                // start!
                selectcarinfo(UserPhoneNumber);
                // end!
            }
            confirm();
        }

        private void selectcarinfo(final String phonenum) {
            // TODO Auto-generated method stub
            String carinfo_selectrequest_baseurl = getString(R.string.uri_base)
                    + getString(R.string.uri_CarInfo) + getString(R.string.uri_selectcarinfo_action);

            Log.d("carinfo_selectrequest_baseurl", carinfo_selectrequest_baseurl);
            StringRequest stringRequest = new StringRequest(Request.Method.POST, carinfo_selectrequest_baseurl,
                    new Response.Listener<String>() {

                        @Override
                        public void onResponse(String response) {
                            // TODO Auto-generated method stub
                            Log.d("carinfo_select", response);
                            String jas_id = null;
                            JSONObject json1 = null;
                            try {
                                json1 = new JSONObject(response);
                                JSONObject json = json1.getJSONObject("result");
                                jas_id = json.getString("id");

                                if (jas_id.compareTo("") != 0) { // 

                                    carinfochoosing_type = 2;
                                    carbrand.setText(json.getString("carBrand"));
                                    model.setText(json.getString("carModel"));
                                    licensenum.setText(json.getString("carNum"));
                                    color.setText(json.getString("carColor"));

                                } else {
                                    carinfochoosing_type = 1;
                                }
                            } catch (JSONException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                        }
                    }, new Response.ErrorListener() {

                        @Override
                        public void onErrorResponse(VolleyError error) {
                            // TODO Auto-generated method stub
                            Log.e("carinfo_selectresult_result", error.getMessage(), error);
                        }
                    }) {
                protected Map<String, String> getParams() {
                    Map<String, String> params = new HashMap<String, String>();
                    params.put("phonenum", phonenum);
                    return params;
                }
            };

            queue.add(stringRequest);
        }

    });

    sure.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub

            if (commute_group.getCheckedRadioButtonId() == mRadio1.getId()) {
                supplycar = "y";
            } else
                supplycar = "n";

            // start!
            Context phonenumber = CommuteActivity.this;
            SharedPreferences filename = phonenumber
                    .getSharedPreferences(getString(R.string.PreferenceDefaultName), Context.MODE_PRIVATE);
            username = filename.getString("refreshfilename", "0");
            commute_request(username, startdate.getText().toString(), enddate.getText().toString(),
                    earlystarttime.getText().toString(), latestarttime.getText().toString());
            // end!

        }

        private void commute_request(final String commute_phonenum, final String commute_startdate,
                final String commute_enddate, final String commute_starttime, final String commute_endtime) {
            // TODO Auto-generated method stub

            weekrepeat = "";
            if (bmon)
                weekrepeat += "1";
            if (btue)
                weekrepeat += "2";
            if (bwed)
                weekrepeat += "3";
            if (bthu)
                weekrepeat += "4";
            if (bfri)
                weekrepeat += "5";
            if (bsat)
                weekrepeat += "6";
            if (bsun)
                weekrepeat += "7";

            // start
            try {
                test_date = primary_date.parse(commute_startdate);
                standard_commute_startdate = standard_date.format(test_date);
                test_date = primary_date.parse(commute_enddate);
                standard_commute_enddate = standard_date.format(test_date);
                test_date = primary_time.parse(commute_starttime);
                standard_commute_starttime = standard_time.format(test_date);
                test_date = primary_time.parse(commute_endtime);
                standard_commute_endtime = standard_time.format(test_date);
            } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

            // end!

            String commute_baseurl = getString(R.string.uri_base) + getString(R.string.uri_CommuteRequest)
                    + getString(R.string.uri_addrequest_action);
            // + "phonenum=" + commute_phonenum + "&startplacex=" +
            // String.valueOf(startplace_longitude) +
            // "&startplacey=" + String.valueOf(startplace_latitude) +
            // "&destinationx=" + String.valueOf(destination_longitude) +
            // "&destinationy=" + String.valueOf(destination_latitude) +
            // "&startdate=" + standard_commute_startdate
            // + "&enddate=" + standard_commute_enddate
            // + "&starttime=" + standard_commute_starttime
            // + "&endtime=" + standard_commute_endtime + "&weekrepeat=" +
            // weekrepeat + "&supplycar=" + supplycar;

            Log.e("commute_URL", commute_baseurl);
            // Instantiate the RequestQueue.
            // Request a string response from the provided URL.
            StringRequest stringRequest = new StringRequest(Request.Method.POST, commute_baseurl,
                    new Response.Listener<String>() {

                        @Override
                        public void onResponse(String response) {
                            Log.d("commute_result", response);
                            JSONObject json1 = null;
                            try {
                                json1 = new JSONObject(response);
                                requestok = json1.getBoolean("result");
                            } catch (JSONException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }

                            if (requestok == true) {

                                if (carinfochoosing_type == 1) {
                                    // add
                                    // start!
                                    carinfo(commute_phonenum, licensenum.getText().toString(),
                                            carbrand.getText().toString(), model.getText().toString(),
                                            color.getText().toString(), String.valueOf(sum), 1);
                                    // end!
                                } else {
                                    // update
                                    // start!
                                    carinfo(commute_phonenum, licensenum.getText().toString(),
                                            carbrand.getText().toString(), model.getText().toString(),
                                            color.getText().toString(), String.valueOf(sum), 2);
                                    // end!
                                }

                                Intent sure = new Intent(CommuteActivity.this, OrderResponseActivity.class);
                                sure.putExtra(getString(R.string.request_response), "true");
                                sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                                startActivity(sure);
                            } else {
                                // Toast errorinfo =
                                // Toast.makeText(getApplicationContext(),
                                // "", Toast.LENGTH_LONG);
                                // errorinfo.show();
                                Intent sure = new Intent(CommuteActivity.this, OrderResponseActivity.class);
                                sure.putExtra(getString(R.string.request_response), "false");
                                sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                                startActivity(sure);
                            }
                        }
                    }, new Response.ErrorListener() {
                        @Override
                        public void onErrorResponse(VolleyError error) {
                            Log.e("commute_result", error.getMessage(), error);
                            commute_result = null;
                            // Toast errorinfo = Toast.makeText(null,
                            // "", Toast.LENGTH_LONG);
                            // errorinfo.show();
                            Intent sure = new Intent(CommuteActivity.this, OrderResponseActivity.class);
                            sure.putExtra(getString(R.string.request_response), "false");
                            sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                            startActivity(sure);
                        }
                    }) {
                protected Map<String, String> getParams() {
                    // POSTgetParams

                    // start
                    try {
                        test_date = primary_date.parse(commute_startdate);
                        standard_commute_startdate = standard_date.format(test_date);
                        test_date = primary_date.parse(commute_enddate);
                        standard_commute_enddate = standard_date.format(test_date);
                        test_date = primary_time.parse(commute_starttime);
                        standard_commute_starttime = standard_time.format(test_date);
                        test_date = primary_time.parse(commute_endtime);
                        standard_commute_endtime = standard_time.format(test_date);
                    } catch (ParseException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }

                    // end!

                    Map<String, String> params = new HashMap<String, String>();
                    params.put(getString(R.string.uri_phonenum), commute_phonenum);
                    params.put(getString(R.string.uri_startplacex), String.valueOf(startplace_longitude));
                    params.put(getString(R.string.uri_startplacey), String.valueOf(startplace_latitude));
                    params.put(getString(R.string.uri_startplace), startplace.getText().toString());
                    params.put(getString(R.string.uri_destinationx), String.valueOf(destination_longitude));
                    params.put(getString(R.string.uri_destinationy), String.valueOf(destination_latitude));
                    params.put(getString(R.string.uri_destination), endplace.getText().toString());
                    params.put(getString(R.string.uri_startdate), standard_commute_startdate);
                    params.put(getString(R.string.uri_enddate), standard_commute_enddate);
                    params.put(getString(R.string.uri_starttime), standard_commute_starttime);
                    params.put(getString(R.string.uri_endtime), standard_commute_endtime);
                    params.put(getString(R.string.uri_weekrepeat), weekrepeat);
                    params.put(getString(R.string.uri_supplycar), supplycar);
                    // Log.w("phonemum", commute_phonenum);
                    // Log.w("startplacex",
                    // String.valueOf(startplace_longitude));
                    // Log.w("startdate", standard_commute_startdate);
                    // Log.w("starttime", standard_commute_starttime);
                    // Log.w("weekrepeat",weekrepeat );
                    // Log.w("supplycar",supplycar );
                    // Log.w("enddate",standard_commute_enddate );

                    return params;
                }
            };

            queue.add(stringRequest);

        }
    });

    startplace.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            startActivityForResult(new Intent(CommuteActivity.this, ChooseAddressActivity.class), 1);
        }
    });

    endplace.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            startActivityForResult(new Intent(CommuteActivity.this, ChooseArrivalActivity.class), 2);
        }
    });

    increase.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            sum++;
            s1.setText("" + sum);
            confirm();
        }
    });

    decrease.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            sum--;
            if (sum < 0) {
                sum = 0;
            }
            s1.setText("" + sum);
            confirm();
        }
    });

    startdate.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            showDialog(DATE_DIALOG);
        }

    });

    enddate.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            showDialog(DATE_DIALOG01);

        }
    });

    earlystarttime.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            showDialog(TIME_DIALOG);
        }
    });

    latestarttime.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            showDialog(TIME_DIALOG01);

        }
    });
}