Java 类java.util.Iterator 实例源码
项目:lib-commons-httpclient
文件:HttpState.java
/**
* Find matching {@link Credentials credentials} for the given authentication scope.
*
* @param map the credentials hash map
* @param token the {@link AuthScope authentication scope}
* @return the credentials
*
*/
private static Credentials matchCredentials(final HashMap map, final AuthScope authscope) {
// see if we get a direct hit
Credentials creds = (Credentials)map.get(authscope);
if (creds == null) {
// Nope.
// Do a full scan
int bestMatchFactor = -1;
AuthScope bestMatch = null;
Iterator items = map.keySet().iterator();
while (items.hasNext()) {
AuthScope current = (AuthScope)items.next();
int factor = authscope.match(current);
if (factor > bestMatchFactor) {
bestMatchFactor = factor;
bestMatch = current;
}
}
if (bestMatch != null) {
creds = (Credentials)map.get(bestMatch);
}
}
return creds;
}
项目:JRediClients
文件:AbstractCacheMap.java
@Override
public Iterator<V> iterator() {
return new MapIterator<V>() {
@Override
public V next() {
if (mapEntry == null) {
throw new NoSuchElementException();
}
V value = readValue(mapEntry.getValue());
mapEntry = null;
return value;
}
@Override
public void remove() {
if (mapEntry == null) {
throw new IllegalStateException();
}
map.remove(mapEntry.getKey(), mapEntry.getValue());
mapEntry = null;
}
};
}
项目:boohee_v5.6
文件:Fallback.java
public synchronized void a(String[] strArr) {
for (int size = this.j.size() - 1; size >= 0; size--) {
for (CharSequence equals : strArr) {
if (TextUtils.equals(((e) this.j.get(size)).a, equals)) {
this.j.remove(size);
break;
}
}
}
Iterator it = this.j.iterator();
int i = 0;
while (it.hasNext()) {
e eVar = (e) it.next();
i = eVar.b > i ? eVar.b : i;
}
for (int i2 = 0; i2 < strArr.length; i2++) {
a(new e(strArr[i2], (strArr.length + i) - i2));
}
}
项目:rapidminer
文件:LibSVMLearner.java
/**
* Creates a support vector problem for the LibSVM.
*
* @throws UserError
*/
private svm_problem getProblem(ExampleSet exampleSet) throws UserError {
log("Creating LibSVM problem.");
FastExample2SparseTransform ripper = new FastExample2SparseTransform(exampleSet);
int nodeCount = 0;
svm_problem problem = new svm_problem();
problem.l = exampleSet.size();
problem.y = new double[exampleSet.size()];
problem.x = new svm_node[exampleSet.size()][];
Iterator<Example> i = exampleSet.iterator();
Attribute label = exampleSet.getAttributes().getLabel();
int j = 0;
while (i.hasNext()) {
Example e = i.next();
problem.x[j] = makeNodes(e, ripper);
problem.y[j] = e.getValue(label);
nodeCount += problem.x[j].length;
j++;
}
log("Created " + nodeCount + " nodes for " + j + " examples.");
return problem;
}
项目:common-services
文件:ServiceMessageHandlerTest.java
private ResultSet<String> createBlockingResultSet(BlockingQueue<String> queue, Supplier<Boolean> finished) {
AtomicReference<String> ref = new AtomicReference<>();
AtomicInteger sizeref = new AtomicInteger(0);
Iterator<String> blockingIterator = new Iterator<String>() {
@Override
public boolean hasNext() {
if (ref.get() != null) return true;
while (!finished.get()) {
if (ref.get() != null) return true;
try {
ref.set(queue.poll(1000, TimeUnit.MILLISECONDS));
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
return ref.get() != null;
}
@Override
public String next() {
sizeref.incrementAndGet();
return ref.getAndSet(null);
}
};
return createResultSet(blockingIterator);
}
项目:weak-semi-crf-naacl2016
文件:AttributedWord.java
@Override
public String toString(){
StringBuilder sb = new StringBuilder();
sb.append(this.getName());
Iterator<String> attNames = this._attrs.keySet().iterator();
while(attNames.hasNext()){
String attName = attNames.next();
ArrayList<String> attValues = this._attrs.get(attName);
sb.append("|");
sb.append(attName);
for(String attValue : attValues){
sb.append(":");
sb.append(attValue);
}
}
return sb.toString();
}
项目:dhus-core
文件:CheckIterator.java
/**
* Checks number of elements within a iterator.
* @param it iterator to check
* @param n number of elements found
* @return true if n equals elements number in iterator, otherwise false.
*/
public static boolean checkElementNumber (Iterator<?> it, int n)
{
int i = 0;
while (it.hasNext ())
{
if (it.next () == null)
{
return false;
}
i++;
}
return (i == n);
}
项目:guava-mock
文件:Hashing.java
/**
* Returns a hash code, having the same bit length as each of the input hash codes, that combines
* the information of these hash codes in an ordered fashion. That is, whenever two equal hash
* codes are produced by two calls to this method, it is <i>as likely as possible</i> that each
* was computed from the <i>same</i> input hash codes in the <i>same</i> order.
*
* @throws IllegalArgumentException if {@code hashCodes} is empty, or the hash codes do not all
* have the same bit length
*/
public static HashCode combineOrdered(Iterable<HashCode> hashCodes) {
Iterator<HashCode> iterator = hashCodes.iterator();
checkArgument(iterator.hasNext(), "Must be at least 1 hash code to combine.");
int bits = iterator.next().bits();
byte[] resultBytes = new byte[bits / 8];
for (HashCode hashCode : hashCodes) {
byte[] nextBytes = hashCode.asBytes();
checkArgument(
nextBytes.length == resultBytes.length, "All hashcodes must have the same bit length.");
for (int i = 0; i < nextBytes.length; i++) {
resultBytes[i] = (byte) (resultBytes[i] * 37 ^ nextBytes[i]);
}
}
return HashCode.fromBytesNoCopy(resultBytes);
}
项目:ctsms
文件:ProbandListEntryTagValueBean.java
public static void copyProbandListEntryTagValueOutToIn(ProbandListEntryTagValueInVO in, ProbandListEntryTagValueOutVO out) {
if (in != null && out != null) {
ProbandListEntryOutVO listEntryVO = out.getListEntry();
ProbandListEntryTagOutVO tagVO = out.getTag();
Collection<InputFieldSelectionSetValueOutVO> tagValueVOs = out.getSelectionValues();
in.setBooleanValue(out.getBooleanValue());
in.setDateValue(out.getDateValue());
in.setTimeValue(out.getTimeValue());
in.setFloatValue(out.getFloatValue());
in.setId(out.getId());
in.setListEntryId(listEntryVO == null ? null : listEntryVO.getId());
in.setLongValue(out.getLongValue());
ArrayList<Long> selectionValueIds = new ArrayList<Long>(tagValueVOs.size());
Iterator<InputFieldSelectionSetValueOutVO> tagValueVOsIt = tagValueVOs.iterator();
while (tagValueVOsIt.hasNext()) {
selectionValueIds.add(tagValueVOsIt.next().getId());
}
in.setSelectionValueIds(selectionValueIds);
in.setTagId(tagVO == null ? null : tagVO.getId());
in.setTextValue(out.getTextValue());
in.setTimestampValue(out.getTimestampValue());
in.setInkValues(out.getInkValues());
in.setVersion(out.getVersion());
}
}
项目:ctsms
文件:SearchServiceImpl.java
private static CriteriaOutVO obfuscateCriterions(CriteriaOutVO criteriaVO) {
if (criteriaVO != null) {
CriteriaOutVO result = new CriteriaOutVO(criteriaVO);
ArrayList<CriterionOutVO> obfuscatedCriterions = new ArrayList<CriterionOutVO>();
Iterator<CriterionOutVO> criterionsIt = criteriaVO.getCriterions().iterator();
while (criterionsIt.hasNext()) {
CriterionOutVO obfuscatedCriterion = new CriterionOutVO(criterionsIt.next());
obfuscatedCriterion.setCriteria(result);
CriterionPropertyVO property = obfuscatedCriterion.getProperty();
if (property != null && OmittedFields.isOmitted(property.getProperty())) {
obfuscatedCriterion.setStringValue(OmittedFields.OBFUSCATED_STRING);
}
obfuscatedCriterions.add(obfuscatedCriterion);
}
result.setCriterions(obfuscatedCriterions);
return result;
}
return null;
}
项目:cleaninsights-android-sdk
文件:TrackerBulkURLWrapper.java
/**
* page iterator
*
* @return iterator
*/
public Iterator<Page> iterator() {
return new Iterator<Page>() {
@Override
public boolean hasNext() {
return mCurrentPage < mPages;
}
@Override
public Page next() {
if (hasNext()) {
return new Page(mCurrentPage++);
}
return null;
}
@Override
public void remove() {
}
};
}
项目:kestrel
文件:VariantWriter.java
/**
* List any valid writers that can be found.
*
* @param loader Loader to search for classes. If <code>null</code>, the system class
* loader is used.
*
* @return A sorted list of writer names.
*/
public static String[] listWriters(URLClassLoader loader) {
// Create structures
Set<String> urlSet = SystemUtil.findSubPackages(PACKAGE_NAME, loader.getURLs(), true);
Iterator<String> setIter = urlSet.iterator();
while (setIter.hasNext()) {
String url = setIter.next();
try {
getWriterClass(url, loader);
} catch (Throwable ex) {
setIter.remove();
}
}
// Sort and return
String[] writers = urlSet.toArray(new String[0]);
Arrays.sort(writers);
return writers;
}
项目:Elasticsearch
文件:FieldNamesFieldMapper.java
@Override
public MetadataFieldMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
if (parserContext.indexVersionCreated().before(Version.V_1_3_0)) {
throw new IllegalArgumentException("type="+CONTENT_TYPE+" is not supported on indices created before version 1.3.0. Is your cluster running multiple datanode versions?");
}
Builder builder = new Builder(parserContext.mapperService().fullName(NAME));
if (parserContext.indexVersionCreated().before(Version.V_2_0_0_beta1)) {
parseField(builder, builder.name, node, parserContext);
}
for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
Map.Entry<String, Object> entry = iterator.next();
String fieldName = Strings.toUnderscoreCase(entry.getKey());
Object fieldNode = entry.getValue();
if (fieldName.equals("enabled")) {
builder.enabled(nodeBooleanValue(fieldNode));
iterator.remove();
}
}
return builder;
}
项目:HCFCore
文件:IteratorUtils.java
/**
* Executes the given closure on each but the last element in the iterator.
* <p>
* If the input iterator is null no change is made.
*
* @param <E> the type of object the {@link Iterator} contains
* @param iterator the iterator to get the input from, may be null
* @param closure the closure to perform, may not be null
* @return the last element in the iterator, or null if iterator is null or empty
* @throws NullPointerException if closure is null
* @since 4.1
*/
public static <E> E forEachButLast(final Iterator<E> iterator, final Closure<? super E> closure) {
if (closure == null) {
throw new NullPointerException("Closure must not be null.");
}
if (iterator != null) {
while (iterator.hasNext()) {
final E element = iterator.next();
if (iterator.hasNext()) {
closure.execute(element);
} else {
return element;
}
}
}
return null;
}
项目:soapbox-race-jlauncher
文件:Md5Files.java
public static boolean checkModules(String path) {
setFiles();
Iterator<Entry<String, byte[]>> iterator = filesToCheck.entrySet().iterator();
while (iterator.hasNext()) {
Entry<String, byte[]> next = iterator.next();
String filename = path.concat("/".concat(next.getKey()));
try {
byte[] createChecksum = createChecksum(filename);
if (!Arrays.equals(next.getValue(), createChecksum)) {
return false;
}
} catch (Exception e) {
return false;
}
}
return true;
}
项目:OpenJSharp
文件:InstructionList.java
/**
* @return Enumeration that lists all instructions (handles)
*/
public Iterator iterator() {
return new Iterator() {
private InstructionHandle ih = start;
public Object next() {
InstructionHandle i = ih;
ih = ih.next;
return i;
}
public void remove() {
throw new UnsupportedOperationException();
}
public boolean hasNext() { return ih != null; }
};
}
项目:openjdk-jdk10
文件:ArrayBlockingQueueTest.java
/**
* iterator.remove removes current element
*/
public void testIteratorRemove() {
final ArrayBlockingQueue q = new ArrayBlockingQueue(3);
q.add(two);
q.add(one);
q.add(three);
Iterator it = q.iterator();
it.next();
it.remove();
it = q.iterator();
assertSame(it.next(), one);
assertSame(it.next(), three);
assertFalse(it.hasNext());
}
项目:java-android-websocket-client
文件:AbstractConnPool.java
/**
* Enumerates all available connections.
*
* @since 4.3
*/
protected void enumAvailable(final PoolEntryCallback<T, C> callback) {
this.lock.lock();
try {
final Iterator<E> it = this.available.iterator();
while (it.hasNext()) {
final E entry = it.next();
callback.process(entry);
if (entry.isClosed()) {
final RouteSpecificPool<T, C, E> pool = getPool(entry.getRoute());
pool.remove(entry);
it.remove();
}
}
purgePoolMap();
} finally {
this.lock.unlock();
}
}
项目:monarch
文件:ClientHealthStats.java
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
buf.append("ClientHealthStats [");
buf.append("\n numOfGets=" + this.numOfGets);
buf.append("\n numOfPuts=" + this.numOfPuts);
buf.append("\n numOfMisses=" + this.numOfMisses);
buf.append("\n numOfCacheListenerCalls=" + this.numOfCacheListenerCalls);
buf.append("\n numOfThreads=" + this.numOfThreads);
buf.append("\n cpus=" + this.cpus);
buf.append("\n processCpuTime=" + this.processCpuTime);
buf.append("\n updateTime=" + this.updateTime);
Iterator<Entry<String, String>> it = this.poolStats.entrySet().iterator();
StringBuffer tempBuffer = new StringBuffer();
while (it.hasNext()) {
Entry<String, String> entry = it.next();
tempBuffer.append(entry.getKey() + " = " + entry.getValue());
}
buf.append("\n poolStats " + tempBuffer);
buf.append("\n]");
return buf.toString();
}
项目:sstore-soft
文件:TestMultiPartitionTxnFilter.java
/**
* testMultiPartition
*/
@Test
public void testMultiPartition() throws Exception {
MultiPartitionTxnFilter filter = new MultiPartitionTxnFilter(p_estimator, false);
Iterator<TransactionTrace> it = workload.iterator(filter);
assertNotNull(it);
int count = 0;
while (it.hasNext()) {
AbstractTraceElement<? extends CatalogType> element = it.next();
if (element instanceof TransactionTrace) {
// Make sure that this txn's base partition is what we expect it to be
TransactionTrace txn = (TransactionTrace)element;
partitions.clear();
p_estimator.getAllPartitions(partitions, txn);
assertNotNull(partitions);
assertNotSame(1, partitions.size());
count++;
}
} // WHILE
assert(count > 0);
}
项目:incubator-netbeans
文件:JDBCDriverConvertor.java
private static JDBCDriver readDriverFromFile(FileObject fo) throws IOException, MalformedURLException {
Handler handler = new Handler();
// parse the XM file
try {
XMLReader reader = XMLUtil.createXMLReader();
InputSource is = new InputSource(fo.getInputStream());
is.setSystemId(fo.toURL().toExternalForm());
reader.setContentHandler(handler);
reader.setErrorHandler(handler);
reader.setEntityResolver(EntityCatalog.getDefault());
reader.parse(is);
} catch (SAXException ex) {
throw new IOException(ex.getMessage());
}
// read the driver from the handler
URL[] urls = new URL[handler.urls.size()];
int j = 0;
for (Iterator i = handler.urls.iterator(); i.hasNext(); j++) {
urls[j] = new URL((String)i.next());
}
if (checkClassPathDrivers(handler.clazz, urls) == false) {
return null;
}
if (handler.displayName == null) {
handler.displayName = handler.name;
}
return JDBCDriver.create(handler.name, handler.displayName, handler.clazz, urls);
}
项目:JRediClients
文件:RedissonMapCacheReactiveTest.java
@Test
public void testKeyIterator() {
RMapReactive<Integer, Integer> map = redisson.getMapCache("simple");
sync(map.put(1, 0));
sync(map.put(3, 5));
sync(map.put(4, 6));
sync(map.put(7, 8));
List<Integer> keys = new ArrayList<Integer>(Arrays.asList(1, 3, 4, 7));
for (Iterator<Integer> iterator = toIterator(map.keyIterator()); iterator.hasNext();) {
Integer value = iterator.next();
if (!keys.remove(value)) {
Assert.fail();
}
}
Assert.assertEquals(0, keys.size());
}
项目:OpenJSharp
文件:CorbaMessageMediatorImpl.java
private byte getStreamFormatVersionForThisRequest(IOR ior,
GIOPVersion giopVersion)
{
byte localMaxVersion
= ORBUtility.getMaxStreamFormatVersion();
IOR effectiveTargetIOR =
((CorbaContactInfo)this.contactInfo).getEffectiveTargetIOR();
IIOPProfileTemplate temp =
(IIOPProfileTemplate)effectiveTargetIOR.getProfile().getTaggedProfileTemplate();
Iterator iter = temp.iteratorById(TAG_RMI_CUSTOM_MAX_STREAM_FORMAT.value);
if (!iter.hasNext()) {
// Didn't have the max stream format version tagged
// component.
if (giopVersion.lessThan(GIOPVersion.V1_3))
return ORBConstants.STREAM_FORMAT_VERSION_1;
else
return ORBConstants.STREAM_FORMAT_VERSION_2;
}
byte remoteMaxVersion
= ((MaxStreamFormatVersionComponent)iter.next()).getMaxStreamFormatVersion();
return (byte)Math.min(localMaxVersion, remoteMaxVersion);
}
项目:SimQRI
文件:BatchProcessPropertiesEditionPartImpl.java
/**
*
*/
protected void addStorageOutputFlow() {
TabElementTreeSelectionDialog dialog = new TabElementTreeSelectionDialog(storageOutputFlow.getInput(), storageOutputFlowFilters, storageOutputFlowBusinessFilters,
"storageOutputFlow", propertiesEditionComponent.getEditingContext().getAdapterFactory(), current.eResource()) {
@Override
public void process(IStructuredSelection selection) {
for (Iterator<?> iter = selection.iterator(); iter.hasNext();) {
EObject elem = (EObject) iter.next();
propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(BatchProcessPropertiesEditionPartImpl.this, MetamodelViewsRepository.BatchProcess.Properties.storageOutputFlow,
PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.ADD, null, elem));
}
storageOutputFlow.refresh();
}
};
dialog.open();
}
项目:lams
文件:AuthoringAction.java
/**
* Updates SessionMap using Scribe content.
*
* @param scribe
* @param mode
*/
private SessionMap<String, Object> createSessionMap(Scribe scribe, ToolAccessMode mode, String contentFolderID,
Long toolContentID) {
SessionMap<String, Object> map = new SessionMap<String, Object>();
map.put(KEY_MODE, mode);
map.put(KEY_CONTENT_FOLDER_ID, contentFolderID);
map.put(KEY_TOOL_CONTENT_ID, toolContentID);
map.put(KEY_HEADINGS, new LinkedList<ScribeHeading>());
// adding headings
Iterator iter = scribe.getScribeHeadings().iterator();
while (iter.hasNext()) {
ScribeHeading element = (ScribeHeading) iter.next();
getHeadingList(map).add(element);
}
// sorting headings according to displayOrder.
Collections.sort(getHeadingList(map));
return map;
}
项目:lazycat
文件:StatusTransformer.java
/**
* Write JSP monitoring information.
*/
public static void writeJspMonitor(PrintWriter writer, Set<ObjectName> jspMonitorONs, MBeanServer mBeanServer,
int mode) throws Exception {
int jspCount = 0;
int jspReloadCount = 0;
Iterator<ObjectName> iter = jspMonitorONs.iterator();
while (iter.hasNext()) {
ObjectName jspMonitorON = iter.next();
Object obj = mBeanServer.getAttribute(jspMonitorON, "jspCount");
jspCount += ((Integer) obj).intValue();
obj = mBeanServer.getAttribute(jspMonitorON, "jspReloadCount");
jspReloadCount += ((Integer) obj).intValue();
}
if (mode == 0) {
writer.print("<br>");
writer.print(" JSPs loaded: ");
writer.print(jspCount);
writer.print(" JSPs reloaded: ");
writer.print(jspReloadCount);
} else if (mode == 1) {
// for now we don't write out anything
}
}
项目:digital-display-garden-iteration-4-dorfner-v2
文件:TestPlantComment.java
@Test
public void successfulInputOfComment() throws IOException {
String json = "{ plantId: \"58d1c36efb0cac4e15afd278\", comment : \"Here is our comment for this test\" }";
assertTrue(plantController.addComment(json, "second uploadId"));
MongoClient mongoClient = new MongoClient();
MongoDatabase db = mongoClient.getDatabase(databaseName);
MongoCollection<Document> plants = db.getCollection("plants");
Document filterDoc = new Document();
filterDoc.append("_id", new ObjectId("58d1c36efb0cac4e15afd278"));
filterDoc.append("uploadID", "second uploadId");
Iterator<Document> iter = plants.find(filterDoc).iterator();
Document plant = iter.next();
List<Document> plantComments = (List<Document>) ((Document) plant.get("metadata")).get("comments");
long comments = plantComments.size();
assertEquals(1, comments);
assertEquals("Here is our comment for this test", plantComments.get(0).getString("comment"));
assertNotNull(plantComments.get(0).getObjectId("_id"));
}
项目:ctsms
文件:DateUtil.java
public static Map<Integer, ArrayList<TimeZone>> getTimeZoneByOffsets(Collection<TimeZone> timeZones) {
TreeMap<Integer, ArrayList<TimeZone>> result = new TreeMap<Integer, ArrayList<TimeZone>>();
if (timeZones != null) {
Iterator<TimeZone> it = timeZones.iterator();
while (it.hasNext()) {
TimeZone timeZone = it.next();
int timeZoneOffset = timeZone.getRawOffset();
ArrayList<TimeZone> offsetTimeZones;
if (!result.containsKey(timeZoneOffset)) {
offsetTimeZones = new ArrayList<TimeZone>();
result.put(timeZoneOffset, offsetTimeZones);
} else {
offsetTimeZones = result.get(timeZoneOffset);
}
offsetTimeZones.add(timeZone);
}
}
return result;
}
项目:scanning
文件:SubsetStatus.java
/**
* Returns true if expected is a subset of returned
*
* This is used for JSON serialiser comparisons.
*
* @param expected
* @param returned
* @return
*/
protected boolean isObjectNodeSubset(ObjectNode expected, ObjectNode returned) {
Iterator<Entry<String, JsonNode>> expectedChildren = expected.fields();
for (Map.Entry<String, JsonNode> en; expectedChildren.hasNext();) {
en = expectedChildren.next();
String key = en.getKey();
JsonNode value = en.getValue();
JsonNode returnedValue = returned.get(key);
if (returnedValue == null) {
errorDescription = "Returned JSON does not have key '" + key +"', with expected value:\n" + value.toString();
return false;
} else if (!isJsonNodeSubset(value, returnedValue)) {
return false;
}
}
return true;
}
项目:unitimes
文件:ExamSolver.java
private ExamPlacement getPlacement(Exam exam, ExamPlacement placement) {
ExamPeriodPlacement period = null;
for (ExamPeriodPlacement p: exam.getPeriodPlacements()) {
if (placement.getPeriod().equals(p.getPeriod())) {
period = p; break;
}
}
if (period==null) {
iProgress.warn("WARNING: Period "+placement.getPeriod()+" is not available for class "+exam.getName());
return null;
}
Set rooms = new HashSet();
for (Iterator f=exam.getRoomPlacements().iterator();f.hasNext();) {
ExamRoomPlacement r = (ExamRoomPlacement)f.next();
if (r.isAvailable(period.getPeriod()) && placement.contains(r.getRoom())) {
rooms.add(r);
}
}
if (rooms.size()!=placement.getRoomPlacements().size()) {
iProgress.warn("WARNING: Room(s) "+placement.getRoomPlacements()+" are not available for exam "+exam.getName());
return null;
}
return new ExamPlacement(exam,period,rooms);
}
项目:unitimes
文件:Solution.java
private void deleteObjects(org.hibernate.Session hibSession, String objectName, String idQuery) {
Iterator idIterator = hibSession.createQuery(idQuery).setLong("solutionId",getUniqueId()).iterate();
StringBuffer ids = new StringBuffer();
int idx = 0;
while (idIterator.hasNext()) {
ids.append(idIterator.next()); idx++;
if (idx==100) {
hibSession.createQuery("delete "+objectName+" as x where x.uniqueId in ("+ids+")").executeUpdate();
ids = new StringBuffer();
idx = 0;
} else if (idIterator.hasNext()) {
ids.append(",");
}
}
if (idx>0)
hibSession.createQuery("delete "+objectName+" as x where x.uniqueId in ("+ids+")").executeUpdate();
}
项目:Reer
文件:Dom4JUtility.java
/**
* Thie returns the node that is a child of hte specified parent that has the specified attribute with the specified value. This is similar to the above getChild, but no tag name is required.
*/
public static List<Element> getChildren(Element parent, String attribute, String attributeValue) {
List<Element> children = new ArrayList<Element>();
Iterator iterator = parent.elements().iterator();
while (iterator.hasNext()) {
Element childElement = (Element) iterator.next();
String actualValue = childElement.attributeValue(attribute);
if (attributeValue.equals(actualValue)) {
children.add(childElement);
}
}
return children;
}
项目:lams
文件:AbstractTransactSQLDialect.java
@Override
public String applyLocksToSql(String sql, LockOptions aliasedLockOptions, Map<String, String[]> keyColumnNames) {
// TODO: merge additional lockoptions support in Dialect.applyLocksToSql
final Iterator itr = aliasedLockOptions.getAliasLockIterator();
final StringBuilder buffer = new StringBuilder( sql );
int correction = 0;
while ( itr.hasNext() ) {
final Map.Entry entry = (Map.Entry) itr.next();
final LockMode lockMode = (LockMode) entry.getValue();
if ( lockMode.greaterThan( LockMode.READ ) ) {
final String alias = (String) entry.getKey();
int start = -1;
int end = -1;
if ( sql.endsWith( " " + alias ) ) {
start = ( sql.length() - alias.length() ) + correction;
end = start + alias.length();
}
else {
int position = sql.indexOf( " " + alias + " " );
if ( position <= -1 ) {
position = sql.indexOf( " " + alias + "," );
}
if ( position > -1 ) {
start = position + correction + 1;
end = start + alias.length();
}
}
if ( start > -1 ) {
final String lockHint = appendLockHint( lockMode, alias );
buffer.replace( start, end, lockHint );
correction += ( lockHint.length() - alias.length() );
}
}
}
return buffer.toString();
}
项目:lams
文件:PersistentClass.java
public Iterator getDeclaredPropertyIterator() {
ArrayList iterators = new ArrayList();
iterators.add( declaredProperties.iterator() );
for ( int i = 0; i < joins.size(); i++ ) {
Join join = ( Join ) joins.get( i );
iterators.add( join.getDeclaredPropertyIterator() );
}
return new JoinedIterator( iterators );
}
项目:smile_1.5.0_java7
文件:Math.java
/**
* Find unique elements of vector.
* @param x an array of strings.
* @return the same values as in x but with no repetitions.
*/
public static String[] unique(String[] x) {
HashSet<String> hash = new HashSet<>(Arrays.asList(x));
String[] y = new String[hash.size()];
Iterator<String> keys = hash.iterator();
for (int i = 0; i < y.length; i++) {
y[i] = keys.next();
}
return y;
}
项目:CPG
文件:JSONObject.java
/**
* Produce a JSONArray containing the names of the elements of this
* JSONObject.
*
* @return A JSONArray containing the key strings, or null if the JSONObject
* is empty.
*/
public JSONArray names() {
JSONArray ja = new JSONArray();
Iterator<String> keys = this.keys();
while (keys.hasNext()) {
ja.put(keys.next());
}
return ja.length() == 0 ? null : ja;
}
项目:hanlpStudy
文件:PinyinKey.java
public PinyinKey(String sentence)
{
Pair<List<Pinyin>, List<Boolean>> pair = String2PinyinConverter.convert2Pair(sentence, true);
pinyinArray = PinyinUtil.convertList2Array(pair.getKey());
List<Boolean> booleanList = pair.getValue();
int pinyinSize = 0;
for (Boolean yes : booleanList)
{
if (yes)
{
++pinyinSize;
}
}
int firstCharSize = 0;
for (Pinyin pinyin : pinyinArray)
{
if (pinyin != Pinyin.none5)
{
++firstCharSize;
}
}
pyOrdinalArray = new int[pinyinSize];
firstCharArray = new char[firstCharSize];
pinyinSize = 0;
firstCharSize = 0;
Iterator<Boolean> iterator = booleanList.iterator();
for (int i = 0; i < pinyinArray.length; ++i)
{
if (iterator.next())
{
pyOrdinalArray[pinyinSize++] = pinyinArray[i].ordinal();
}
if (pinyinArray[i] != Pinyin.none5)
{
firstCharArray[firstCharSize++] = pinyinArray[i].getFirstChar();
}
}
}
项目:javaide
文件:FilteredMemberList.java
public Iterator<Symbol> iterator() {
return new Iterator<Symbol>() {
/** The next entry to examine, or null if none. */
private Scope.Entry nextEntry = scope.elems;
private boolean hasNextForSure = false;
public boolean hasNext() {
if (hasNextForSure) {
return true;
}
while (nextEntry != null && unwanted(nextEntry.sym)) {
nextEntry = nextEntry.sibling;
}
hasNextForSure = (nextEntry != null);
return hasNextForSure;
}
public Symbol next() {
if (hasNext()) {
Symbol result = nextEntry.sym;
nextEntry = nextEntry.sibling;
hasNextForSure = false;
return result;
} else {
throw new NoSuchElementException();
}
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
项目:kourami
文件:HLAGraph.java
public void updateEdgeWeightProb(){
Set<CustomWeightedEdge> eSet = g.edgeSet();
Iterator<CustomWeightedEdge> itr = eSet.iterator();
CustomWeightedEdge e = null;
while(itr.hasNext()){
e = itr.next();
e.computeGroupErrorProb();
//HLA.log.appendln(e.toString());
}
}
项目:RRFramework-Android
文件:HashBiMap.java
public K getKey(Object value) {
Iterator iter = entrySet().iterator();
while (iter.hasNext()) {
Entry entry = (Entry) iter.next();
Object val = entry.getValue();
if (val.equals(value)) {
return (K) entry.getKey();
}
}
return null;
}