Java Examples for java.util.Iterator

The following java examples will help you to understand the usage of java.util.Iterator. These source code samples are taken from different open source projects.

Example 1
Project: eclipse.jdt.ui-master  File: IteratorForLoopJavaContextTest.java View source code
public void testProposalsWithFieldAndParam() throws Exception {
    String template = evaluateTemplateInMethodWithField("void method(Collection<String> strings)", "Collection<Number> numbers");
    assertEquals("	for (java.util.Iterator iterator = strings.iterator(); iterator.hasNext();) {\n" + "		String string = (String) iterator.next();\n" + "		\n" + "	}", template);
}
Example 2
Project: alvsanand-master  File: FacesUtils.java View source code
public static UIComponent findComponent(UIComponent parent, String id) {
    if (id.equals(parent.getId())) {
        return parent;
    }
    Iterator<UIComponent> kids = parent.getFacetsAndChildren();
    while (kids.hasNext()) {
        UIComponent kid = kids.next();
        UIComponent found = findComponent(kid, id);
        if (found != null) {
            return found;
        }
    }
    return null;
}
Example 3
Project: android-alternative-video-recorder-master  File: VideoFilter.java View source code
public static String format(ArrayList<VideoFilter> listFilters) {
    StringBuffer result = new StringBuffer();
    Iterator<VideoFilter> it = listFilters.iterator();
    VideoFilter vf;
    while (it.hasNext()) {
        vf = it.next();
        result.append(vf.getFilterString());
        if (it.hasNext())
            result.append(",");
    }
    return result.toString();
}
Example 4
Project: android-ffmpeg-java-master  File: VideoFilter.java View source code
public static String format(ArrayList<VideoFilter> listFilters) {
    StringBuffer result = new StringBuffer();
    Iterator<VideoFilter> it = listFilters.iterator();
    VideoFilter vf;
    while (it.hasNext()) {
        vf = it.next();
        result.append(vf.getFilterString());
        if (it.hasNext())
            result.append(",");
    }
    return result.toString();
}
Example 5
Project: aq2o-master  File: MapToObject.java View source code
public Object[][] convert(Map<String, Object> mapIn) {
    Object[][] out = new Object[mapIn.size()][2];
    Iterator<String> keyIterator = mapIn.keySet().iterator();
    Iterator<Object> valueIterator = mapIn.values().iterator();
    int row = 0;
    while (keyIterator.hasNext()) {
        //
        String key = keyIterator.next();
        Object value = valueIterator.next();
        out[row][0] = key;
        out[row][1] = value;
        row++;
    }
    return out;
}
Example 6
Project: cloudstore-master  File: LocalRepositoryDao.java View source code
public LocalRepository getLocalRepositoryOrFail() {
    Iterator<LocalRepository> repositoryIterator = pm().getExtent(LocalRepository.class).iterator();
    if (!repositoryIterator.hasNext()) {
        throw new IllegalStateException("LocalRepository entity not found in database.");
    }
    LocalRepository localRepository = repositoryIterator.next();
    if (repositoryIterator.hasNext()) {
        throw new IllegalStateException("Multiple LocalRepository entities in database.");
    }
    return localRepository;
}
Example 7
Project: cordova-plugin-video-editor-master  File: VideoFilter.java View source code
public static String format(ArrayList<VideoFilter> listFilters) {
    StringBuffer result = new StringBuffer();
    Iterator<VideoFilter> it = listFilters.iterator();
    VideoFilter vf;
    while (it.hasNext()) {
        vf = it.next();
        result.append(vf.getFilterString());
        if (it.hasNext())
            result.append(",");
    }
    return result.toString();
}
Example 8
Project: ef-orm-master  File: JsCall.java View source code
public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append(name).append('(');
    Iterator<Object> iter = args.iterator();
    if (iter.hasNext()) {
        sb.append(JsonUtil.toJsonScriptCode(iter.next()));
    }
    for (; iter.hasNext(); ) {
        sb.append(',');
        sb.append(JsonUtil.toJsonScriptCode(iter.next()));
    }
    return sb.toString();
}
Example 9
Project: FURCAS-master  File: QualifiedNamesHelper.java View source code
public static String getQualifiedString(List<String> nameList) {
    StringBuilder qualifiedname = new StringBuilder();
    for (Iterator<String> iterator = nameList.iterator(); iterator.hasNext(); ) {
        String string = iterator.next();
        qualifiedname.append(string);
        if (iterator.hasNext()) {
            qualifiedname.append("::");
        }
    }
    return qualifiedname.toString();
}
Example 10
Project: gdl-tools-master  File: CMTypeManagerTest.java View source code
@Test
public void shouldHaveOrderOnCMTypes() {
    Iterator<CMType> cmTypeIterator = CMTypeManager.getInstance().getAllCMTypes().iterator();
    assertEquals("terminologies", cmTypeIterator.next().getId());
    assertEquals("archetypes", cmTypeIterator.next().getId());
    assertEquals("templates", cmTypeIterator.next().getId());
    assertEquals("guidelines", cmTypeIterator.next().getId());
}
Example 11
Project: gngr-master  File: RenderUtils.java View source code
public static Renderable findHtmlRenderable(RCollection root) {
    final Iterator<? extends Renderable> rs = root.getRenderables();
    if (rs != null) {
        while (rs.hasNext()) {
            final Renderable r = rs.next();
            if (r.getModelNode() instanceof HTMLHtmlElement) {
                return r;
            }
        }
    }
    return null;
}
Example 12
Project: gruppe33-master  File: CompositeIterator.java View source code
/*
	 * (non-Javadoc)
	 * 
	 * @see java.util.Iterator#next()
	 */
