Java Code Examples for java.util.ListIterator
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project collections-generic, under directory /src/test/org/apache/commons/collections15/iterators/.
Source file: AbstractTestListIterator.java

public void testRemoveThenSet(){ ListIterator it=makeFullListIterator(); if (supportsRemove() && supportsSet()) { it.next(); it.remove(); try { it.set(addSetValue()); fail("IllegalStateException must be thrown from set after remove"); } catch ( IllegalStateException e) { } } }
Example 2
From project core_5, under directory /exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/diff/.
Source file: RevisionImpl.java

public synchronized void applyTo(List target) throws Exception { ListIterator i=deltas_.listIterator(deltas_.size()); while (i.hasPrevious()) { Delta delta=(Delta)i.previous(); delta.patch(target); } }
Example 3
From project freemind, under directory /freemind/accessories/plugins/.
Source file: SplitNode.java

public void invoke(MindMapNode node){ super.invoke(node); final List list=getMindMapController().getSelecteds(); final ListIterator listIterator=list.listIterator(); while (listIterator.hasNext()) { MindMapNode next=(MindMapNode)listIterator.next(); splitNode(next); } }
Example 4
From project fits_1, under directory /src/edu/harvard/hul/ois/fits/consolidation/.
Source file: OISConsolidator.java

private List<FitsIdentitySection> consolidateIdentities(List<FileIdentity> identities){ List<FitsIdentitySection> consolidatedIdentities=new ArrayList<FitsIdentitySection>(); for ( FileIdentity ident : identities) { ListIterator iter=consolidatedIdentities.listIterator(); boolean anyMatches=false; boolean formatTreeMatch=false; while (iter.hasNext()) { FitsIdentitySection identitySection=(FitsIdentitySection)iter.next(); if (identitiesMatch(ident,identitySection)) { mergeExternalIdentifiers(ident,identitySection); mergeFormatVersions(ident,identitySection); identitySection.addReportingTool(ident.getToolInfo()); anyMatches=true; break; } else { int matchCondition=checkFormatTree(ident,identitySection); if (matchCondition == -1) { FitsIdentitySection newSection=new FitsIdentitySection(ident); iter.previous(); iter.add(newSection); iter.next(); iter.remove(); anyMatches=true; break; } else if (matchCondition == 1) { formatTreeMatch=true; } else { } } } if (!anyMatches && !formatTreeMatch) { iter.add(new FitsIdentitySection(ident)); } } return consolidatedIdentities; }
Example 5
From project aether-core, under directory /aether-impl/src/main/java/org/eclipse/aether/internal/impl/.
Source file: DefaultLocalRepositoryProvider.java

public LocalRepositoryManager newLocalRepositoryManager(LocalRepository localRepository) throws NoLocalRepositoryManagerException { List<LocalRepositoryManagerFactory> factories=new ArrayList<LocalRepositoryManagerFactory>(managerFactories); Collections.sort(factories,COMPARATOR); for ( LocalRepositoryManagerFactory factory : factories) { try { LocalRepositoryManager manager=factory.newInstance(localRepository); if (logger.isDebugEnabled()) { StringBuilder buffer=new StringBuilder(256); buffer.append("Using manager ").append(manager.getClass().getSimpleName()); buffer.append(" with priority ").append(factory.getPriority()); buffer.append(" for ").append(localRepository.getBasedir()); logger.debug(buffer.toString()); } return manager; } catch ( NoLocalRepositoryManagerException e) { } } StringBuilder buffer=new StringBuilder(256); buffer.append("No manager available for local repository "); buffer.append(localRepository.getBasedir()); buffer.append(" of type ").append(localRepository.getContentType()); buffer.append(" using the available factories "); for (ListIterator<LocalRepositoryManagerFactory> it=factories.listIterator(); it.hasNext(); ) { LocalRepositoryManagerFactory factory=it.next(); buffer.append(factory.getClass().getSimpleName()); if (it.hasNext()) { buffer.append(", "); } } throw new NoLocalRepositoryManagerException(localRepository,buffer.toString()); }
Example 6
From project ALP, under directory /workspace/alp-reporter-fe/src/main/java/com/lohika/alp/reporter/fe/query/.
Source file: QueryParser.java

Query buildAST(Query rightmost,ListIterator<String> itr){ if (rightmost == null) { rightmost=buildExpression(itr.next()); itr.remove(); } if (itr.hasNext()) { Query exp=new Or(buildExpression(itr.next()),rightmost); itr.remove(); return buildAST(exp,itr); } else return rightmost; }
Example 7
From project AmDroid, under directory /httpclientandroidlib/src/ch/boye/httpclientandroidlib/impl/client/cache/.
Source file: CacheEntryUpdater.java

private void removeCacheHeadersThatMatchResponse(List<Header> cacheEntryHeaderList,HttpResponse response){ for ( Header responseHeader : response.getAllHeaders()) { ListIterator<Header> cacheEntryHeaderListIter=cacheEntryHeaderList.listIterator(); while (cacheEntryHeaderListIter.hasNext()) { String cacheEntryHeaderName=cacheEntryHeaderListIter.next().getName(); if (cacheEntryHeaderName.equals(responseHeader.getName())) { cacheEntryHeaderListIter.remove(); } } } }
Example 8
From project Amoeba-for-Aladdin, under directory /src/java/com/meidusa/amoeba/net/poolable/copy/.
Source file: CursorableLinkedList.java

/** * Returns a fail-fast ListIterator. * @see List#listIterator(int) */ public ListIterator listIterator(int index){ if (index < 0 || index > _size) { throw new IndexOutOfBoundsException(index + " < 0 or > " + _size); } return new ListIter(index); }
Example 9
From project amplafi-sworddance, under directory /src/main/java/com/sworddance/taskcontrol/.
Source file: ResourceLockManager.java

