Package com.zaranux.client.app

Source Code of com.zaranux.client.app.Program

package com.zaranux.client.app;

import com.google.gwt.core.client.GWT;
import com.google.gwt.http.client.URL;
import com.google.gwt.user.client.Window;
import com.openmashupos.core.client.OMOS;
import com.zaranux.client.api.SystemCallAPI;

import com.zaranux.client.app.core.SystemCallImpl;
import com.zaranux.client.java.io.ZaranuxFileSystem;

public abstract class Program extends OMOS {

  @Override
  public void onOMOSLoad() {
    systemcall = new SystemCallImpl();
    ZaranuxFileSystem.setSystemcallImpl(systemcall);
    main(getArgs());
  }
 
  protected SystemCallAPI systemcall;
 
  protected abstract void main(String[] args);
 
  protected void finalize()
  {
  }
 
  private String[] getArgs() {
    int baseLen = GWT.getHostPageBaseURL().length();
    // params = "?X&Y&...#..."
    String params = Window.Location.getHref().substring(baseLen);
    String[] args = null;

    int paramStartIndex = params.indexOf('?');

    if(paramStartIndex>=0)
    {
      params = params.substring(paramStartIndex+1);
   
      int hashStartIndex = params.indexOf('#');
      if(hashStartIndex>=0)
        params = params.substring(0, hashStartIndex);
     
 
      if(params!=null)
      {
        args = params.split("&");
        if(args!=null)
        {
          for(int i =0; i< args.length ; i++)
          {
            args[i] = URL.decodeComponent(args[i]);
          }
        }
      }
    }
    if(args == null) args = new String[0];
   
    return args;
  };
 
}
TOP

Related Classes of com.zaranux.client.app.Program

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.