Package org.teiid.core.id

Examples of org.teiid.core.id.UUID$Variant


  public void gotoFrame(String timeline, int frameNum) {
    if (!created)
      return;

    Variant[] args = new Variant[2];
    args[0] = new Variant(timeline);
    args[1] = new Variant(frameNum);

    flashObject.invokeNoReply(DISPID_TGOTOFRAME, args);
  }
View Full Code Here


    protected Variant invoke(int dispId, int flags, Variant[] params)
        throws HResultException, InvocationTargetException {

      if (dispId == 0 && (flags & COM.DISPATCH_PROPERTYGET) != 0) {
        // MAGIC: this is the default property, let's just do toString()
        return new Variant(toString());
      } else if (dispId == 1) {
        if ((flags & COM.DISPATCH_METHOD) != 0) {
          try {
            if (params.length < 3) {
              reportIncorrectInvocation("gwtOnLoad", 3, params.length);
              throw new HResultException(COM.E_INVALIDARG);
            }
            IDispatch frameWnd = (params[0].getType() == COM.VT_DISPATCH)
                ? params[0].getDispatch() : null;
            String moduleName = (params[1].getType() == COM.VT_BSTR)
                ? params[1].getString() : null;
            String version = (params[2].getType() == COM.VT_BSTR)
                ? params[2].getString() : null;
            boolean success = gwtOnLoad(frameWnd, moduleName, version);

            // boolean return type
            return new Variant(success);
          } catch (SWTException e) {
            throw new HResultException(COM.E_INVALIDARG);
          }
        } else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
          // property get on the method itself
          try {
            Method gwtOnLoadMethod = getClass().getMethod("gwtOnLoad",
                new Class[] {IDispatch.class, String.class, String.class});
            MethodAdaptor methodAdaptor = new MethodAdaptor(gwtOnLoadMethod);
            IDispatchImpl funcObj = new MethodDispatch(null, methodAdaptor);
            IDispatch disp = new IDispatch(funcObj.getAddress());
            disp.AddRef();
            return new Variant(disp);
          } catch (Exception e) {
            // just return VT_EMPTY
            return new Variant();
          }
        }
        throw new HResultException(COM.E_NOTSUPPORTED);
      } else if (dispId == 2) {
        if ((flags & COM.DISPATCH_METHOD) != 0) {
          try {
            if (params.length < 1) {
              reportIncorrectInvocation("initModule", 1, params.length);
              throw new HResultException(COM.E_INVALIDARG);
            }
            String moduleName = (params[0].getType() == COM.VT_BSTR)
                ? params[0].getString() : null;
            boolean reload = initModule(moduleName);

            // boolean return type
            return new Variant(reload);
          } catch (SWTException e) {
            throw new HResultException(COM.E_INVALIDARG);
          }
        } else if ((flags & COM.DISPATCH_PROPERTYGET) != 0) {
          // property get on the method itself
          try {
            Method gwtOnLoadMethod = getClass().getMethod("initModule",
                new Class[] {String.class});
            MethodAdaptor methodAdaptor = new MethodAdaptor(gwtOnLoadMethod);
            IDispatchImpl funcObj = new MethodDispatch(null, methodAdaptor);
            IDispatch disp = new IDispatch(funcObj.getAddress());
            disp.AddRef();
            return new Variant(disp);
          } catch (Exception e) {
            // just return VT_EMPTY
            return new Variant();
          }
        }
        throw new HResultException(COM.E_NOTSUPPORTED);
      }