/** * Insert a lock for a subtask. NOtice that it is very dangerous to add a subtask lock * @param lock * @param insertionComparator */ private void addSubtaskLock(ResourceLock lock,Comparator<ResourceLock> insertionComparator){ PrioritizedTask task=(PrioritizedTask)lock.getTask(); List<ResourceLock> lockList=getResourceLockList(lock.getResourceName()); ListIterator<ResourceLock> iter; ResourceLock currentLock=null; boolean foundInsertPoint=false; for (iter=lockList.listIterator(); iter.hasNext(); ) { currentLock=iter.next(); PrioritizedTask currentTask=(PrioritizedTask)currentLock.getTask(); if (currentTask == task) { combineLocks(iter,lock,currentLock); return; } else if (((DependentPrioritizedTask)task).getParentTask() == currentTask) { foundInsertPoint=true; break; } } if (!foundInsertPoint) { throw new RuntimeException(lock + ":could not find a parent lock"); } if (!lock.isSubset(currentLock)) { throw new RuntimeException(lock + ": subtask not a subset of parent lock " + currentLock); } if (iter.hasNext()) { for (; iter.hasNext(); ) { currentLock=iter.next(); int compareValue=insertionComparator.compare(lock,currentLock); if (compareValue == 0) { combineLocks(iter,lock,currentLock); return; } else if (compareValue < 0) { iter.previous(); break; } } } iter.add(lock); }
Example 10
From project android_external_guava, under directory /src/com/google/common/collect/.
Source file: Iterables.java

private static <T>boolean removeIfFromRandomAccessList(List<T> list,Predicate<? super T> predicate){ int from=0; int to=0; for (; from < list.size(); from++) { T element=list.get(from); if (!predicate.apply(element)) { if (from > to) { list.set(to,element); } to++; } } ListIterator<T> iter=list.listIterator(list.size()); for (int idx=from - to; idx > 0; idx--) { iter.previous(); iter.remove(); } return from != to; }
Example 11
From project ANNIS, under directory /annis-service/src/main/java/annis/dao/.
Source file: ResolverDaoHelper.java

@Override public List<ResolverEntry> extractData(ResultSet rs) throws SQLException, DataAccessException { List<ResolverEntry> result=new LinkedList<ResolverEntry>(); Set<RemoveIndexElement> removeEntries=new HashSet<RemoveIndexElement>(); while (rs.next()) { Properties mappings=new Properties(); String mappingsAsString=rs.getString("mappings"); if (mappingsAsString != null) { String[] entries=mappingsAsString.split(";"); for ( String e : entries) { String[] keyvalue=e.split(":",2); if (keyvalue.length == 2) { mappings.put(keyvalue[0].trim(),keyvalue[1].trim()); } } } String element=rs.getString("element"); ResolverEntry e=new ResolverEntry(rs.getLong("id"),rs.getString("corpus"),rs.getString("version"),rs.getString("namespace"),element == null ? null : ResolverEntry.ElementType.valueOf(element),rs.getString("vis_type"),rs.getString("display_name"),rs.getString("visibility"),mappings,rs.getInt("order")); if ("removed".equals(e.getVisibility())) { RemoveIndexElement r=new RemoveIndexElement(e); removeEntries.add(r); } else { result.add(e); } } ListIterator<ResolverEntry> it=result.listIterator(); while (it.hasNext()) { ResolverEntry entry=it.next(); RemoveIndexElement idx=new RemoveIndexElement(entry); if (removeEntries.contains(idx)) { it.remove(); } } return result; }
Example 12
String setExpandedList(List<String> list){ String value=""; if (list != null && !list.isEmpty()) { for (ListIterator<String> it=list.listIterator(); it.hasNext(); ) { String s=it.next(); final String v=expand(s); if (!v.equals(s)) { it.set(v); } } value=listToString(list); } return value; }
Example 13
From project archaius, under directory /archaius-core/src/main/java/com/netflix/config/.
Source file: ConcurrentCompositeConfiguration.java

/** * Get a List of objects associated with the given configuration key. If the key doesn't map to an existing object, the default value is returned. * @param key The configuration key. * @param defaultValue The default value. * @return The associated List of value. */ @Override public List getList(String key,List defaultValue){ List<Object> list=new ArrayList<Object>(); Iterator<AbstractConfiguration> it=configList.iterator(); if (overrideProperties.containsKey(key)) { appendListProperty(list,overrideProperties,key); } while (it.hasNext() && list.isEmpty()) { Configuration config=it.next(); if ((config != containerConfiguration || containerConfigurationChanged) && config.containsKey(key)) { appendListProperty(list,config,key); } } if (list.isEmpty()) { appendListProperty(list,containerConfiguration,key); } if (list.isEmpty()) { return defaultValue; } ListIterator<Object> lit=list.listIterator(); while (lit.hasNext()) { lit.set(interpolate(lit.next())); } return list; }
Example 14
From project ardverk-commons, under directory /src/main/java/org/ardverk/collection/.
Source file: ZipperList.java

@Override public ListIterator<E> listIterator(){ return new ListIterator<E>(){ private final Iterator<E> it=iterator(); @Override public void add( E e){ ZipperList.this.add(e); } @Override public boolean hasNext(){ return it.hasNext(); } @Override public boolean hasPrevious(){ return false; } @Override public E next(){ return it.next(); } @Override public int nextIndex(){ throw new UnsupportedOperationException(); } @Override public E previous(){ throw new UnsupportedOperationException(); } @Override public int previousIndex(){ throw new UnsupportedOperationException(); } @Override public void remove(){ it.remove(); } @Override public void set( E e){ throw new UnsupportedOperationException(); } } ; }
Example 15
From project AuToBI, under directory /src/edu/cuny/qc/speech/AuToBI/util/.
Source file: AlignmentUtils.java

/** * Retrieves the next region in the list following a particular time. <p/> Returns null if there is no additional region before the time. * @param time the time * @param iter the list iterator * @return the first region that starts after the time. */ protected static Region getNextRegionBeforeTime(double time,ListIterator<Region> iter){ if (!iter.hasNext()) return null; Double epsilon=0.005; Region region=iter.next(); if (region.getStart() > time + epsilon) { iter.previous(); return null; } return region; }
Example 16
From project BBC-News-Reader, under directory /src/com/digitallizard/bbcnewsreader/.
Source file: ServiceManager.java

