Search in sources :

Example 86 with ListIterator

use of java.util.ListIterator in project OpenAM by OpenRock.

the class SetupUtils method copyAndFilterScripts.

/**
     * Copy and replace the variables in the scripts.
     *
     * @param bundle The ResourceBundle which contains the prompt messages.
     * @param lookupProp The properties which contains the variables map, file
     *        patterns, source directory, and destinated directory.
     */
public static void copyAndFilterScripts(ResourceBundle bundle, Properties lookupProp) throws IOException {
    String currentOS = determineOS();
    String fromFilePattern = lookupProp.getProperty(currentOS + FROM_FILE);
    String toFilePattern = lookupProp.getProperty(currentOS + TO_FILE);
    String tempFromDir = lookupProp.getProperty(currentOS + FROM_DIR);
    String tempToDir = lookupProp.getProperty(currentOS + TO_DIR);
    File fromDir = new File(tempFromDir);
    File toDir = new File(tempToDir);
    if (toDir.isAbsolute()) {
        toDir = new File(toDir.getName());
    }
    Properties tokens = SetupUtils.getTokens(bundle, lookupProp);
    LinkedList fromFilesList = new LinkedList();
    LinkedList toFilesList = new LinkedList();
    SetupUtils.getFiles(fromDir, toDir, fromFilePattern, toFilePattern, fromFilesList, toFilesList);
    ListIterator srcIter = fromFilesList.listIterator();
    ListIterator destIter = toFilesList.listIterator();
    while ((srcIter.hasNext()) && (destIter.hasNext())) {
        File srcFile = (File) srcIter.next();
        File destFile = (File) destIter.next();
        CopyUtils.copyFile(srcFile, destFile, tokens, true, false);
    }
    if (!currentOS.equals(WINDOWS)) {
        Process proc = Runtime.getRuntime().exec("/bin/chmod -R +x " + toDir.getName());
        try {
            if (proc.waitFor() != 0) {
                System.out.println(bundle.getString("message.info." + "permission.scripts"));
            }
        } catch (InterruptedException ex) {
            System.out.println(bundle.getString("message.info." + "permission.scripts"));
        //ex.printStackTrace();
        }
    }
    System.out.println(bundle.getString("message.info.success") + " " + (new File(".")).getCanonicalPath() + FILE_SEPARATOR + toDir.getName());
}
Also used : Properties(java.util.Properties) ListIterator(java.util.ListIterator) File(java.io.File) LinkedList(java.util.LinkedList)

Example 87 with ListIterator

use of java.util.ListIterator in project hibernate-orm by hibernate.

the class EventManager method createHolidayCalendar.

public Long createHolidayCalendar() {
    Session session = sessionFactory.getCurrentSession();
    session.beginTransaction();
    // delete all existing calendars
    List calendars = session.createQuery("from HolidayCalendar").setCacheable(true).list();
    for (ListIterator li = calendars.listIterator(); li.hasNext(); ) {
        session.delete(li.next());
    }
    HolidayCalendar calendar = new HolidayCalendar();
    calendar.init();
    Long calendarId = (Long) session.save(calendar);
    session.getTransaction().commit();
    return calendarId;
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) ListIterator(java.util.ListIterator) Session(org.hibernate.Session)

Example 88 with ListIterator

use of java.util.ListIterator in project NetherEx by LogicTechCorp.

the class EventHandler method onLivingDrops.

@SubscribeEvent
public static void onLivingDrops(LivingDropsEvent event) {
    Random rand = new Random();
    BlockPos deathPoint = event.getEntity().getPosition();
    if (event.getEntity() instanceof EntityGhast) {
        event.getDrops().add(new EntityItem(event.getEntity().getEntityWorld(), deathPoint.getX(), deathPoint.getY(), deathPoint.getZ(), new ItemStack(NetherExItems.FOOD_MEAT_GHAST_RAW, rand.nextInt(3) + 1, 0)));
    } else if (event.getEntity() instanceof EntityWitherSkeleton) {
        ListIterator<EntityItem> iter = event.getDrops().listIterator();
        while (iter.hasNext()) {
            EntityItem entityItem = iter.next();
            ItemStack stack = entityItem.getEntityItem();
            if (stack.getItem() == Items.BONE || stack.getItem() == Items.COAL) {
                iter.remove();
            }
        }
        event.getDrops().add(new EntityItem(event.getEntity().world, deathPoint.getX(), deathPoint.getY(), deathPoint.getZ(), new ItemStack(NetherExItems.ITEM_BONE_WITHER, rand.nextInt(3), 0)));
    }
}
Also used : Random(java.util.Random) EntityGhast(net.minecraft.entity.monster.EntityGhast) BlockPos(net.minecraft.util.math.BlockPos) EntityWitherSkeleton(net.minecraft.entity.monster.EntityWitherSkeleton) ItemStack(net.minecraft.item.ItemStack) ListIterator(java.util.ListIterator) EntityItem(net.minecraft.entity.item.EntityItem) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 89 with ListIterator

use of java.util.ListIterator in project robovm by robovm.

the class LinkedListTest method test_listIteratorI.

/**
     * java.util.LinkedList#listIterator(int)
     */
