Exemple #1
0
        /**
         * Returns an {@code Enumeration} that contains all of the loaded JDBC
         * drivers that the current caller can access.
         *
         * @return An {@code Enumeration} containing all the currently loaded JDBC
         *         {@code Drivers}.
         */
        public static java.util.Enumeration <Driver> getDrivers()
        {
            java.lang.ClassLoader callerClassLoader = java.lang.Runtime.getRuntime().getClass().getClassLoader();// Basties note: sometime do the same as VM.callerClassLoader();

            /*
             * Synchronize to avoid clashes with additions and removals of drivers
             * in the DriverSet
             */
            lock (theDrivers)
            {
                /*
                 * Create the Enumeration by building a Vector from the elements of
                 * the DriverSet
                 */
                java.util.Vector <Driver>   theVector   = new java.util.Vector <Driver>();
                java.util.Iterator <Driver> theIterator = theDrivers.iterator();
                while (theIterator.hasNext())
                {
                    Driver theDriver = theIterator.next();
                    if (DriverManager.isClassFromClassLoader(theDriver,
                                                             callerClassLoader))
                    {
                        theVector.add(theDriver);
                    }
                }
                return(theVector.elements());
            }
        }
Exemple #2
0
        public void Test_ForEach_Vector()
        {
            java.lang.SystemJ.outJ.println("Vector foreach test");


            java.util.Vector <String> testArray = new java.util.Vector <String>();
            testArray.add("VampireAPI");
            testArray.add("supports");
            testArray.add("foreach statements");
            testArray.add("! Yeah!!!");

            // for count loop
            java.lang.SystemJ.outJ.println("for count loop: ");
            for (int i = 0; i < testArray.size(); i++)
            {
                java.lang.SystemJ.outJ.print(testArray.get(i));
                java.lang.SystemJ.outJ.print(" ");
            }
            java.lang.SystemJ.outJ.println();

            // for iterator loop
            java.lang.SystemJ.outJ.println("for iterator loop: ");
            for (java.util.Iterator <String> it = testArray.iterator(); it.hasNext();)
            {
                java.lang.SystemJ.outJ.print(it.next());
                java.lang.SystemJ.outJ.print(" ");
            }
            java.lang.SystemJ.outJ.println();

            // foreach loop
            java.lang.SystemJ.outJ.println("foreach loop: ");
            foreach (String text in testArray)
            {
                java.lang.SystemJ.outJ.print(text);
                java.lang.SystemJ.outJ.print(" ");
            }
            java.lang.SystemJ.outJ.println();


            Assert.True(true, "compiler OK");
        }
Exemple #3
0
        /*
         * Writes entry information to the underlying stream. Data associated with
         * the entry can then be written using {@code write()}. After data is
         * written {@code closeEntry()} must be called to complete the writing of
         * the entry to the underlying stream.
         *
         * @param ze
         *            the {@code ZipEntry} to store.
         * @throws IOException
         *             If an error occurs storing the entry.
         * @see #write
         */
        public void putNextEntry(ZipEntry ze)  //throws java.io.IOException {
        {
            if (currentEntry != null)
            {
                closeEntry();
            }
            if (ze.getMethod() == STORED ||
                (compressMethod == STORED && ze.getMethod() == -1))
            {
                if (ze.crc == -1)
                {
                    /* [MSG "archive.20", "Crc mismatch"] */
                    throw new ZipException("Crc mismatch"); //$NON-NLS-1$
                }
                if (ze.size == -1 && ze.compressedSize == -1)
                {
                    /* [MSG "archive.21", "Size mismatch"] */
                    throw new ZipException("Size mismatch"); //$NON-NLS-1$
                }
                if (ze.size != ze.compressedSize && ze.compressedSize != -1 &&
                    ze.size != -1)
                {
                    /* [MSG "archive.21", "Size mismatch"] */
                    throw new ZipException("Size mismatch"); //$NON-NLS-1$
                }
            }
            /* [MSG "archive.1E", "Stream is closed"] */
            if (cDir == null)
            {
                throw new java.io.IOException("Stream is closed"); //$NON-NLS-1$
            }
            if (entries.contains(ze.name))
            {
                /* [MSG "archive.29", "Entry already exists: {0}"] */
                throw new ZipException("Entry already exists: " + ze.name); //$NON-NLS-1$
            }
            nameLength = utf8Count(ze.name);
            if (nameLength > 0xffff)
            {
                /* [MSG "archive.2A", "Name too long: {0}"] */
                throw new java.lang.IllegalArgumentException("Name too long: " + ze.name); //$NON-NLS-1$
            }

            def.setLevel(compressLevel);
            currentEntry = ze;
            entries.add(currentEntry.name);
            if (currentEntry.getMethod() == -1)
            {
                currentEntry.setMethod(compressMethod);
            }
            writeLong(outJ, ZipFile.LOCSIG);               // Entry header
            writeShort(outJ, ZIPLocalHeaderVersionNeeded); // Extraction version
            writeShort(outJ, currentEntry.getMethod() == STORED ? 0
                    : ZIPDataDescriptorFlag);
            writeShort(outJ, currentEntry.getMethod());
            if (currentEntry.getTime() == -1)
            {
                currentEntry.setTime(java.lang.SystemJ.currentTimeMillis());
            }
            writeShort(outJ, currentEntry.time);
            writeShort(outJ, currentEntry.modDate);

            if (currentEntry.getMethod() == STORED)
            {
                if (currentEntry.size == -1)
                {
                    currentEntry.size = currentEntry.compressedSize;
                }
                else if (currentEntry.compressedSize == -1)
                {
                    currentEntry.compressedSize = currentEntry.size;
                }
                writeLong(outJ, currentEntry.crc);
                writeLong(outJ, currentEntry.size);
                writeLong(outJ, currentEntry.size);
            }
            else
            {
                writeLong(outJ, 0);
                writeLong(outJ, 0);
                writeLong(outJ, 0);
            }
            writeShort(outJ, nameLength);
            if (currentEntry.extra != null)
            {
                writeShort(outJ, currentEntry.extra.Length);
            }
            else
            {
                writeShort(outJ, 0);
            }
            nameBytes = toUTF8Bytes(currentEntry.name, nameLength);
            outJ.write(nameBytes);
            if (currentEntry.extra != null)
            {
                outJ.write(currentEntry.extra);
            }
        }
Exemple #4
0
 /**
  * Returns an {@code Enumeration} that contains all of the loaded JDBC
  * drivers that the current caller can access.
  *
  * @return An {@code Enumeration} containing all the currently loaded JDBC
  *         {@code Drivers}.
  */
 public static java.util.Enumeration<Driver> getDrivers()
 {
     java.lang.ClassLoader callerClassLoader = java.lang.Runtime.getRuntime().getClass().getClassLoader();// Basties note: sometime do the same as VM.callerClassLoader();
     /*
      * Synchronize to avoid clashes with additions and removals of drivers
      * in the DriverSet
      */
     lock (theDrivers)
     {
         /*
          * Create the Enumeration by building a Vector from the elements of
          * the DriverSet
          */
         java.util.Vector<Driver> theVector = new java.util.Vector<Driver>();
         java.util.Iterator<Driver> theIterator = theDrivers.iterator();
         while (theIterator.hasNext())
         {
             Driver theDriver = theIterator.next();
             if (DriverManager.isClassFromClassLoader(theDriver,
                     callerClassLoader))
             {
                 theVector.add(theDriver);
             }
         }
         return theVector.elements();
     }
 }