public void onServiceConnected(ComponentName className,IBinder service){ resourceServiceBound=true; resourceMessenger=new Messenger(service); sendMessageToService(ResourceService.MSG_REGISTER_CLIENT); ListIterator<Message> iterator=messageQueue.listIterator(); while (iterator.hasNext()) { sendMessageToService(iterator.next()); } messageQueue.clear(); }
Example 17
From project beanstalker, under directory /beanstalk-maven-plugin/src/main/java/br/com/ingenieux/mojo/beanstalk/version/.
Source file: RollbackVersionMojo.java

@Override protected Object executeInternal() throws MojoExecutionException, MojoFailureException { DescribeApplicationVersionsRequest describeApplicationVersionsRequest=new DescribeApplicationVersionsRequest().withApplicationName(applicationName); DescribeApplicationVersionsResult appVersions=getService().describeApplicationVersions(describeApplicationVersionsRequest); DescribeEnvironmentsRequest describeEnvironmentsRequest=new DescribeEnvironmentsRequest().withApplicationName(applicationName).withEnvironmentIds(environmentId).withEnvironmentNames(environmentName).withIncludeDeleted(false); DescribeEnvironmentsResult environments=getService().describeEnvironments(describeEnvironmentsRequest); List<ApplicationVersionDescription> appVersionList=new ArrayList<ApplicationVersionDescription>(appVersions.getApplicationVersions()); List<EnvironmentDescription> environmentList=environments.getEnvironments(); if (environmentList.isEmpty()) throw new MojoFailureException("No environments were found"); EnvironmentDescription d=environmentList.get(0); Collections.sort(appVersionList,new Comparator<ApplicationVersionDescription>(){ @Override public int compare( ApplicationVersionDescription o1, ApplicationVersionDescription o2){ return new CompareToBuilder().append(o1.getDateUpdated(),o2.getDateUpdated()).toComparison(); } } ); Collections.reverse(appVersionList); if (latestVersionInstead) { ApplicationVersionDescription latestVersionDescription=appVersionList.get(0); return changeToVersion(d,latestVersionDescription); } ListIterator<ApplicationVersionDescription> versionIterator=appVersionList.listIterator(); String curVersionLabel=d.getVersionLabel(); while (versionIterator.hasNext()) { ApplicationVersionDescription versionDescription=versionIterator.next(); String versionLabel=versionDescription.getVersionLabel(); if (curVersionLabel.equals(versionLabel) && versionIterator.hasNext()) { return changeToVersion(d,versionIterator.next()); } } throw new MojoFailureException("No previous version was found (current version: " + curVersionLabel); }
Example 18
From project blogActivity, under directory /src/com/slezica/tools/widget/.
Source file: FilterableAdapter.java

@Override protected FilterResults performFiltering(CharSequence constraintSeq){ ArrayList<ObjectType> filteredObjects; synchronized (mFilterLock) { if (!mOutOfSync && mLastFilter != null && mLastFilter.equals(constraintSeq)) return null; mOutOfSync=false; mLastFilter=constraintSeq; } synchronized (mObjects) { filteredObjects=new ArrayList<ObjectType>(mObjects); } if (constraintSeq == null) return resultsFromList(filteredObjects); ConstraintType constraint=prepareFilter(constraintSeq); ListIterator<ObjectType> it=filteredObjects.listIterator(); while (it.hasNext()) { ObjectType item=it.next(); if (!passesFilter(item,constraint)) it.remove(); } return resultsFromList(filteredObjects); }
Example 19
From project boilerpipe, under directory /boilerpipe-core/src/main/de/l3s/boilerpipe/extractors/.
Source file: CanolaExtractor.java

public boolean process(TextDocument doc) throws BoilerpipeProcessingException { List<TextBlock> textBlocks=doc.getTextBlocks(); boolean hasChanges=false; ListIterator<TextBlock> it=textBlocks.listIterator(); if (!it.hasNext()) { return false; } TextBlock prevBlock=TextBlock.EMPTY_START; TextBlock currentBlock=it.next(); TextBlock nextBlock=it.hasNext() ? it.next() : TextBlock.EMPTY_START; hasChanges=classify(prevBlock,currentBlock,nextBlock) | hasChanges; if (nextBlock != TextBlock.EMPTY_START) { while (it.hasNext()) { prevBlock=currentBlock; currentBlock=nextBlock; nextBlock=it.next(); hasChanges=classify(prevBlock,currentBlock,nextBlock) | hasChanges; } prevBlock=currentBlock; currentBlock=nextBlock; nextBlock=TextBlock.EMPTY_START; hasChanges=classify(prevBlock,currentBlock,nextBlock) | hasChanges; } return hasChanges; }
Example 20
From project boilerpipe_1, under directory /boilerpipe-core/src/main/de/l3s/boilerpipe/extractors/.
Source file: CanolaExtractor.java