View Full Code Here

   * @return the return value of the JavaScript function
   */
  protected static Variant doInvokeOnWindow(OleAutomation window, String name,
      Variant[] vArgs) {
    OleAutomation funcObj = null;
    Variant funcObjVar = null;
    try {

      // Get the function object and its 'call' method.
      //
      int[] ids = window.getIDsOfNames(new String[] {name});
      if (ids == null) {
        throw new RuntimeException(
            "Could not find a native method with the signature '" + name + "'");
      }
      int functionId = ids[0];
      funcObjVar = window.getProperty(functionId);
      funcObj = funcObjVar.getAutomation();
      int callDispId = funcObj.getIDsOfNames(new String[] {"call"})[0];

      // Invoke it and return the result.
      //
      return funcObj.invoke(callDispId, vArgs);

    } finally {
      if (funcObjVar != null) {
        funcObjVar.dispose();
      }

      if (funcObj != null) {
        funcObj.dispose();
      }
View Full Code Here

    // a new top-level function.
    //
    String newScript = createNativeMethodInjector(jsniSignature, paramNames, js);
    try {
      // TODO: somehow insert file/line info into the script
      Variant result = execute(newScript);
      if (result != null) {
        result.dispose();
      }
    } catch (RuntimeException e) {
      throw new RuntimeException(file + "(" + line
          + "): Failed to create JSNI method with signature '" + jsniSignature
          + "'", e);
View Full Code Here

      for (int i = 0; i < len; ++i) {
        vArgs[i + 1] = SwtOleGlue.convertObjectToVariant(isolatedClassLoader,
            types[i], args[i]);
      }

      Variant result = doInvokeOnWindow(window, name, vArgs);
      try {
        return new JsValueIE6(result);
      } finally {
        if (result != null) {
          result.dispose();
        }
      }
    } finally {
      // We allocated variants for all arguments, so we must dispose them all.
      //
View Full Code Here

  }

  private Variant execute(String code) {
    int[] dispIds = window.getIDsOfNames(new String[] {"execScript", "code"});
    Variant[] vArgs = new Variant[1];
    vArgs[0] = new Variant(code);
    int[] namedArgs = new int[1];
    namedArgs[0] = dispIds[1];
    Variant result = window.invoke(dispIds[0], vArgs, namedArgs);
    vArgs[0].dispose();
    if (result == null) {
      String lastError = window.getLastError();
      throw new RuntimeException("Error (" + lastError
          + ") executing JavaScript:\n" + code);
View Full Code Here

    /**
     * Test UUID generation for IDs generated from powers of 2.
     */
    private static void helpTestGenPowers( int nGen ) {
        UUID uuid = null;

        // First test some fairly "regular" numbers...
        for ( int j = 0; j < Math.min(nGen,63); j++ ) {
            long v1 = 1L << j;
            long v2 = (1L << j)/2;
            uuid = new UUID(v1,v2);
            checkStringToObject(uuid)// Test case may fail here
        }
    }
View Full Code Here

   
    /**
     * Test UUID generation for IDs generated randomly.
     */
    private static void helpTestGenRandom( int nGen ) {
        UUID uuid = null;

        // Then test some random numbers...
        java.util.Random rng = new java.util.Random();
        for ( int k = 0; k < nGen; k++ ) {
            long v1 = rng.nextLong();
            long v2 = rng.nextLong();
            uuid = new UUID(v1,v2);
            checkStringToObject(uuid)// Test case may fail here
        }
    }
View Full Code Here

   
    /**
     * Test for duplicates when generating a bunch of IDs.
     */
    private static void helpTestDuplicates( int nGen ) {
        UUID uuid = null;
        Set uuids = new HashSet();
//        Set duplicates = new HashSet();

        // First test some fairly "regular" numbers...
        for ( int j = 0; j < Math.min(nGen,63); j++ ) {
            long v1 = 1L << j;
            long v2 = (1L << j)/2;
            uuid = new UUID(v1,v2);
            assertTrue( "UUID '" + uuid + "' is a duplicate!", !uuids.contains(uuid) ); //$NON-NLS-1$ //$NON-NLS-2$
            uuids.add(uuid);
        }

        // Then test some random numbers...
        java.util.Random rng = new java.util.Random();
        for ( int k = 0; k < nGen; k++ ) {
            long v1 = rng.nextLong();
            long v2 = rng.nextLong();
            uuid = new UUID(v1,v2);
            if ( uuids.contains(uuid) ) {
                fail( "UUID '" + uuid + "' is a duplicate!" ); //$NON-NLS-1$ //$NON-NLS-2$
            }
            uuids.add(uuid);
        }
View Full Code Here

     * @param id1 The ID to test
     */
    public static void checkStringToObject( UUID id1 ) {
        String uuidString = id1.exportableForm();

        UUID id2 = null;
        try {
            id2 = (UUID)UUID.stringToObject( uuidString );
        } catch ( InvalidIDException e ) {
            fail( "Could not convert UUID exportable form '" + uuidString + "' to UUID: " //$NON-NLS-1$ //$NON-NLS-2$
                + e.getMessage() );
View Full Code Here

TOP

Related Classes of org.teiid.core.id.UUID$Variant

Copyright © 2018 www.massapicom. 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.