@Override
public E next() {
    if (!hasNext()) {
        throw new NoSuchElementException();
    }
    // Get iterator
    Iterator<? extends E> itr = iterators.element();
    // Store next object
    E next = itr.next();
    // Store remove reference
    removePtr = itr;
    // Empty now ?
    if (!itr.hasNext()) {
        iterators.remove();
    }
    // Return the next
    return next;
}
Example 13
Project: hibernate-tools-master  File: JUnitUtil.java View source code
public static void assertIteratorContainsExactly(String reason, Iterator<?> iterator, int expectedAmountOfElements) {
    int actualAmountOfElements = 0;
    while (iterator.hasNext() && actualAmountOfElements <= expectedAmountOfElements) {
        actualAmountOfElements++;
        iterator.next();
    }
    if (actualAmountOfElements != expectedAmountOfElements) {
        throw new ComparisonFailure(reason, Integer.toString(expectedAmountOfElements), Integer.toString(actualAmountOfElements));
    }
}
Example 14
Project: jblog-master  File: ArrayUtils.java View source code
public static PostParameter[] mapToArray(Map<String, String> map) {
    PostParameter[] parList = new PostParameter[map.size()];
    Iterator<String> iter = map.keySet().iterator();
    int i = 0;
    while (iter.hasNext()) {
        String key = iter.next();
        String value = map.get(key);
        parList[i++] = new PostParameter(key, value);
    }
    return parList;
}
Example 15
Project: Jnario-master  File: EObjects.java View source code
public static Iterator<EObject> allParents(final EObject eObject) {
    return new Iterator<EObject>() {

        EObject current = eObject;

        public boolean hasNext() {
            return current.eContainer() != null;
        }

        public EObject next() {
            current = current.eContainer();
            return current;
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
}
Example 16
Project: ldbc_driver-master  File: LimitGeneratorTest.java View source code
@Test
public void shouldStopAtLimitTest() {
    // Given
    Iterator<Integer> generator = new GeneratorFactory(new RandomDataGeneratorFactory()).uniform(1, 10);
    Iterator<Integer> cappedGenerator = new LimitGenerator<Integer>(generator, 10);
    // When
    int count = 0;
    while (cappedGenerator.hasNext()) {
        cappedGenerator.next();
        count++;
    }
    // Then
    assertEquals(10, count);
}
Example 17
Project: lombok-pg-master  File: YieldIfThenElse.java View source code
@java.lang.SuppressWarnings("all")
public Iterable<String> test() {
    class $YielderTest implements java.util.Iterator<String>, java.lang.Iterable<String>, java.io.Closeable {

        private boolean b;

        private int $state;

        private boolean $hasNext;

        private boolean $nextDefined;

        private String $next;

        private $YielderTest() {
            super();
        }

        public java.util.Iterator<String> iterator() {
            if (($state == 0)) {
                $state = 1;
                return this;
            } else
                return new $YielderTest();
        }

        public boolean hasNext() {
            if ((!$nextDefined)) {
                $hasNext = getNext();
                $nextDefined = true;
            }
            return $hasNext;
        }

        public String next() {
            if ((!hasNext())) {
                throw new java.util.NoSuchElementException();
            }
            $nextDefined = false;
            return $next;
        }

        public void remove() {
            throw new java.lang.UnsupportedOperationException();
        }

        public void close() {
            $state = 5;
        }

        private boolean getNext() {
            while (true) switch($state) {
                case 0:
                    ;
                    $state = 1;
                case 1:
                    ;
                    b = true;
                case 2:
                    ;
                    if ((!b)) {
                        $state = 3;
                        continue;
                    }
                    $next = "foo";
                    $state = 4;
                    return true;
                case 3:
                    ;
                    $next = "bar";
                    $state = 4;
                    return true;
                case 4:
                    ;
                    b = (!b);
                    $state = 2;
                    continue;
                case 5:
                    ;
                default:
                    ;
                    return false;
            }
        }
    }
    return new $YielderTest();
}
Example 18
Project: osm-tools-master  File: SequenceIteratorTest.java View source code
@Test
public void itShouldIterateSequenceUrls() throws Exception {
    Iterator<Sequence> it = new SequenceIterator(Granularity.hour, 999, 1001);
    assertEquals("http://planet.openstreetmap.org/replication/hour/000/001/000.osc.gz", it.next().getUrl());
    assertEquals("http://planet.openstreetmap.org/replication/hour/000/001/001.osc.gz", it.next().getUrl());
    assertFalse(it.hasNext());
}
Example 19
Project: Prendamigo-master  File: FailingIterableDataProvider.java View source code
@DataProvider(name = "dp")
public Iterator<Object[]> createData() {
    return new Iterator<Object[]>() {

        int count = 0;

        public boolean hasNext() {
            return count < 10;
        }

        public Object[] next() {
            if (++count == 6) {
                throw new RuntimeException();
            }
            return new Object[] { count };
        }

        public void remove() {
        }
    };
}
Example 20
Project: SecurityCraft-master  File: EntityUtils.java View source code
/**
	 * Does the given entity have the specified potion effect? <p>
	 * 
	 * Args: entity, potionEffect.
	 */
public static boolean doesMobHavePotionEffect(EntityLivingBase mob, Potion potion) {
    Iterator<?> iterator = mob.getActivePotionEffects().iterator();
    while (iterator.hasNext()) {
        PotionEffect effect = (PotionEffect) iterator.next();
        String eName = effect.getEffectName();
        if (eName.matches(potion.getName())) {
            return true;
        } else {
            continue;
        }
    }
    return false;
}
Example 21
Project: vertexium-master  File: EmptyClosableIterable.java View source code
@Override
public Iterator<T> iterator() {
    return new Iterator<T>() {

        @Override
        public boolean hasNext() {
            return false;
        }

        @Override
        public T next() {
            throw new IllegalStateException("No element");
        }

        @Override
        public void remove() {
            throw new IllegalStateException("Remove not implemented");
        }
    };
}
Example 22
Project: vorlesung-se2-dhbw-master  File: Main.java View source code
public static void main(String[] args) {
    final String[] array = new String[] { "Frühjahr", "Sommer", "Herbst", "Winter", "Weihnachten", "Ostern", "Klausurwoche", "Fasching", "Geburtstag", "The day after the party" };
    Iterator<String> all = new EndlessSummer();
    //		Iterator<String> all = new RandomOrderArrayIterator<>(array);
    while (all.hasNext()) {
        System.out.println(all.next());
    }
}
Example 23
Project: VUE-master  File: CabList.java View source code
public static void main(String args[]) {
    ArrayList names = CabUtil.parseCommandLine(args);
    if (names.size() < 1)
        names.add(".");
    Iterator i = names.iterator();
    while (i.hasNext()) {
        String cabName = (String) i.next();
        Cabinet cabinet = CabUtil.getCabinet(cabName);
        CabUtil.printCabinet(cabinet);
    }
}
Example 24
Project: wayback-machine-master  File: SurtNodeTest.java View source code
public void testNodesFromSurt() {
    Iterator<SurtNode> it = SurtNode.nodesFromSurt("(org,archive,)/about").iterator();
    assertEquals("(", it.next().getName());
    assertEquals("(org,", it.next().getSurt());
    assertEquals("archive,", it.next().getName());
    assertEquals("(org,archive,)/", it.next().getSurt());
    assertEquals("about", it.next().getName());
    assertFalse(it.hasNext());
}
Example 25
Project: wonder-master  File: FlattenedIteratorTest.java View source code
public void test1_discoveredNPETest() {
    // it used to fail when internal iterator was not present, due to NullPointerException
    List<Iterator<Object>> iterators = new ArrayList<Iterator<Object>>();
    FlattenedIterator<Object> it = new FlattenedIterator<>(iterators.iterator());
    while (it.hasNext()) {
        it.next();
    }
}
Example 26
Project: WordsDetection-master  File: ArrayUtils.java View source code
public static PostParameter[] mapToArray(Map<String, String> map) {
    PostParameter[] parList = new PostParameter[map.size()];
    Iterator<String> iter = map.keySet().iterator();
    int i = 0;
    while (iter.hasNext()) {
        String key = iter.next();
        String value = map.get(key);
        parList[i++] = new PostParameter(key, value);
    }
    return parList;
}
Example 27
Project: kludje-master  File: LambdaIterators.java View source code
/**
   * Provides an {@link java.util.Iterator} backed by functional interfaces.
   * {@link java.util.Iterator#remove} is not supported.
   *
   * @param hasNext used to implement {@link java.util.Iterator#hasNext()}
   * @param next used to implement {@link java.util.Iterator#next()}
   * @param <E> the generic type
   * @return a new instance
   */
public static <E> Iterator<E> iterator(BooleanSupplier hasNext, Supplier<E> next) {
    Objects.requireNonNull(hasNext, "hasNext");
    Objects.requireNonNull(next, "next");
    class LambdaIterator extends BaseIterator<E> {

        @Override
        public boolean hasNext() {
            return hasNext.getAsBoolean();
        }

        @Override
        protected E nextElement() {
            return next.get();
        }
    }
    return new LambdaIterator();
}
Example 28
Project: sosies-generator-master  File: ObjectGraphIteratorTest.java View source code
@Override
public void setUp() {
    list1 = new ArrayList<java.lang.String>();
    list1.add("One");
    list1.add("Two");
    list1.add("Three");
    list2 = new ArrayList<java.lang.String>();
    list2.add("Four");
    list3 = new ArrayList<java.lang.String>();
    list3.add("Five");
    list3.add("Six");
    iteratorList = new ArrayList<java.util.Iterator<java.lang.String>>();
    iteratorList.add(list1.iterator());
    iteratorList.add(list2.iterator());
    iteratorList.add(list3.iterator());
}
Example 29
Project: acs-master  File: ListenerBasedNodeUpdater.java View source code
protected final void fireShortDescriptionChange(String newShortDescription) {
    if (!hasListeners())
        return;
    synchronized (eventListeners) {
        java.util.Iterator iterator = eventListeners.iterator();
        while (iterator.hasNext()) {
            ((NodeUpdaterListener) iterator.next()).shortDescriptionChanged(newShortDescription);
        }
    }
}
Example 30
Project: BC-BSP-master  File: ErrorSumAggregator.java View source code
@Override
public ErrorAggregateValue aggregate(Iterable<ErrorAggregateValue> aggValues) {
    ErrorAggregateValue errorSum = new ErrorAggregateValue();
    Iterator<ErrorAggregateValue> it = aggValues.iterator();
    double errorValue = 0.0;
    while (it.hasNext()) {
        errorValue += Double.parseDouble(it.next().getValue());
    }
    errorSum.setValue(Double.toString(errorValue));
    return errorSum;
}
Example 31
Project: extFM-Tooling-master  File: MtextEObjectSelection.java View source code
public java.util.Iterator<?> iterator() {
    return new java.util.Iterator<org.eclipse.emf.ecore.EObject>() {

        private boolean hasNext = true;

        public boolean hasNext() {
            return hasNext;
        }

        public org.eclipse.emf.ecore.EObject next() {
            hasNext = false;
            return selectedObject;
        }

        public void remove() {
        }
    };
}
Example 32
Project: k3-master  File: RobotEObjectSelection.java View source code
public java.util.Iterator<?> iterator() {
    return new java.util.Iterator<org.eclipse.emf.ecore.EObject>() {

        private boolean hasNext = true;

        public boolean hasNext() {
            return hasNext;
        }

        public org.eclipse.emf.ecore.EObject next() {
            hasNext = false;
            return selectedObject;
        }

        public void remove() {
        }
    };
}
Example 33
Project: Reuseware-master  File: AsEObjectSelection.java View source code
public java.util.Iterator<?> iterator() {
    return new java.util.Iterator<org.eclipse.emf.ecore.EObject>() {

        private boolean hasNext = true;

        public boolean hasNext() {
            return hasNext;
        }

        public org.eclipse.emf.ecore.EObject next() {
            hasNext = false;
            return selectedObject;
        }

        public void remove() {
        }
    };
}
Example 34
Project: ttc2011-master  File: SslEObjectSelection.java View source code
public java.util.Iterator<?> iterator() {
    return new java.util.Iterator<org.eclipse.emf.ecore.EObject>() {

        private boolean hasNext = true;

        public boolean hasNext() {
            return hasNext;
        }

        public org.eclipse.emf.ecore.EObject next() {
            hasNext = false;
            return selectedObject;
        }

        public void remove() {
        }
    };
}
Example 35
Project: 101simplejava-master  File: Total.java View source code
public static double total(Document doc) {
    // Aggregate salaries
    double total = 0;
    // Iterate over all salary elements
    Iterator<?> iterator = doc.getDescendants(new ElementFilter("salary"));
    while (iterator.hasNext()) {
        Element elem = (Element) iterator.next();
        Double salary = Double.valueOf(elem.getText());
        total += salary;
    }
    return total;
}
Example 36
Project: agui_eclipse_plugin-master  File: ClassFinderCollection.java View source code
public byte[] findClass(String name) {
    byte[] result = null;
    for (Iterator iter = classFinders.iterator(); iter.hasNext(); ) {
        IClassFinder classFinder = (IClassFinder) iter.next();
        result = classFinder.findClass(name);
        if (result != null) {
            break;
        }
    }
    return result;
}
Example 37
Project: AnimeTaste-master  File: ApiUtils.java View source code
public static String getAccessToken(TreeMap<String, String> map, String app_secret) {
    String toMd5 = "";
    Set<String> keys = map.keySet();
    Iterator<String> iterator = keys.iterator();
    while (iterator.hasNext()) {
        String key = iterator.next();
        toMd5 += key + "=" + map.get(key) + "&";
    }
    toMd5 = toMd5.substring(0, toMd5.length() - 1);
    toMd5 += app_secret;
    return MD5.digest(toMd5);
}
Example 38
Project: apollo-master  File: ServiceBootstrap.java View source code
public static <S> S loadFirst(Class<S> clazz) {
    Iterator<S> iterator = loadAll(clazz);
    if (!iterator.hasNext()) {
        throw new IllegalStateException(String.format("No implementation defined in /META-INF/services/%s, please check whether the file exists and has the right implementation class!", clazz.getName()));
    }
    return iterator.next();
}
Example 39
Project: bluetooth_social-master  File: HttpUtils.java View source code
public static Map<String, String> decodeByDecodeNames(List<String> decodeNames, Map<String, String> map) {
    Set<String> keys = map.keySet();
    Iterator<String> it = keys.iterator();
    while (it.hasNext()) {
        String key = it.next();
        String value = map.get(key);
        for (String decodeName : decodeNames) {
            if (key.equals(decodeName)) {
                value = URLDecoder.decode(value);
                map.put(key, value);
            }
        }
    }
    return map;
}
Example 40
Project: BootsFaces-OSP-master  File: FullCalendarEventList.java View source code
public String toJson() {
    StringBuilder buf = new StringBuilder("[");
    Iterator<FullCalendarEventBean> iterator = list.iterator();
    while (iterator.hasNext()) {
        buf.append(iterator.next().toJson());
        if (iterator.hasNext()) {
            buf.append(",");
        }
    }
    buf.append("]");
    return buf.toString();
}
Example 41
Project: bvira-master  File: MapsUnitTests.java View source code
@Test
public void orderedMapsAreOrderedByInsertionSequence() {
    Map<String, String> map = Maps.createOrdered();
    map.put("B", "A");
    map.put("A", "B");
    Iterator<String> iterator = map.keySet().iterator();
    assertThat(iterator.next(), is("B"));
    assertThat(iterator.next(), is("A"));
    Iterator<String> iterator1 = map.values().iterator();
    assertThat(iterator1.next(), is("A"));
    assertThat(iterator1.next(), is("B"));
}
Example 42
Project: byte-buddy-master  File: ByteBuddyAgentProcessProviderTest.java View source code
@Test
public void testObjectProperties() throws Exception {
    ObjectPropertyAssertion.of(ByteBuddyAgent.ProcessProvider.ForCurrentVm.ForLegacyVm.class).apply();
    final Iterator<Method> methods = Arrays.asList(Object.class.getDeclaredMethods()).iterator();
    ObjectPropertyAssertion.of(ByteBuddyAgent.ProcessProvider.ForCurrentVm.ForJava9CapableVm.class).create(new ObjectPropertyAssertion.Creator<Method>() {

        @Override
        public Method create() {
            return methods.next();
        }
    }).apply();
    ObjectPropertyAssertion.of(ByteBuddyAgent.AttachmentProvider.Accessor.Unavailable.class).apply();
}
Example 43
Project: ChipsLayoutManager-master  File: ChildViewsIterable.java View source code
@Override
public Iterator<View> iterator() {
    return new Iterator<View>() {

        int i = 0;

        @Override
        public boolean hasNext() {
            return i < layoutManager.getChildCount();
        }

        @Override
        public View next() {
            return layoutManager.getChildAt(i++);
        }
    };
}
Example 44
Project: CliffiesGoos1.7-master  File: EventHooks.java View source code
@SubscribeEvent
public void onTick(TickEvent.ServerTickEvent event) {
    if (NukeRegistry.isExploding()) {
        Iterator<Explosion> i = NukeRegistry.getExplosions().iterator();
        while (i.hasNext()) {
            Explosion explosion = i.next();
            if (explosion.hasExploded()) {
                System.out.println("Ending Nuking");
                i.remove();
                return;
            }
            explosion.progress();
        }
    }
}
Example 45
Project: Cloud9-master  File: AER.java View source code
public static float computeAER(Iterator<ReferenceAlignment> refi, Iterator<Alignment> testi) {
    float num = 0.0f;
    float den = 0.0f;
    while (refi.hasNext()) {
        ReferenceAlignment ref = refi.next();
        Alignment test = testi.next();
        num += (ref.countProbableHits(test) + ref.countSureHits(test));
        den += (test.countAlignmentPoints() + ref.countAlignmentPoints());
    }
    if (testi.hasNext())
        throw new RuntimeException("Mismatch in lengths");
    return num / den;
}
Example 46
Project: cms-ce-master  File: RelationAggregator.java View source code
/**
     * Visit the specified node.
     */
public Object visit(RelationNode node) {
    double num = 0;
    Object data = node.getData();
    if (data instanceof Number) {
        num += ((Number) data).doubleValue();
    }
    for (Iterator i = node.getChildren().iterator(); i.hasNext(); ) {
        Object tmp = ((RelationNode) i.next()).accept(this);
        if (tmp instanceof Number) {
            num += ((Number) tmp).doubleValue();
        }
    }
    return new Double(num);
}
Example 47
Project: codemap-master  File: Cycle.java View source code
public Iterator<E> iterator() {
    return new Iterator<E>() {

        private Iterator<E> it = iterable.iterator();

        public boolean hasNext() {
            if (!it.hasNext())
                it = iterable.iterator();
            return it.hasNext();
        }

        public E next() {
            if (!it.hasNext())
                it = iterable.iterator();
            return it.next();
        }

        public void remove() {
            it.remove();
        }
    };
}
Example 48
Project: contexttoolkit-master  File: ComponentDescriptions.java View source code
public ComponentDescription mergeComponentDescriptions() {
    ComponentDescription result = new ComponentDescription();
    Iterator<ComponentDescription> itr = this.iterator();
    while (itr.hasNext()) {
        ComponentDescription cd = itr.next();
        for (Attribute att : cd.getConstantAttributesFull().values()) {
            result.getConstantAttributesFull().add(att);
        }
        for (Attribute att : cd.getNonConstantAttributes().values()) {
            result.getNonConstantAttributes().add(att);
        }
    // TODO unir os demais atributos. Poderam ser usados em algum momento. 
    }
    return result;
}
Example 49
Project: continuous_integration_example-master  File: BeerServicePerformanceTest.java View source code
public void testPerformanceGetBeer() {
    Collection beers = beerService.findAll();
    java.util.Iterator itor = beers.iterator();
    String name = null;
    Beer beer = null;
    while (itor.hasNext()) {
        beer = (Beer) itor.next();
        name = beer.getName();
        System.out.println("name1=" + name);
    }
    if (beers != null && beers.size() > 0) {
        assertTrue(true);
    } else {
        assertTrue(false);
    }
}
Example 50
Project: CoreNLP-master  File: ConcatenationIteratorTest.java View source code
public void testIterator() {
    Collection<String> c1 = Collections.singleton("a");
    Collection<String> c2 = Collections.singleton("b");
    Iterator<String> i = new ConcatenationIterator<String>(c1.iterator(), c2.iterator());
    assertEquals("a", i.next());
    assertEquals("b", i.next());
    assertFalse(i.hasNext());
}
Example 51
Project: cucumber-jvm-master  File: DelegatingResourceIteratorFactoryTest.java View source code
@Test
public void should_load_test_resource_iterator() throws MalformedURLException {
    ResourceIteratorFactory factory = new DelegatingResourceIteratorFactory(new ZipThenFileResourceIteratorFactory());
    URL url = new URL(TestResourceIteratorFactory.TEST_URL);
    assertTrue(factory.isFactoryFor(url));
    Iterator<Resource> iterator = factory.createIterator(url, "test", "test");
    assertTrue(iterator instanceof TestResourceIterator);
}
Example 52
Project: deltaspike-solder-master  File: ValidationException.java View source code
@Override
public String getMessage() {
    StringBuilder builder = new StringBuilder("[");
    for (Iterator<ConstraintViolation<Object>> iterator = violations.iterator(); iterator.hasNext(); ) {
        builder.append(iterator.next().getMessage());
        if (iterator.hasNext()) {
            builder.append(", ");
        }
    }
    builder.append("]");
    return builder.toString();
}
Example 53
Project: dltk.tcl-master  File: PackageUtils.java View source code
public static String packagesToKey(Set<String> packages) {
    Set<String> sorted = new TreeSet<String>();
    sorted.addAll(packages);
    StringBuffer buffer = new StringBuffer();
    for (Iterator<String> iterator = sorted.iterator(); iterator.hasNext(); ) {
        String object = iterator.next();
        buffer.append("_").append(object);
    }
    return buffer.toString().replaceAll(":", "_");
}
Example 54
Project: DoSeR-master  File: WikipediaLDADataGeneratorReducer.java View source code
@Override
public void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
    Iterator<Text> it = values.iterator();
    StringBuilder b = new StringBuilder();
    while (it.hasNext()) {
        //			b.append("---");
        b.append(" ");
        b.append(it.next());
    }
    //		b.append("---");
    b.append(" ");
    context.write(key, new Text(b.toString()));
}
Example 55
Project: ElasticRawClient-master  File: AliasParser.java View source code
public static List<String> getAliasesFromJson(String indexName, String jsonString) {
    List<String> retValue = new ArrayList<>();
    try {
        JSONObject json = new JSONObject(jsonString);
        JSONObject index = json.getJSONObject(indexName);
        JSONObject aliases = index.getJSONObject("aliases");
        for (Iterator iterator = aliases.keys(); iterator.hasNext(); ) {
            String key = (String) iterator.next();
            retValue.add(key);
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
    return retValue;
}
Example 56
Project: emf.diffmerge.core-master  File: ComparableTreeMap.java View source code
/**
   * @see org.eclipse.emf.diffmerge.util.structures.comparable.IComparableStructure#getCompareIterator()
   */
public Iterator<IComparableMapEntry<K, V>> getCompareIterator() {
    final Iterator<Map.Entry<K, V>> ascendingEntryIterator = // In ascending order
    entrySet().iterator();
    return new Iterator<IComparableMapEntry<K, V>>() {

        /**
       * @see java.util.Iterator#hasNext()
       */
        public boolean hasNext() {
            return ascendingEntryIterator.hasNext();
        }

        /**
       * @see java.util.Iterator#next()
       */
        public IComparableMapEntry<K, V> next() {
            Map.Entry<K, V> next = ascendingEntryIterator.next();
            return new ComparableMapEntry<K, V>(next);
        }

        /**
       * @see java.util.Iterator#remove()
       */
        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
}
Example 57
Project: entermedia-core-master  File: FileUtilsTest.java View source code
public void testIsLegalPath() {
    FileUtils util = new FileUtils();
    ArrayList ar = new ArrayList();
    ar.add("previous_photos/previous_photos/Photos/Institutional Advancement/DONORS/SBC/FRANK WEATHERS 10-03 COON /Weathers 01.JPG.xconf");
    ar.add("ABC\\DEFGHIJ\\KL?MNOP.xconf");
    ar.add("ABC\\DEFGHIJ\nKL\\MNOP.xconf");
    for (Iterator iterator = ar.iterator(); iterator.hasNext(); ) {
        String path = (String) iterator.next();
        assertFalse(util.isLegalFilename(path));
    }
}
Example 58
Project: etk-component-master  File: ValuesParam.java View source code
public String toString() {
    Iterator it = values.iterator();
    StringBuilder builder = new StringBuilder();
    while (it.hasNext()) {
        Object object = (Object) it.next();
        builder.append(object);
        if (it.hasNext()) {
            builder.append(",");
        }
    }
    return builder.toString();
}
Example 59
Project: exhibition369_android-master  File: ListUtil.java View source code
/**
     * 数组去除��元素
     */
public static List<String> removeDuplicateWithOrder(List<String> list) {
    Set<String> set = new HashSet<String>();
    List<String> newList = new ArrayList<String>();
    for (Iterator<String> iter = list.iterator(); iter.hasNext(); ) {
        String element = iter.next();
        if (set.add(element))
            newList.add(element);
    }
    list.clear();
    return newList;
}
Example 60
Project: extension-aws-master  File: Node.java View source code
public String get(String inId) {
    String val = getElement().attributeValue(inId);
    if (val == null) {
        for (Iterator iterator = getElement().elementIterator(); iterator.hasNext(); ) {
            Element ele = (Element) iterator.next();
            if (inId.equals(ele.attributeValue("id"))) {
                val = ele.getTextTrim();
                break;
            }
        }
    }
    return val;
}
Example 61
Project: Far-On-Droid-master  File: ReversedIterator.java View source code
@Override
public Iterator<T> iterator() {
    final ListIterator<T> iterator = list.listIterator(list.size());
    return new Iterator<T>() {

        @Override
        public boolean hasNext() {
            return iterator.hasPrevious();
        }

        @Override
        public T next() {
            return iterator.previous();
        }

        @Override
        public void remove() {
            iterator.remove();
        }
    };
}
Example 62
Project: FB2OnlineConverter-master  File: ImportRule.java View source code
public void serialize(PrintWriter out) {
    out.print("@import url(");
    out.print(url);
    out.print(")");
    if (mediaList != null) {
        Iterator it = mediaList.iterator();
        String sep = " ";
        while (it.hasNext()) {
            out.print(sep);
            out.print(it.next());
            sep = ", ";
        }
    }
    out.println(";");
}
Example 63
Project: featurehouse_fstcomp_examples-master  File: Main.java View source code
public Object driver(String[] args) throws Throwable {
    setVersion("v2002.08.27");
    Collector collector = (Collector) original(args);
    List misDefined = collector.baliRules.misDefined();
    Collections.sort(misDefined);
    for (Iterator p = misDefined.iterator(); p.hasNext(); ) {
        String rule = (String) p.next();
        System.err.println("rule \"" + rule + "\" is referenced but not defined");
    }
    return collector;
}
Example 64
Project: floodlight-master  File: TVersionedValueIterable.java View source code
@Override
public Iterator<Versioned<byte[]>> iterator() {
    final Iterator<VersionedValue> vs = tvvi.iterator();
    return new Iterator<Versioned<byte[]>>() {

        @Override
        public boolean hasNext() {
            return vs.hasNext();
        }

        @Override
        public Versioned<byte[]> next() {
            return TProtocolUtil.getVersionedValued(vs.next());
        }

        @Override
        public void remove() {
            vs.remove();
        }
    };
}
Example 65
Project: floodlightUI-master  File: TVersionedValueIterable.java View source code
@Override
public Iterator<Versioned<byte[]>> iterator() {
    final Iterator<VersionedValue> vs = tvvi.iterator();
    return new Iterator<Versioned<byte[]>>() {

        @Override
        public boolean hasNext() {
            return vs.hasNext();
        }

        @Override
        public Versioned<byte[]> next() {
            return TProtocolUtil.getVersionedValued(vs.next());
        }

        @Override
        public void remove() {
            vs.remove();
        }
    };
}
Example 66
Project: floodlight_with_topoguard-master  File: TVersionedValueIterable.java View source code
@Override
public Iterator<Versioned<byte[]>> iterator() {
    final Iterator<VersionedValue> vs = tvvi.iterator();
    return new Iterator<Versioned<byte[]>>() {

        @Override
        public boolean hasNext() {
            return vs.hasNext();
        }

        @Override
        public Versioned<byte[]> next() {
            return TProtocolUtil.getVersionedValued(vs.next());
        }

        @Override
        public void remove() {
            vs.remove();
        }
    };
}
Example 67
Project: flow-master  File: NotPersistentHistoryFilter.java View source code
@NonNull
@Override
public History scrubHistory(@NonNull History history) {
    History.Builder builder = History.emptyBuilder();
    final Iterator<Object> keys = history.reverseIterator();
    while (keys.hasNext()) {
        Object key = keys.next();
        if (!key.getClass().isAnnotationPresent(NotPersistent.class)) {
            builder.push(key);
        }
    }
    return builder.build();
}
Example 68
Project: h-store-master  File: TestProcedureLimitFilter.java View source code
/**
     * testFilter
     */
@Test
public void testFilter() throws Exception {
    int new_limit = 100;
    ProcedureLimitFilter filter = new ProcedureLimitFilter(new_limit);
    Iterator<TransactionTrace> it = workload.iterator(filter);
    assertNotNull(it);
    int count = 0;
    while (it.hasNext()) {
        AbstractTraceElement<? extends CatalogType> element = it.next();
        if (element instanceof TransactionTrace) {
            count++;
        }
    }
    // WHILE
    assertEquals(new_limit, count);
}
Example 69
Project: hexa.tools-master  File: JSArrayIterator.java View source code
public Iterator<T> iterator() {
    return new Iterator<T>() {

        int idx = 0;

        public boolean hasNext() {
            return idx < obj.length();
        }

        public T next() {
            return obj.get(idx++);
        }

        public void remove() {
            assert false : "remove forbidden";
        }
    };
}
Example 70
Project: hivedb-master  File: Strings.java View source code
public static String join(String separator, String... strings) {
    StringBuilder sb = new StringBuilder();
    List<String> list = Lists.newList(strings);
    Iterator<String> itr = list.iterator();
    while (itr.hasNext()) {
        sb.append(itr.next());
        if (itr.hasNext())
            sb.append(separator);
    }
    return sb.toString();
}
Example 71
Project: java-virtual-machine-master  File: ByteBuddyAgentProcessProviderTest.java View source code
@Test
public void testObjectProperties() throws Exception {
    ObjectPropertyAssertion.of(ByteBuddyAgent.ProcessProvider.ForCurrentVm.ForLegacyVm.class).apply();
    final Iterator<Method> methods = Arrays.asList(Object.class.getDeclaredMethods()).iterator();
    ObjectPropertyAssertion.of(ByteBuddyAgent.ProcessProvider.ForCurrentVm.ForJava9CapableVm.class).create(new ObjectPropertyAssertion.Creator<Method>() {

        @Override
        public Method create() {
            return methods.next();
        }
    }).apply();
    ObjectPropertyAssertion.of(ByteBuddyAgent.AttachmentProvider.Accessor.Unavailable.class).apply();
}
Example 72
Project: javardices-master  File: JptEvalUtils.java View source code
public static Object[] evaluateToArray(Object collection) {
    if (collection == null)
        return new Object[0];
    if (collection.getClass().isArray())
        return (Object[]) collection;
    if (collection instanceof Collection)
        return ((Collection) collection).toArray();
    if (collection instanceof Iterator) {
        List<Object> content_list = new ArrayList<Object>();
        for (Object o : content_list) {
            content_list.add(o);
        }
        return content_list.toArray();
    } else {
        return new Object[0];
    }
}
Example 73
Project: jeboorker-master  File: LruListTest.java View source code
public void testList1() {
    int len = 5;
    LruList<String> l = new LruList<>(len);
    for (int i = 0; i < 8; i++) {
        l.add(String.valueOf(i + "val"));
    }
    assertEquals("[3val, 4val, 5val, 6val, 7val]", l.toString());
    assertEquals(len, l.size());
    Iterator<String> iterator = l.iterator();
    String testResult = "";
    while (iterator.hasNext()) {
        testResult += iterator.next();
    }
    assertEquals("3val4val5val6val7val", testResult);
    l.clear();
    assertEquals(0, l.size());
}
Example 74
Project: jframe-master  File: ClientRequestHandler.java View source code
@SuppressWarnings("rawtypes")
public String getXmlBody() {
    StringBuilder sb = new StringBuilder();
    Set es = super.getAllParameters().entrySet();
    Iterator it = es.iterator();
    while (it.hasNext()) {
        Map.Entry entry = (Map.Entry) it.next();
        String k = (String) entry.getKey();
        String v = (String) entry.getValue();
        if (!"appkey".equals(k)) {
            sb.append("<" + k + ">" + v + "<" + k + ">" + "\r\n");
        }
    }
    return sb.toString();
}
Example 75
Project: JHazm-master  File: VerbValencyReaderTest.java View source code
@Test
public void getVerbsTest() throws IOException {
    VerbValencyReader vv = new VerbValencyReader();
    String expected = "بر";
    Iterator<Verb> iter = vv.getVerbs().iterator();
    iter.next();
    iter.next();
    iter.next();
    String actual = iter.next().Prefix;
    assertEquals("Failed to read verb valency corpus.", expected, actual);
}
Example 76
Project: jtwig-master  File: IterableToCollectionConverter.java View source code
@Override
public Result<WrappedCollection> convert(Object object) {
    if (object instanceof Iterable) {
        WrappedCollection result = new WrappedCollection();
        Iterator iterator = ((Iterable) object).iterator();
        int i = 0;
        while (iterator.hasNext()) {
            Object next = iterator.next();
            result.add(String.valueOf(i++), next);
        }
        return Result.defined(result);
    }
    return Result.undefined();
}
Example 77
Project: Julez-master  File: StringUtils.java View source code
@SuppressWarnings("rawtypes")
public static String join(Collection items, String separator) {
    items = items == null ? Collections.emptySet() : items;
    separator = separator == null ? "" : separator;
    StringBuilder sb = new StringBuilder();
    int count = 1;
    Iterator it = items.iterator();
    while (it.hasNext()) {
        sb.append(it.next());
        if (count < items.size()) {
            sb.append(separator);
        }
        count++;
    }
    return sb.toString();
}
Example 78
Project: jxse-master  File: MessengerStateListenerSet.java View source code
public synchronized void notifyNewState(int newState) {
    Iterator<MessengerStateListener> listenerIter = stateChangeListeners.iterator();
    while (listenerIter.hasNext()) {
        MessengerStateListener listener = listenerIter.next();
        if (!listener.messengerStateChanged(newState)) {
            listenerIter.remove();
        }
    }
}
Example 79
Project: jxta-master  File: MessengerStateListenerSet.java View source code
public synchronized void notifyNewState(int newState) {
    Iterator<MessengerStateListener> listenerIter = stateChangeListeners.iterator();
    while (listenerIter.hasNext()) {
        MessengerStateListener listener = listenerIter.next();
        if (!listener.messengerStateChanged(newState)) {
            listenerIter.remove();
        }
    }
}
Example 80
Project: katharsis-core-master  File: StringUtils.java View source code
public static String join(String delimiter, Iterable<String> stringsIterable) {
    List<String> strings = new LinkedList<>();
    Iterator<String> iterator = stringsIterable.iterator();
    while (iterator.hasNext()) {
        strings.add(iterator.next());
    }
    StringBuilder ab = new StringBuilder();
    for (int i = 0; i < strings.size(); i++) {
        ab.append(strings.get(i));
        if (i != strings.size() - 1) {
            ab.append(delimiter);
        }
    }
    return ab.toString();
}
Example 81
Project: librepdf-master  File: Utils.java View source code
public static PropertyValue[] toPropertyValues(Map properties) {
    final PropertyValue[] ret = new PropertyValue[properties.size()];
    int i = 0;
    for (Iterator it = properties.entrySet().iterator(); it.hasNext(); ) {
        Map.Entry entry = (Map.Entry) it.next();
        String key = entry.getKey().toString();
        Object val = entry.getValue();
        ret[i] = new PropertyValue();
        ret[i].Name = key;
        ret[i].Value = (val instanceof Map) ? Utils.toPropertyValues((Map) val) : val;
        i++;
    }
    return ret;
}
Example 82
Project: lzusdn-master  File: TVersionedValueIterable.java View source code
@Override
public Iterator<Versioned<byte[]>> iterator() {
    final Iterator<VersionedValue> vs = tvvi.iterator();
    return new Iterator<Versioned<byte[]>>() {

        @Override
        public boolean hasNext() {
            return vs.hasNext();
        }

        @Override
        public Versioned<byte[]> next() {
            return TProtocolUtil.getVersionedValued(vs.next());
        }

        @Override
        public void remove() {
            vs.remove();
        }
    };
}
Example 83
Project: mcplus_mods-master  File: LanguageFactory.java View source code
public static void write(String parDirectory, String parFileName, Language parLanguage) {
    StringBuilder str = new StringBuilder();
    Iterator<String> iter = parLanguage.iterator();
    while (iter.hasNext()) {
        String unlocalized = iter.next();
        str.append(unlocalized + "=" + parLanguage.get(unlocalized) + "\n");
    }
    ResourceWriter.write(parDirectory, parFileName, str.toString());
}
Example 84
Project: MoparScape-master  File: TaskScheduler.java View source code
public void tick() {
    for (Task task : taskQueue) {
        tasks.add(task);
    }
    taskQueue.clear();
    for (Iterator<Task> it = tasks.iterator(); it.hasNext(); ) {
        Task task = it.next();
        if (!task.isRunning()) {
            it.remove();
            continue;
        }
        task.tick();
    }
}
Example 85
Project: MPS-master  File: Utils.java View source code
public static <T> void assertSameSequence(Iterable<T> expexted, Iterable<T> actual) {
    Iterator<T> expIt = Sequence.fromIterable(expexted).iterator();
    Iterator<T> testIt = Sequence.fromIterable(actual).iterator();
    while (expIt.hasNext() && testIt.hasNext()) {
        Assert.assertEquals(expIt.next(), testIt.next());
    }
    Assert.assertFalse(expIt.hasNext());
    Assert.assertFalse(testIt.hasNext());
}
Example 86
Project: neo4j-components-svn-master  File: TestCommonIterators.java View source code
@Test
public void testNoDuplicatesFilteringIterator() {
    List<Integer> ints = Arrays.asList(1, 2, 2, 40, 100, 40, 101, 2, 3);
    Iterator<Integer> iterator = FilteringIterator.noDuplicates(ints.iterator());
    assertEquals((Integer) 1, iterator.next());
    assertEquals((Integer) 2, iterator.next());
    assertEquals((Integer) 40, iterator.next());
    assertEquals((Integer) 100, iterator.next());
    assertEquals((Integer) 101, iterator.next());
    assertEquals((Integer) 3, iterator.next());
}
Example 87
Project: n_e_b_u_l_a-master  File: SimpleTest.java View source code
public void testSimple() {
    // arrange
    @SuppressWarnings("unchecked") Iterator<String> i = (Iterator<String>) mock(Iterator.class);
    when(i.next()).thenReturn("Hello").thenReturn("World");
    // act
    String result = i.next() + " " + i.next();
    // verify
    verify(i, times(2)).next();
    // assert
    assertEquals("Hello World", result);
}
Example 88
Project: olca-modules-master  File: OpOr.java View source code
@Override
public Object evaluate(Scope context) throws ExpressionException {
    boolean result = false;
    Iterator<?> argIt = arguments.iterator();
    while (argIt.hasNext()) {
        result = result || ((Boolean) ((Expression) argIt.next()).evaluate(context)).booleanValue();
        if (result)
            return Boolean.TRUE;
    }
    if (result)
        return Boolean.TRUE;
    return Boolean.FALSE;
}
Example 89
Project: openbel-framework-experimental  File: TestUtilities.java View source code
public static <E> E randomElement(final Collection<E> c) {
    if (noItems(c)) {
        return null;
    }
    final int size = c.size();
    final int randomIndex = new Random().nextInt(size);
    final Iterator<E> it = c.iterator();
    int i = 0;
    while (it.hasNext()) {
        if (i == randomIndex) {
            return it.next();
        }
        i++;
    }
    return null;
}
Example 90
Project: oripa-master  File: CreasePatternTest.java View source code
@Test
public void testIteratorRemove() {
    final int paperSize = 400;
    CreasePattern cp = new CreasePattern(paperSize);
    cp.add(new OriLine(0.0, 0.0, 100.0, 100.0, OriLine.TYPE_RIDGE));
    cp.add(new OriLine(10.0, 10.0, 100.0, 100.0, OriLine.TYPE_RIDGE));
    cp.add(new OriLine(20.0, 20.0, 100.0, 100.0, OriLine.TYPE_RIDGE));
    for (Iterator<OriLine> iter = cp.iterator(); iter.hasNext(); ) {
        OriLine oriLine = iter.next();
        iter.remove();
    }
    assertTrue(cp.isEmpty());
}
Example 91
Project: Phenex-master  File: Collections.java View source code
public static String join(Collection<?> collection, String separator) {
    final Iterator<?> iterator = collection.iterator();
    final StringBuffer buffer = new StringBuffer();
    while (iterator.hasNext()) {
        final Object next = iterator.next();
        if (next != null) {
            buffer.append(next);
            if (iterator.hasNext())
                buffer.append(separator);
        }
    }
    return buffer.toString();
}
Example 92
Project: picard-master  File: Iterators.java View source code
public static <E> AtomicIterator<E> atomicIteratorOf(final Iterator<E> backingIterator) {
    final Object monitor = new Object();
    return new AtomicIterator<E>() {

        @Override
        public Optional<E> next() {
            synchronized (monitor) {
                return backingIterator.hasNext() ? Optional.fromNullable(backingIterator.next()) : Optional.<E>absent();
            }
        }
    };
}
Example 93
Project: playtrd-master  File: EClassNameBinderFactory.java View source code
protected IBinder createBinder(EClass eClass) {
    List<EClass> superTypes = new ArrayList<EClass>(eClass.getEAllSuperTypes());
    superTypes.add(0, eClass);
    for (Iterator<EClass> it = superTypes.iterator(); it.hasNext(); ) {
        EClass superClass = it.next();
        IBinder binder = super.createBinder(superClass);
        if (binder != null) {
            return binder;
        }
    }
    return null;
}
Example 94
Project: plexus-io-master  File: PlexusIoFileSupplierResourceCollectionTest.java View source code
public void testGetName() throws Exception {
    PlexusIoFileResourceCollection coll = new PlexusIoFileResourceCollection();
    char nonSeparator = File.separatorChar == '/' ? '\\' : '/';
    coll.setPrefix("fud" + nonSeparator);
    coll.setBaseDir(new File("src/test/resources/symlinks"));
    final Iterator<PlexusIoResource> resources = coll.getResources();
    while (resources.hasNext()) {
        final PlexusIoResource next = resources.next();
        final String name = coll.getName(next);
        assertTrue(name.indexOf(nonSeparator) < 0);
    }
}
Example 95
Project: polly-master  File: AbstractLogOutput.java View source code
public String formatLogs(List<LogEntry> logs, LogFormatter formatter, FormatManager pollyFormat) {
    StringWriter string = new StringWriter();
    PrintWriter pw = new PrintWriter(string);
    Iterator<LogEntry> it = logs.iterator();
    while (it.hasNext()) {
        LogEntry log = it.next();
        pw.print(formatter.formatLog(log, pollyFormat));
        if (it.hasNext()) {
            pw.println();
        }
    }
    return string.toString();
}
Example 96
Project: Prefuse-master  File: SortedTupleIterator.java View source code
/**
     * Initialize this iterator for the given source iterator and
     * comparator.
     * @param iter the source iterator of tuples
     * @param c the comparator to use for sorting
     */
public void init(Iterator iter, Comparator c) {
    m_tuples.clear();
    m_cmp = c;
    // populate tuple list
    while (iter.hasNext()) {
        Tuple t = (Tuple) iter.next();
        m_tuples.add(t);
    }
    // sort tuple list
    Collections.sort(m_tuples, m_cmp);
    // create sorted iterator
    m_iter = m_tuples.iterator();
}
Example 97
Project: Progression-master  File: CommandPotions.java View source code
@Override
public boolean processCommand(ICommandSender sender, String[] parameters) {
    try {
        StringBuilder builder = new StringBuilder();
        Iterator<Potion> it = Potion.REGISTRY.iterator();
        while (it.hasNext()) {
            builder.append(it.next().getRegistryName() + "\n");
        }
        PrintWriter writer = new PrintWriter("potions.log", "UTF-8");
        writer.write(builder.toString());
        writer.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return true;
}
Example 98
Project: ProjectAres-master  File: RocketTask.java View source code
@Override
public void run() {
    for (Iterator<Rocket> it = Gizmos.rocketGizmo.rockets.iterator(); it.hasNext(); ) {
        Rocket rocket = it.next();
        if (rocket.allFireworksAlive()) {
            Vector center = rocket.getCenter();
            Vector delta = center.clone().subtract(rocket.getPreviousCenter());
            RocketUtils.fakeDelta(rocket.getObserver(), rocket.getVictim(), delta);
            rocket.setPreviousCenter(center);
        } else {
            rocket.getObserver().hidePlayer(rocket.getVictim());
            it.remove();
        }
    }
}
Example 99
Project: Quaere-master  File: Repeater.java View source code
public Iterator<T> iterator() {
    return new Iterator<T>() {

        private int index = 0;

        public boolean hasNext() {
            return index < repititions;
        }

        public T next() {
            if (index >= repititions)
                throw new ArrayIndexOutOfBoundsException();
            index++;
            return value;
        }

        public void remove() {
            throw new UnsupportedOperationException();
        }
    };
}
Example 100
Project: ShadowsOfPhysis-master  File: CompatThaumcraft.java View source code
@Override
public void initEnd(FMLInitializationEvent event, boolean client) {
    thaumcraftRecipeList = new RecipeListGetter() {

        @Override
        public Iterator<?> getIterator() {
            return ThaumcraftApi.getCraftingRecipes().listIterator();
        }
    };
    RecipeHelper.registerRecipeListGetter(thaumcraftRecipeList);
    RecipeHelper.addRecipeComponentTranslator(thaumcraftRecipeList, ShapedArcaneRecipe.class, new ShapedArcaneRecipeCT());
}
Example 101
Project: SikuliX-2014-master  File: IDESupport.java View source code
public static void initIDESupport() {
    ServiceLoader<IIDESupport> sloader = ServiceLoader.load(IIDESupport.class);
    Iterator<IIDESupport> supIterator = sloader.iterator();
    while (supIterator.hasNext()) {
        IIDESupport current = supIterator.next();
        try {
            for (String ending : current.getEndings()) {
                ideSupporter.put(ending, current);
            }
        } catch (Exception ex) {
        }
    }
}