public boolean process(TextDocument doc) throws BoilerpipeProcessingException { List<TextBlock> textBlocks=doc.getTextBlocks(); boolean hasChanges=false; ListIterator<TextBlock> it=textBlocks.listIterator(); if (!it.hasNext()) { return false; } TextBlock prevBlock=TextBlock.EMPTY_START; TextBlock currentBlock=it.next(); TextBlock nextBlock=it.hasNext() ? it.next() : TextBlock.EMPTY_START; hasChanges=classify(prevBlock,currentBlock,nextBlock) | hasChanges; if (nextBlock != TextBlock.EMPTY_START) { while (it.hasNext()) { prevBlock=currentBlock; currentBlock=nextBlock; nextBlock=it.next(); hasChanges=classify(prevBlock,currentBlock,nextBlock) | hasChanges; } prevBlock=currentBlock; currentBlock=nextBlock; nextBlock=TextBlock.EMPTY_START; hasChanges=classify(prevBlock,currentBlock,nextBlock) | hasChanges; } return hasChanges; }
Example 21
/** * Calculate coefficient of variation of last n results * @param anisotropyHistory list of anisotropy results, one result per iteration * @return coefficient of variation, which is standard deviation / mean. */ private double getVariance(Vector<Double> anisotropyHistory,final int n){ ListIterator<Double> iter=anisotropyHistory.listIterator(anisotropyHistory.size()); double sum=0; double sumSquares=0; int count=0; while (iter.hasPrevious()) { final double value=iter.previous(); sum+=value; count++; if (count >= n) break; } final double mean=sum / n; ListIterator<Double> itr=anisotropyHistory.listIterator(anisotropyHistory.size()); count=0; while (itr.hasPrevious()) { final double value=itr.previous(); final double a=value - mean; sumSquares+=a * a; count++; if (count >= n) break; } double stDev=Math.sqrt(sumSquares / n); double coeffVariation=stDev / mean; return coeffVariation; }
Example 22
From project brut.apktool, under directory /apktool-lib/src/main/java/brut/androlib/src/.
Source file: SmaliBuilder.java

private void buildFile(String fileName) throws AndrolibException, IOException { File inFile=new File(mSmaliDir,fileName); InputStream inStream=new FileInputStream(inFile); if (fileName.endsWith(".smali")) { mDexBuilder.addSmaliFile(inFile); return; } if (!fileName.endsWith(".java")) { LOGGER.warning("Unknown file type, ignoring: " + inFile); return; } StringBuilder out=new StringBuilder(); List<String> lines=IOUtils.readLines(inStream); if (!mDebug) { final String[] linesArray=lines.toArray(new String[0]); for (int i=2; i < linesArray.length - 2; i++) { out.append(linesArray[i]).append('\n'); } } else { lines.remove(lines.size() - 1); lines.remove(lines.size() - 1); ListIterator<String> it=lines.listIterator(2); out.append(".source \"").append(inFile.getName()).append("\"\n"); while (it.hasNext()) { String line=it.next().trim(); if (line.isEmpty() || line.charAt(0) == '#' || line.startsWith(".source")) { continue; } if (line.startsWith(".method ")) { it.previous(); DebugInjector.inject(it,out); continue; } out.append(line).append('\n'); } } mDexBuilder.addSmaliFile(IOUtils.toInputStream(out.toString()),fileName); }
Example 23
From project byteman, under directory /agent/src/main/java/org/jboss/byteman/rule/binding/.
Source file: Bindings.java

/** * lookup a binding in the list by name * @param name * @return the binding or null if no bidngin exists with the supplied name */ public Binding lookup(String name){ ListIterator<Binding> iterator=bindings.listIterator(); while (iterator.hasNext()) { Binding binding=iterator.next(); if (binding.getName().equals(name)) { return binding; } } return null; }
Example 24
From project c24-spring, under directory /c24-spring-integration/src/test/java/biz/c24/io/spring/integration/config/.
Source file: ValidatingSelectorTests.java

@Test public void testThrowingInvalid(){ Employee employee=new Employee(); employee.setSalutation("Mr"); employee.setFirstName("andy"); employee.setLastName("Acheson"); try { template.convertAndSend(exceptionThrowingInputChannel,employee); fail("Selector failed to throw exception on invalid message"); } catch ( MessageHandlingException ex) { assertThat(ex.getCause(),is(C24AggregatedMessageValidationException.class)); C24AggregatedMessageValidationException vEx=(C24AggregatedMessageValidationException)ex.getCause(); ListIterator<ValidationEvent> failures=vEx.getFailEvents(); int failureCount=0; while (failures.hasNext()) { failureCount++; failures.next(); } assertThat(failureCount,is(2)); } assertThat(validChannel.receive(1),is(nullValue())); assertThat(invalidChannel.receive(1),is(nullValue())); }
Example 25
From project capedwarf-blue, under directory /datastore/src/main/java/org/jboss/capedwarf/datastore/query/.
Source file: LazyListIterator.java

protected ListIterator<E> getDelegate(){ if (delegate == null) { synchronized (this) { if (delegate == null) { delegate=lazyList.getDelegate().listIterator(index); } } } return delegate; }
Example 26
From project Carolina-Digital-Repository, under directory /access/src/main/java/edu/unc/lib/dl/ui/model/response/.
Source file: HierarchicalBrowseResultResponse.java

public void removeContainersWithoutContents(){ ListIterator<BriefObjectMetadataBean> resultIt=this.getResultList().listIterator(this.getResultList().size()); while (resultIt.hasPrevious()) { BriefObjectMetadataBean briefObject=resultIt.previous(); if (briefObject.getChildCount() == 0 && searchSettings.isResourceTypeContainer(briefObject.getResourceType())) { if (this.matchingContainerPids != null && this.matchingContainerPids.contains(briefObject.getId())) { } else { resultIt.remove(); if (briefObject.getAncestorPath() != null && briefObject.getAncestorPath().getFacetTiers() != null) { for ( HierarchicalFacetTier facetTier : briefObject.getAncestorPath().getFacetTiers()) { String tierIdentifier=facetTier.getIdentifier(); Long count=this.subcontainerCounts.get(tierIdentifier); if (count != null) this.subcontainerCounts.put(tierIdentifier,count - 1); } } } } } }
Example 27
From project cascading, under directory /src/core/cascading/cascade/.
Source file: CascadeConnector.java