public void test_listIteratorI() {
    // Test for method java.util.ListIterator
    // java.util.LinkedList.listIterator(int)
    ListIterator i1 = ll.listIterator();
    ListIterator i2 = ll.listIterator(0);
    Object elm;
    int n = 0;
    while (i2.hasNext()) {
        if (n == 0 || n == objArray.length - 1) {
            if (n == 0)
                assertTrue("First element claimed to have a previous", !i2.hasPrevious());
            if (n == objArray.length)
                assertTrue("Last element claimed to have next", !i2.hasNext());
        }
        elm = i2.next();
        assertTrue("Iterator returned elements in wrong order", elm == objArray[n]);
        if (n > 0 && n < objArray.length - 1) {
            assertTrue("Next index returned incorrect value", i2.nextIndex() == n + 1);
            assertTrue("previousIndex returned incorrect value : " + i2.previousIndex() + ", n val: " + n, i2.previousIndex() == n);
        }
        elm = i1.next();
        assertTrue("Iterator returned elements in wrong order", elm == objArray[n]);
        ++n;
    }
    i2 = ll.listIterator(ll.size() / 2);
    assertTrue((Integer) i2.next() == ll.size() / 2);
    List myList = new LinkedList();
    myList.add(null);
    myList.add("Blah");
    myList.add(null);
    myList.add("Booga");
    myList.add(null);
    ListIterator li = myList.listIterator();
    assertTrue("li.hasPrevious() should be false", !li.hasPrevious());
    assertNull("li.next() should be null", li.next());
    assertTrue("li.hasPrevious() should be true", li.hasPrevious());
    assertNull("li.prev() should be null", li.previous());
    assertNull("li.next() should be null", li.next());
    assertEquals("li.next() should be Blah", "Blah", li.next());
    assertNull("li.next() should be null", li.next());
    assertEquals("li.next() should be Booga", "Booga", li.next());
    assertTrue("li.hasNext() should be true", li.hasNext());
    assertNull("li.next() should be null", li.next());
    assertTrue("li.hasNext() should be false", !li.hasNext());
    try {
        ll.listIterator(-1);
        fail("IndexOutOfBoundsException expected");
    } catch (IndexOutOfBoundsException e) {
    //expected
    }
    try {
        ll.listIterator(ll.size() + 1);
        fail("IndexOutOfBoundsException expected");
    } catch (IndexOutOfBoundsException e) {
    //expected
    }
}
Also used : List(java.util.List) LinkedList(java.util.LinkedList) ArrayList(java.util.ArrayList) ListIterator(java.util.ListIterator) LinkedList(java.util.LinkedList)

Example 90 with ListIterator

use of java.util.ListIterator in project robovm by robovm.

the class PKIXCertPath method getEncoded.

/**
     * Returns the encoded form of this certification path, using
     * the specified encoding.
     *
     * @param encoding the name of the encoding to use
     * @return the encoded bytes
     * @exception java.security.cert.CertificateEncodingException if an encoding error
     * occurs or the encoding requested is not supported
     *
     **/
public byte[] getEncoded(String encoding) throws CertificateEncodingException {
    if (encoding.equalsIgnoreCase("PkiPath")) {
        ASN1EncodableVector v = new ASN1EncodableVector();
        ListIterator iter = certificates.listIterator(certificates.size());
        while (iter.hasPrevious()) {
            v.add(toASN1Object((X509Certificate) iter.previous()));
        }
        return toDEREncoded(new DERSequence(v));
    } else if (encoding.equalsIgnoreCase("PKCS7")) {
        ContentInfo encInfo = new ContentInfo(PKCSObjectIdentifiers.data, null);
        ASN1EncodableVector v = new ASN1EncodableVector();
        for (int i = 0; i != certificates.size(); i++) {
            v.add(toASN1Object((X509Certificate) certificates.get(i)));
        }
        SignedData sd = new SignedData(new ASN1Integer(1), new DERSet(), encInfo, new DERSet(v), null, new DERSet());
        return toDEREncoded(new ContentInfo(PKCSObjectIdentifiers.signedData, sd));
    } else // BEGIN android-removed
    // else if (encoding.equalsIgnoreCase("PEM"))
    // {
    //     ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    //     PemWriter pWrt = new PemWriter(new OutputStreamWriter(bOut));
    //
    //     try
    //     {
    //         for (int i = 0; i != certificates.size(); i++)
    //         {
    //             pWrt.writeObject(new PemObject("CERTIFICATE", ((X509Certificate)certificates.get(i)).getEncoded()));
    //         }
    //
    //         pWrt.close();
    //     }
    //     catch (Exception e)
    //     {
    //         throw new CertificateEncodingException("can't encode certificate for PEM encoded path");
    //     }
    //
    //     return bOut.toByteArray();
    // }
    // END android-removed
    {
        throw new CertificateEncodingException("unsupported encoding: " + encoding);
    }
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) SignedData(org.bouncycastle.asn1.pkcs.SignedData) ContentInfo(org.bouncycastle.asn1.pkcs.ContentInfo) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) CertificateEncodingException(java.security.cert.CertificateEncodingException) ASN1Integer(org.bouncycastle.asn1.ASN1Integer) ListIterator(java.util.ListIterator) DERSet(org.bouncycastle.asn1.DERSet) X509Certificate(java.security.cert.X509Certificate)

Aggregations

ListIterator (java.util.ListIterator)121 ArrayList (java.util.ArrayList)42 List (java.util.List)41 LinkedList (java.util.LinkedList)26 Iterator (java.util.Iterator)21 Map (java.util.Map)12 Handler (com.sun.jsftemplating.annotation.Handler)8 AbstractList (java.util.AbstractList)7 HashMap (java.util.HashMap)7 AbstractSequentialList (java.util.AbstractSequentialList)6 IOException (java.io.IOException)5 RandomAccess (java.util.RandomAccess)5 SelectResults (org.apache.geode.cache.query.SelectResults)5 Test (org.junit.Test)5 File (java.io.File)4 HashSet (java.util.HashSet)4 NoSuchElementException (java.util.NoSuchElementException)4 SipURI (javax.sip.address.SipURI)4 ArgumentIntKey (lucee.runtime.type.scope.ArgumentIntKey)4 StructTypeImpl (org.apache.geode.cache.query.internal.types.StructTypeImpl)4