private void unwrapCompositeTaps(LinkedList<Tap> taps){ ListIterator<Tap> iterator=taps.listIterator(); while (iterator.hasNext()) { Tap tap=iterator.next(); if (tap instanceof CompositeTap) { iterator.remove(); Iterator<Tap> childTaps=((CompositeTap)tap).getChildTaps(); while (childTaps.hasNext()) { iterator.add(childTaps.next()); iterator.previous(); } } } }
Example 28
public Flow plan(Properties properties){ Map<String,Pipe> pipes=new HashMap<String,Pipe>(); Map<String,Tap> sources=new HashMap<String,Tap>(); Map<String,Tap> sinks=new HashMap<String,Tap>(); Pipe currentPipe=null; ListIterator<String[]> iterator=params.listIterator(); while (iterator.hasNext()) { String[] pair=iterator.next(); String key=pair[0]; String value=pair[1]; LOG.info("key: {}",key); Map<String,String> subParams=getSubParams(key,iterator); Factory factory=factoryMap.get(key); if (factory instanceof SourceFactory) { Tap tap=((TapFactory)factory).getTap(value,subParams); currentPipe=((TapFactory)factory).addAssembly(value,subParams,currentPipe); sources.put(currentPipe.getName(),tap); } else if (factory instanceof SinkFactory) { sinks.put(currentPipe.getName(),((TapFactory)factory).getTap(value,subParams)); currentPipe=((TapFactory)factory).addAssembly(value,subParams,currentPipe); } else { currentPipe=((PipeFactory)factory).addAssembly(value,subParams,pipes,currentPipe); } pipes.put(currentPipe.getName(),currentPipe); } if (sources.isEmpty()) throw new IllegalArgumentException("error: must have atleast one source"); if (sinks.isEmpty()) throw new IllegalArgumentException("error: must have one sink"); return new HadoopFlowConnector(properties).connect("multitool",sources,sinks,currentPipe); }
Example 29
From project Catroid-maven-playground, under directory /src/main/java/at/tugraz/ist/catroid/content/.
Source file: Sprite.java

private synchronized void startScript(Script s){ final Script script=s; Thread t=new Thread(new Runnable(){ public void run(){ script.run(); } } ); if (script instanceof WhenScript) { if (!activeScripts.containsKey(script)) { activeScripts.put(script,new LinkedList<Thread>()); activeScripts.get(script).add(t); activeThreads.put(t,true); } else { ListIterator<Thread> currentScriptThreads=activeScripts.get(script).listIterator(); while (currentScriptThreads.hasNext()) { Thread currentThread=currentScriptThreads.next(); activeThreads.put(currentThread,false); } activeScripts.get(script).clear(); activeScripts.get(script).add(t); activeThreads.put(t,true); } } t.start(); }
Example 30
From project chromattic, under directory /common/src/main/java/org/chromattic/common/collection/.
Source file: BufferingList.java

public ListIterator<E> listIterator(int index){ BufferingListIterator<E> iterator=new BufferingListIterator<E>(model); while (index-- > 0) { iterator.next(); } return iterator; }
Example 31
From project CircDesigNA, under directory /src/circdesigna/.
Source file: CircDesigNA_SharedUtils.java

public static void utilRemoveDuplicateSequences(ArrayList<DuplexClosingTarget> hairpinClosings){ ListIterator<DuplexClosingTarget> itr=hairpinClosings.listIterator(); big: while (itr.hasNext()) { DuplexClosingTarget seq=itr.next(); for ( DuplexClosingTarget q : hairpinClosings) { if (q != seq && q.equals(seq)) { for (int i=0; i < q.stemAndOpening.length; i++) { q.stemAndOpening[i].appendMoleculeNames(seq.stemAndOpening[i]); } itr.remove(); continue big; } } } }
Example 32
From project clj-ds, under directory /src/main/java/com/trifork/clj_ds/.
Source file: APersistentVector.java

public ListIterator<T> listIterator(final int index){ return new ListIterator<T>(){ int nexti=index; public boolean hasNext(){ return nexti < count(); } public T next(){ return nth(nexti++); } public boolean hasPrevious(){ return nexti > 0; } public T previous(){ return nth(--nexti); } public int nextIndex(){ return nexti; } public int previousIndex(){ return nexti - 1; } public void remove(){ throw new UnsupportedOperationException(); } public void set( Object o){ throw new UnsupportedOperationException(); } public void add( Object o){ throw new UnsupportedOperationException(); } } ; }
Example 33
From project cocos2d, under directory /cocos2d-android/src/org/cocos2d/layers/.
Source file: CCTMXTiledMap.java

private CCTMXTilesetInfo tilesetForLayer(CCTMXLayerInfo layerInfo,CCTMXMapInfo mapInfo){ CCTMXTilesetInfo tileset=null; CGSize size=layerInfo.layerSize; ListIterator<CCTMXTilesetInfo> iter=mapInfo.tilesets.listIterator(mapInfo.tilesets.size()); while (iter.hasPrevious()) { tileset=iter.previous(); for (int y=0; y < size.height; y++) { for (int x=0; x < size.width; x++) { int pos=(int)(x + size.width * y); int gid=layerInfo.tiles.get(pos); gid=CCFormatter.swapIntToLittleEndian(gid); if (gid != 0) { if (gid >= tileset.firstGid) return tileset; } } } } ccMacros.CCLOG(LOG_TAG,"cocos2d: Warning: TMX Layer '" + layerInfo.name + "' has no tiles"); return tileset; }
Example 34
/** * TODO This could be made to look a lot better. */ public void drawPopular(){ CopyOnWriteArrayList<FileNode> al=new CopyOnWriteArrayList<FileNode>(); noStroke(); textFont(font); textAlign(RIGHT,TOP); fill(fontColor,200); text("Popular Nodes (touches):",width - 120,0); for ( FileNode fn : nodes.values()) { if (fn.qualifies()) { if (al.size() > 0) { int j=0; for (; j < al.size(); j++) { if (fn.compareTo(al.get(j)) <= 0) { continue; } else { break; } } al.add(j,fn); } else { al.add(fn); } } } int i=1; ListIterator<FileNode> it=al.listIterator(); while (it.hasNext()) { FileNode n=it.next(); if (i <= 10) { text(n.name + " (" + n.touches+ ")",width - 100,10 * i++); } else if (i > 10) { break; } } }
Example 35
/** * TODO This could be made to look a lot better. */ public void drawPopular(){ CopyOnWriteArrayList<FileNode> al=new CopyOnWriteArrayList<FileNode>(); noStroke(); textFont(font); textAlign(RIGHT,TOP); fill(fontColor,200); text("Popular Nodes (touches):",width - 120,0); for ( FileNode fn : nodes.values()) { if (fn.qualifies()) { if (al.size() > 0) { int j=0; for (; j < al.size(); j++) { if (fn.compareTo(al.get(j)) <= 0) { continue; } else { break; } } al.add(j,fn); } else { al.add(fn); } } } int i=1; ListIterator<FileNode> it=al.listIterator(); while (it.hasNext()) { FileNode n=it.next(); if (i <= 10) { text(n.name + " (" + n.touches+ ")",width - 100,10 * i++); } else if (i > 10) { break; } } }
Example 36
From project com.idega.content, under directory /src/java/com/idega/content/presentation/.
Source file: ContentItemListViewer.java

protected void initializeInEncodeBegin(){ notifyManagedBeanOfVariableValues(); ContentListViewerManagedBean bean=getManagedBean(); if (bean != null) { ContentItemViewer viewer=bean.getContentViewer(); viewer.setShowRequestedItem(false); addContentItemViewer(viewer); String[] actions=isShowToolbar() ? getToolbarActions() : null; if (actions != null && actions.length > 0) { ContentItemToolbar toolbar=new ContentItemToolbar(true); toolbar.setContainerId(this.getId()); toolbar.setMenuStyleClass(toolbar.getMenuStyleClass() + " " + toolbar.getMenuStyleClass()+ "_top"); for (int i=0; i < actions.length; i++) { toolbar.addToolbarButton(actions[i]); } String categories=this.getCategories(); if (categories != null) { toolbar.setCategories(categories); } String basePath=getBaseFolderPath(); if (basePath != null) { toolbar.setBaseFolderPath(basePath); } toolbar.setActionHandlerIdentifier(bean.getIWActionURIHandlerIdentifier()); this.setHeader(toolbar); } List attachementViewers=bean.getAttachmentViewers(); if (attachementViewers != null) { for (ListIterator iter=attachementViewers.listIterator(); iter.hasNext(); ) { ContentItemViewer attachmentViewer=(ContentItemViewer)iter.next(); int index=iter.nextIndex(); addAttachmentViewer(attachmentViewer,index); } } this.initialized=true; } }
Example 37
From project cometd, under directory /cometd-java/cometd-java-server/src/main/java/org/cometd/server/.
Source file: BayeuxServerImpl.java

protected boolean extendSend(ServerSession from,ServerSession to,Mutable message){ if (message.isMeta()) { ListIterator<Extension> i=_extensions.listIterator(); while (i.hasNext()) i.next(); while (i.hasPrevious()) { final Extension extension=i.previous(); if (!notifySendMeta(extension,to,message)) { debug("Extension {} interrupted message processing for {}",extension,message); return false; } } } else { ListIterator<Extension> i=_extensions.listIterator(); while (i.hasNext()) i.next(); while (i.hasPrevious()) { final Extension extension=i.previous(); if (!notifySend(extension,from,to,message)) { debug("Extension {} interrupted message processing for {}",extension,message); return false; } } } debug("< {}",message); return true; }
Example 38
From project commons-pool, under directory /src/java/org/apache/commons/pool/impl/.
Source file: CursorableLinkedList.java

/** * Returns a fail-fast ListIterator. * @see List#listIterator(int) */ public ListIterator listIterator(int index){ if (index < 0 || index > _size) { throw new IndexOutOfBoundsException(index + " < 0 or > " + _size); } return new ListIter(index); }
Example 39
From project Core_2, under directory /shell/src/main/java/org/jboss/forge/shell/console/jline/console/.
Source file: ConsoleReader.java

public int searchBackwards(final String searchTerm,final int startIndex,final boolean startsWith){ ListIterator<org.jboss.forge.shell.console.jline.console.history.History.Entry> it=history.entries(startIndex); while (it.hasPrevious()) { org.jboss.forge.shell.console.jline.console.history.History.Entry e=it.previous(); if (startsWith) { if (e.value().toString().startsWith(searchTerm)) { return e.index(); } } else { if (e.value().toString().contains(searchTerm)) { return e.index(); } } } return -1; }
Example 40
/** * Returns a list of all queue names on this server. Effectively, this means all databases that have a RQS design document. <p> Note that this method is inefficient when there is a large number of databases on the server, as it takes the list of all databases and checks each one separately. * @see #isQueue(java.lang.String) * @throws RQSException wraps any exception thrown by the underlying CouchDB layer */ public List<String> listQueues() throws RQSException { ArrayList<String> dbNames; try { dbNames=couchDB.allDbs(); } catch ( Exception e) { throw new RQSException(e); } ListIterator<String> lit=dbNames.listIterator(); while (lit.hasNext()) { String queueName=lit.next(); if (!isQueue(queueName)) lit.remove(); } return dbNames; }
Example 41
From project CraftBay, under directory /src/edu/self/startux/craftBay/locale/.
Source file: Message.java

private void filterEscapes(){ ListIterator<Object> iter=tokens.listIterator(); while (iter.hasNext()) { Object o=iter.next(); if (!(o instanceof String)) continue; iter.remove(); String string=(String)o; Pattern pattern=Pattern.compile("\\\\(.)"); Matcher matcher=pattern.matcher(string); int lastIndex=0; while (matcher.find()) { iter.add(string.substring(lastIndex,matcher.start())); iter.add(matcher.group(1)); lastIndex=matcher.end(); } iter.add(string.substring(lastIndex,string.length())); } }
Example 42
From project Cyborg, under directory /src/main/java/com/alta189/cyborg/api/event/.
Source file: HandlerList.java

public void unregister(Object plugin){ boolean changed=false; for ( List<ListenerRegistration> list : handlerslots.values()) { for (ListIterator<ListenerRegistration> i=list.listIterator(); i.hasNext(); ) { if (i.next().getOwner().equals(plugin)) { i.remove(); changed=true; } } } if (changed) { handlers=null; } }
Example 43
From project Diver, under directory /ca.uvic.chisel.javasketch/src/ca/uvic/chisel/javasketch/persistence/internal/.
Source file: PersistTraceJob.java

/** * @param eventStack * @param callEventStack * @param event * @throws SQLException * @throws CoreException */ private void processPause(LinkedList<TraceModelEvent> eventStack,List<MethodEnterEvent> callEventStack,PauseEvent event) throws CoreException, SQLException { if (event.stackTrace == null) { return; } int thread_id=(Integer)eventStack.getFirst().getDecoration("thread_id"); queryUtils.createEvent(event.time,"PAUSE IN THREAD " + thread_id); if (callEventStack.size() <= 0) return; ListIterator<MethodEnterEvent> iterator=callEventStack.listIterator(callEventStack.size()); LinkedList<MethodExitEvent> exitEvents=new LinkedList<MethodExitEvent>(); while (iterator.hasPrevious()) { MethodEnterEvent topEvent=iterator.previous(); MethodExitEvent exitEvent=topEvent.simulateExit(event.time); exitEvents.addFirst(exitEvent); } while (exitEvents.size() > 0) { processExit(eventStack,callEventStack,exitEvents.removeLast()); } queryUtils.commit(); }
Example 44
From project droidgiro-android, under directory /src/se/droidgiro/scanner/.
Source file: Scanner.java

/** * Composes a single bitmap from a list of bitmaps. * @param bmpList The list of bitmaps. * @param vertical True if bitmaps should be appended vertically. * @return The composed bitmap. */ protected Bitmap composeFromBitmapList(List<Bitmap> bmpList,boolean vertical){ Bitmap measureBmp=bmpList.get(0); int toWidth=measureBmp.getWidth(); int toHeight=measureBmp.getHeight(); Bitmap resultBmp; Bitmap.Config config=Bitmap.Config.RGB_565; if (vertical) { resultBmp=Bitmap.createBitmap(toWidth,toHeight * bmpList.size(),config); } else { resultBmp=Bitmap.createBitmap(toWidth * bmpList.size(),toHeight,config); } Canvas canvas=new Canvas(resultBmp); ListIterator<Bitmap> bmpIterator=bmpList.listIterator(); int i=0; while (bmpIterator.hasNext()) { Bitmap bmp=bmpIterator.next(); Rect srcRect=new Rect(0,0,bmp.getWidth(),bmp.getHeight()); Rect dstRect=new Rect(srcRect); if (i != 0) { if (vertical) { dstRect.offset(0,i * bmp.getHeight()); } else { dstRect.offset(i * bmp.getWidth(),0); } } i++; canvas.drawBitmap(bmp,srcRect,dstRect,null); } return resultBmp; }
Example 45
From project drools-planner, under directory /drools-planner-core/src/main/java/org/drools/planner/core/heuristic/selector/entity/decorator/.
Source file: CachingEntitySelector.java

public ListIterator<Object> listIterator(){ if (!randomSelection) { return cachedEntityList.listIterator(); } else { throw new IllegalStateException("The selector (" + this + ") does not support a ListIterator with randomSelection ("+ randomSelection+ ")."); } }
Example 46
From project droolsjbpm-integration, under directory /drools-simulator/src/main/java/org/drools/fluent/session/impl/.
Source file: DefaultStatefulKnowledgeSessionSimFluent.java

private void insertFireRuleCounter(SimulationStep activeStep,FiredRuleCounter firedRuleCounter){ int lastFireAllRulesIndex=-1; List<Command> commands=activeStep.getCommands(); for (ListIterator<Command> it=commands.listIterator(); it.hasNext(); ) { int i=it.nextIndex(); Command command=it.next(); if (command instanceof FireAllRulesCommand) { lastFireAllRulesIndex=i; } } if (lastFireAllRulesIndex < 0) { throw new IllegalArgumentException("Cannot assertRuleFired, because in this step, fireAllRules() hasn't been called yet."); } commands.add(lastFireAllRulesIndex,new AddEventListenerCommand(firedRuleCounter)); }
Example 47
From project drugis-common, under directory /common-lib/src/test/java/org/drugis/common/beans/.
Source file: SortedSetModelTest.java

@Test public void testRemoving(){ assertTrue(d_filledList.remove("Daan")); assertEquals(Arrays.asList("Gert","Margreth"),d_filledList); assertEquals("Gert",d_filledList.remove(0)); assertEquals(Arrays.asList("Margreth"),d_filledList); resetFilledList(); d_filledList.clear(); assertEquals(Collections.emptyList(),d_filledList); resetFilledList(); ListIterator<String> it=d_filledList.listIterator(); int i=0; while (it.hasNext()) { it.next(); if (i % 2 == 0) { it.remove(); } ++i; } assertEquals(Collections.singletonList("Gert"),d_filledList); }
Example 48
From project Empire, under directory /core/src/com/clarkparsia/empire/ds/impl/.
Source file: TransactionalDataSource.java

/** * @inheritDoc */ public void rollback() throws DataSourceException { assertInTransaction(); try { for (ListIterator<TransactionOp> it=mTransactionOps.listIterator(mTransactionOps.size()); it.hasPrevious(); ) { TransactionOp op=it.previous(); if (op.isAdded()) { mDataSource.remove(op.getData()); } else { mDataSource.add(op.getData()); } } } catch ( DataSourceException e) { throw new DataSourceException("Rollback failed, database is likely to be in an inconsistent state.",e); } finally { mIsInTransaction=false; mTransactionOps.clear(); } }
Example 49
From project erjang, under directory /src/main/java/erjang/beam/loader/.
Source file: Rewriter.java

public void rewriteFunctionBody(List<Insn> body,FunctionInfo sig){ ListIterator<Insn> it=body.listIterator(); while (it.hasNext()) { final Insn insn=it.next(); switch (insn.opcode()) { case call_fun: { int save_pos=savePos(it); boolean trigger=(it.hasNext() && it.next().opcode() == BeamOpcode.deallocate && it.hasNext() && it.next().opcode() == BeamOpcode.K_return); restorePos(it,save_pos); if (trigger) { Insn.I old=(Insn.I)insn; it.set(new Insn.I(BeamOpcode.i_call_fun_last,old.i1)); it.next(); it.remove(); it.next(); it.remove(); } } } } }
Example 50
From project exo-training, under directory /gxt-showcase/src/main/java/com/sencha/gxt/desktopapp/client/spreadsheet/.
Source file: Worksheet.java

protected void adjustCellReferences(Operation operation,Location location,int index,Row row){ int columnCount=getColumnCount(); ListIterator<String> iterator=row.getColumns().listIterator(); for (int columnIndex=0; columnIndex < columnCount; columnIndex++) { String value=iterator.next(); if (value.startsWith(Evaluator.EXPRESSION_MARKER)) { Evaluator evaluator=new Evaluator(value,this); value=evaluator.adjustCellReferences(operation,location,value,index); iterator.set(value); } } }
Example 51
From project fakereplace, under directory /plugins/seam2/src/main/java/org/fakereplace/integration/seam/.
Source file: ClassRedefinitionPlugin.java

/** * Fakereplace does not play nice with the hot deploy filter */ public void disableHotDeployFilter(){ try { Set<?> data=InstanceTracker.get(SeamFilter.class.getName()); for ( Object i : data) { Field filters=i.getClass().getDeclaredField("filters"); filters.setAccessible(true); List<?> filterList=(List<?>)filters.get(i); ListIterator<?> it=filterList.listIterator(); while (it.hasNext()) { Object val=it.next(); if (val instanceof HotDeployFilter) { log.info("Disabling seam hot deployment filter, it does not play nicely with fakereplace"); it.remove(); } } } } catch ( Exception e) { log.error("Unable to disable hot deploy filter",e); e.printStackTrace(); } }
Example 52
From project fitnesse, under directory /src/fitnesse/components/.
Source file: RecentChanges.java

private static void removeDuplicate(List<String> lines,String resource){ for (ListIterator<String> iterator=lines.listIterator(); iterator.hasNext(); ) { String s=iterator.next(); if (s.startsWith("|" + resource + "|")) iterator.remove(); } }
Example 53
From project flatpack-java, under directory /core/src/main/java/com/getperka/flatpack/util/.
Source file: FlatPackTypes.java

private static Type replaceTypes(Map<Type,Type> replacements,Type toReplace){ List<Type> flat=flatten(toReplace); for (ListIterator<Type> it=flat.listIterator(); it.hasNext(); ) { Type type=it.next(); if (replacements.containsKey(type)) { it.set(replacements.get(type)); } } return createType(flat); }
Example 54
From project FlipDroid, under directory /boilerpipe/src/main/java/de/l3s/boilerpipe/extractors/.
Source file: CanolaExtractor.java

public boolean process(TextDocument doc) throws BoilerpipeProcessingException { List<TextBlock> textBlocks=doc.getTextBlocks(); boolean hasChanges=false; ListIterator<TextBlock> it=textBlocks.listIterator(); if (!it.hasNext()) { return false; } TextBlock prevBlock=TextBlock.EMPTY_START; TextBlock currentBlock=it.next(); TextBlock nextBlock=it.hasNext() ? it.next() : TextBlock.EMPTY_START; hasChanges=classify(prevBlock,currentBlock,nextBlock) | hasChanges; if (nextBlock != TextBlock.EMPTY_START) { while (it.hasNext()) { prevBlock=currentBlock; currentBlock=nextBlock; nextBlock=it.next(); hasChanges=classify(prevBlock,currentBlock,nextBlock) | hasChanges; } prevBlock=currentBlock; currentBlock=nextBlock; nextBlock=TextBlock.EMPTY_START; hasChanges=classify(prevBlock,currentBlock,nextBlock) | hasChanges; } return hasChanges; }
Example 55
From project floodlight, under directory /src/main/java/net/floodlightcontroller/packet/.
Source file: DHCP.java

/** * @return the packetType base on option 53 */ public DHCPPacketType getPacketType(){ ListIterator<DHCPOption> lit=options.listIterator(); while (lit.hasNext()) { DHCPOption option=lit.next(); if (option.getCode() == 53) { return DHCPPacketType.getType(option.getData()[0]); } } return null; }
Example 56
From project FML, under directory /client/cpw/mods/fml/client/.
Source file: TextureFXManager.java

public void pruneOldTextureFX(TexturePackBase var1,List<TextureFX> effects){ ListIterator<TextureFX> li=addedTextureFX.listIterator(); while (li.hasNext()) { TextureFX tex=li.next(); if (tex instanceof FMLTextureFX) { if (((FMLTextureFX)tex).unregister(client.field_71446_o,effects)) { li.remove(); } } else { effects.remove(tex); li.remove(); } } }
Example 57
From project formic, under directory /src/java/org/apache/commons/collections/iterators/.
Source file: UnmodifiableListIterator.java

/** * Decorates the specified iterator such that it cannot be modified. * @param iterator the iterator to decorate * @throws IllegalArgumentException if the iterator is null */ public static ListIterator decorate(ListIterator iterator){ if (iterator == null) { throw new IllegalArgumentException("ListIterator must not be null"); } if (iterator instanceof Unmodifiable) { return iterator; } return new UnmodifiableListIterator(iterator); }
Example 58
From project framework, under directory /impl/core/src/main/java/br/gov/frameworkdemoiselle/template/.
Source file: DelegateCrud.java

private void nonTransactionalDelete(final List<I> ids){ ListIterator<I> iter=ids.listIterator(); while (iter.hasNext()) { this.delete(iter.next()); } }