/** * Adds an addition change. * * @param pChange * the change which should result in an addition */ private void addAddition(Change pChange) { if (Change.TYPE_ADD != pChange.type() || pChange.getInput() == null) { return; } if (!changes.isEmpty()) { for (java.util.Iterator <Change> it = changes.iterator(); it.hasNext();) { Change change = it.next(); if (change.type() == Change.TYPE_ADD && change.getEntry() != null) { org.apache.commons.compress.archivers.ArchiveEntry entry = change.getEntry(); if (entry.equals(pChange.getEntry())) { if (pChange.isReplaceMode()) { it.remove(); changes.add(pChange); return; } else { // do not add this change return; } } } } } changes.add(pChange); }
public override bool Equals(Object o) { if (!(o is java.util.Map <Object, Object>)) { return(false); } java.util.Map <Object, Object> m = (java.util.Map <Object, Object>)o; java.util.Set <Object> keys = keySet(); if (!keys.equals(m.keySet())) { return(false); } java.util.Iterator <Object> it = keys.iterator(); while (it.hasNext()) { Key key = (Key)it.next(); Object v1 = get(key); Object v2 = m.get(key); if (!(v1 == null?v2 == null:v1.equals(v2))) { return(false); } } return(true); }
/* * Prints Services content */ // FIXME remove debug function public static void printServices() { refresh(); java.util.Set <String> s = services.keySet(); for (java.util.Iterator <String> i = s.iterator(); i.hasNext();) { String key = i.next(); java.lang.SystemJ.outJ.println(key + "=" + services.get(key)); //$NON-NLS-1$ } }
internal static void CloseSelector(java.nio.channels.Selector selector) { java.util.Set keys = selector.keys(); java.util.Iterator it = keys.iterator(); try { selector.close(); } catch (Exception e) { #if DEBUG Console.WriteLine("Caught exception during CloseSelector selector.close - {0}: {1}\n{2}", e.GetType(), e.Message, e.StackTrace); #endif } while (it.hasNext()) { java.nio.channels.SelectionKey key = (java.nio.channels.SelectionKey)it.next(); Socket source = (Socket)key.attachment(); key.cancel(); try { if (source.Blocking) { /* * A channel must be placed into non-blocking mode before being registered * with a selector, and may not be returned to blocking mode until it has been * deregistered. So, I need set the channel back to the blocking mode, if it was * in blocking mode before select operation */ source.Blocking = true; } } catch (Exception be) { #if DEBUG Console.WriteLine("Caught exception during CloseSelector source.Blocking - {0}: {1}\n{2}", be.GetType(), be.Message, be.StackTrace); #endif } } try { selector.close(); } catch (Exception e) { #if DEBUG Console.WriteLine("Caught exception during CloseSelector selector.close - {0}: {1}\n{2}", e.GetType(), e.Message, e.StackTrace); #endif } }
public int getRunLimit(java.util.Set <AttributedCharacterIteratorNS.Attribute> attributes) { int limit = end; java.util.Iterator <AttributedCharacterIteratorNS.Attribute> it = attributes.iterator(); while (it.hasNext()) { AttributedCharacterIteratorNS.Attribute attribute = it.next(); int newLimit = getRunLimit(attribute); if (newLimit < limit) { limit = newLimit; } } return(limit); }
public int getRunStart(java.util.Set <AttributedCharacterIteratorNS.Attribute> attributes) { int start = begin; java.util.Iterator <AttributedCharacterIteratorNS.Attribute> it = attributes.iterator(); while (it.hasNext()) { AttributedCharacterIteratorNS.Attribute attribute = it.next(); int newStart = getRunStart(attribute); if (newStart > start) { start = newStart; } } return(start); }
private OWLClass getClass(java.util.Set _Class, string keyOwl) { java.util.Iterator iterator = _Class.iterator(); OWLClass _class; while (iterator.hasNext()) { _class = (OWLClass)iterator.next(); if (_class.getIRI().toString().Equals(keyOwl)) { return(_class); } } return(null); }
private AttributedString(AttributedCharacterIterator iterator, int start, int end, java.util.Set <AttributedCharacterIteratorNS.Attribute> attributes) { if (start < iterator.getBeginIndex() || end > iterator.getEndIndex() || start > end) { throw new java.lang.IllegalArgumentException(); } if (attributes == null) { return; } StringBuilder buffer = new StringBuilder(); iterator.setIndex(start); while (iterator.getIndex() < end) { buffer.Append(iterator.current()); iterator.next(); } text = buffer.ToString(); attributeMap = new java.util.HashMap <AttributedCharacterIteratorNS.Attribute, java.util.List <IAC_Range> >();//(attributes.size() * 4 / 3) + 1); java.util.Iterator <AttributedCharacterIteratorNS.Attribute> it = attributes.iterator(); while (it.hasNext()) { AttributedCharacterIteratorNS.Attribute attribute = it.next(); iterator.setIndex(start); while (iterator.getIndex() < end) { System.Object value = iterator.getAttribute(attribute); int runStart = iterator.getRunStart(attribute); int limit = iterator.getRunLimit(attribute); if ((value is java.lang.annotation.Annotation && runStart >= start && limit <= end) || (value != null && !(value is java.lang.annotation.Annotation))) { addAttribute(attribute, value, (runStart < start ? start : runStart) - start, (limit > end ? end : limit) - start); } iterator.setIndex(limit); } } }
private void assertCDvOrdinal(org.openehr.am.archetype.constraintmodel.ArchetypeConstraint node, String terminoloy, String[] codes, org.openehr.am.openehrprofile.datatypes.quantity.Ordinal assumedValue) { Assert.IsTrue(node is org.openehr.am.openehrprofile.datatypes.quantity.CDvOrdinal, "CDvOrdinal expected"); org.openehr.am.openehrprofile.datatypes.quantity.CDvOrdinal cordinal = (org.openehr.am.openehrprofile.datatypes.quantity.CDvOrdinal)node; java.util.List codeList = java.util.Arrays.asList(codes); java.util.Set list = cordinal.getList(); Assert.AreEqual(codes.Length, list.size(), "codes.size"); for (java.util.Iterator it = list.iterator(); it.hasNext();) { org.openehr.am.openehrprofile.datatypes.quantity.Ordinal ordinal = (org.openehr.am.openehrprofile.datatypes.quantity.Ordinal)it.next(); Assert.AreEqual("local", ordinal.getSymbol().getTerminologyId().getValue(), "terminology"); Assert.IsTrue(codeList.contains(ordinal.getSymbol().getCodeString()), "code missing"); } Assert.AreEqual(assumedValue, cordinal.getAssumedValue(), "assumedValue wrong"); }
/** * Constructs an {@code AttributedString} from an {@code * AttributedCharacterIterator}, which represents attributed text. * * @param iterator * the {@code AttributedCharacterIterator} that contains the text * for this attributed string. */ public AttributedString(AttributedCharacterIterator iterator) { if (iterator.getBeginIndex() > iterator.getEndIndex()) { // text.0A=Invalid substring range throw new java.lang.IllegalArgumentException("Invalid substring range"); //$NON-NLS-1$ } StringBuilder buffer = new StringBuilder(); for (int i = iterator.getBeginIndex(); i < iterator.getEndIndex(); i++) { buffer.Append(iterator.current()); iterator.next(); } text = buffer.ToString(); java.util.Set <AttributedCharacterIteratorNS.Attribute> attributes = iterator .getAllAttributeKeys(); if (attributes == null) { return; } attributeMap = new java.util.HashMap <AttributedCharacterIteratorNS.Attribute, java.util.List <IAC_Range> >();//(attributes.size() * 4 / 3) + 1); java.util.Iterator <AttributedCharacterIteratorNS.Attribute> it = attributes.iterator(); while (it.hasNext()) { AttributedCharacterIteratorNS.Attribute attribute = it.next(); iterator.setIndex(0); while (iterator.current() != CharacterIteratorConstants.DONE) { int start = iterator.getRunStart(attribute); int limit = iterator.getRunLimit(attribute); System.Object value = iterator.getAttribute(attribute); if (value != null) { addAttribute(attribute, value, start, limit); } iterator.setIndex(limit); } } }
private void aggregateGroupDescs(java.util.Map <string, java.util.List <android.content.pm.PermissionInfo > > map, java.util.Map <string, string> retMap) { if (map == null) { return; } if (retMap == null) { return; } java.util.Set <string> grpNames = map.keySet(); java.util.Iterator <string> grpNamesIter = grpNames.iterator(); while (grpNamesIter.hasNext()) { string grpDesc = null; string grpNameKey = grpNamesIter.next(); java.util.List <android.content.pm.PermissionInfo> grpPermsList = map.get(grpNameKey ); if (grpPermsList == null) { continue; } foreach (android.content.pm.PermissionInfo permInfo in Sharpen.IterableProxy.Create (grpPermsList)) { java.lang.CharSequence permDesc = permInfo.loadLabel(mPm); grpDesc = formatPermissions(grpDesc, permDesc); } // Insert grpDesc into map if (grpDesc != null) { if (localLOGV) { android.util.Log.i(TAG, "Group:" + grpNameKey + " description:" + grpDesc.ToString ()); } retMap.put(grpNameKey, grpDesc.ToString()); } } }
public LookupProvidersIterator(java.lang.Class providerClass, java.lang.ClassLoader loader) { this.loader = loader; java.util.Enumeration <java.net.URL> e = null; try { e = loader.getResources("META-INF/services/" + providerClass.getName()); //$NON-NLS-1$ while (e.hasMoreElements()) { java.util.Set <String> names = parse((java.net.URL)e.nextElement()); providerNames.addAll(names); } } catch (java.io.IOException e1) { // Ignored } it = providerNames.iterator(); }
/// <summary> /// Execute an updating query. /// </summary> /// <returns>An array containing the root nodes of documents that have been /// updated by the query.</returns> /// <exception cref="DynamicError">Throws a DynamicError if any run-time failure /// occurs while evaluating the expression, or if the expression is not an /// updating query.</exception> public XdmNode[] RunUpdate() { if (!exp.isUpdateQuery()) { throw new DynamicError("Not an updating query"); } try { java.util.Set updatedDocs = exp.runUpdate(context); XdmNode[] result = new XdmNode[updatedDocs.size()]; int i = 0; for (java.util.Iterator iter = updatedDocs.iterator(); iter.hasNext();) { result[i++] = (XdmNode)XdmValue.Wrap((NodeInfo)iter.next()); } return(result); } catch (JXPathException err) { throw new DynamicError(err); } }
/** * Checks if an ArchiveEntry is deleted later in the ChangeSet. This is * necessary if an file is added with this ChangeSet, but later became * deleted in the same set. * * @param entry * the entry to check * @return true, if this entry has an deletion change later, false otherwise */ private bool isDeletedLater(java.util.Set <Change> workingSet, ArchiveEntry entry) { String source = entry.getName(); if (!workingSet.isEmpty()) { for (java.util.Iterator <Change> it = workingSet.iterator(); it.hasNext();) { Change change = it.next(); int type = change.type(); String target = change.targetFile(); if (type == Change.TYPE_DELETE && source.equals(target)) { return(true); } if (type == Change.TYPE_DELETE_DIR && source.startsWith(target + "/")) { return(true); } } } return(false); }
public java.util.Iterator <Object> getOutgoingNodes() { return(outgoingNodes.iterator()); }
internal static void Select_internal(ref Socket [] sockets, int microSeconds, out int error) { error = 0; java.nio.channels.Selector selector = java.nio.channels.Selector.open(); int mode = 0; int count = sockets.Length; for (int i = 0; i < count; i++) { if (sockets [i] == null) { // separator mode++; continue; } GHSocket sock = sockets [i].GHHandle; if (sock == null) { throw new ArgumentNullException("GHSocket handle is null"); } sock.RegisterSelector(selector, mode, sockets [i], out error); if (error != 0) { error = 0; sockets = null; CloseSelector(selector); return; } } sockets = null; long timeOutMillis = 1; if (microSeconds < 0) { timeOutMillis = 0; } else if (microSeconds > 999) { timeOutMillis = (long)(microSeconds / 1000); } int readyCount = 0; try { readyCount = selector.select(timeOutMillis); } catch (Exception e) { error = 10022; //WSAEINVAL (Invalid argument) #if DEBUG Console.WriteLine("Caught exception during Select_internal selector.select - {0}: {1}\n{2}", e.GetType(), e.Message, e.StackTrace); #endif } if (readyCount > 0) { try { sockets = new Socket[readyCount + 2]; Socket[] writeList = new Socket[readyCount]; Socket[] errorList = new Socket[readyCount]; int readListCount = 0; int writeListCount = 0; int errorListCount = 0; java.util.Set readyKeys = selector.selectedKeys(); java.util.Iterator it = readyKeys.iterator(); while (it.hasNext()) { java.nio.channels.SelectionKey key = (java.nio.channels.SelectionKey)it.next(); if (key.isAcceptable() || key.isReadable()) { sockets[readListCount] = (Socket)key.attachment(); readListCount++; } if (key.isWritable()) { writeList[writeListCount] = (Socket)key.attachment(); writeListCount++; } if (key.isConnectable()) { Socket source = (Socket)key.attachment(); if (source.GHHandle.CheckConnectionFinished()) { writeList[writeListCount] = source; writeListCount++; } else { errorList[errorListCount] = source; errorListCount++; } } } sockets[readListCount] = null; readListCount++; for (int i = 0; i < writeListCount; i++, readListCount++) { sockets[readListCount] = writeList[i]; } sockets[readListCount] = null; readListCount++; for (int i = 0; i < errorListCount; i++, readListCount++) { sockets[readListCount] = errorList[i]; } } catch (Exception e) { error = 10022; //WSAEINVAL (Invalid argument) #if DEBUG Console.WriteLine("Caught exception during Select_internal iterate selected keys - {0}: {1}\n{2}", e.GetType(), e.Message, e.StackTrace); #endif } } CloseSelector(selector); }
/** * Returns the array of providers which meet the user supplied set of * filters. The filter must be supplied in one of two formats: * <nl> * <li> CRYPTO_SERVICE_NAME.ALGORITHM_OR_TYPE</li> * <p/> * for example: "MessageDigest.SHA" The value associated with the key must * be an empty string. <li> CRYPTO_SERVICE_NAME.ALGORITHM_OR_TYPE</li> * ATTR_NAME:ATTR_VALUE * <p/> * for example: "Signature.MD2withRSA KeySize:512" where "KeySize:512" is * the value of the filter map entry. * </nl> * * @param filter * case-insensitive filter. * @return the providers which meet the user supplied string filter {@code * filter}. A {@code null} value signifies that none of the * installed providers meets the filter specification. * @throws InvalidParameterException * if an unusable filter is supplied. * @throws NullPointerException * if {@code filter} is {@code null}. */ public static Provider[] getProviders(java.util.Map <String, String> filter) { lock (lockJ) { if (filter == null) { throw new java.lang.NullPointerException("The filter is null"); //$NON-NLS-1$ } if (filter.isEmpty()) { return(null); } java.util.List <Provider> result = Services.getProvidersList(); java.util.Set <java.util.MapNS.Entry <String, String> > keys = filter.entrySet(); java.util.MapNS.Entry <String, String> entry; for (java.util.Iterator <java.util.MapNS.Entry <String, String> > it = keys.iterator(); it.hasNext();) { entry = it.next(); String key = entry.getKey(); String val = entry.getValue(); String attribute = null; int i = key.indexOf(' '); int j = key.indexOf('.'); if (j == -1) { throw new InvalidParameterException("The filter is not in the required format"); //$NON-NLS-1$ } if (i == -1) { // <crypto_service>.<algorithm_or_type> if (val.length() != 0) { throw new InvalidParameterException("The filter is not in the required format"); //$NON-NLS-1$ } } else { // <crypto_service>.<algorithm_or_type> <attribute_name> if (val.length() == 0) { throw new InvalidParameterException("The filter is not in the required format"); //$NON-NLS-1$ } attribute = key.substring(i + 1); if (attribute.trim().length() == 0) { throw new InvalidParameterException("The filter is not in the required format"); //$NON-NLS-1$ } key = key.substring(0, i); } String serv = key.substring(0, j); String alg = key.substring(j + 1); if (serv.length() == 0 || alg.length() == 0) { throw new InvalidParameterException("The filter is not in the required format"); //$NON-NLS-1$ } Provider p; for (int k = 0; k < result.size(); k++) { try { p = result.get(k); } catch (java.lang.IndexOutOfBoundsException) { break; } if (!p.implementsAlg(serv, alg, attribute, val)) { result.remove(p); k--; } } } if (result.size() > 0) { return(result.toArray(new Provider[result.size()])); } return(null); } }
public void putAll(java.util.Map <Object, Object> m) { if (m is RenderingHints) { map.putAll(((RenderingHints)m).map); } else { java.util.Set <java.util.MapNS.Entry <Object, Object> > entries = m.entrySet(); if (entries != null) { java.util.Iterator <java.util.MapNS.Entry <Object, Object> > it = entries.iterator(); while (it.hasNext()) { java.util.MapNS.Entry <Object, Object> entry = it.next(); Key key = (Key)entry.getKey(); Object val = entry.getValue(); put(key, val); } } } }
/** * Checks whether the map contains the value specified. * <p> * This checks all collections against all keys for the value, and thus could be slow. * * @param value the value to search for * @return true if the map contains the value */ public override bool containsValue(Object value) { java.util.Set <java.util.MapNS.Entry <Object, Object> > pairs = base.entrySet(); if (pairs == null) { return(false); } java.util.Iterator <java.util.MapNS.Entry <Object, Object> > pairsIterator = pairs.iterator(); while (pairsIterator.hasNext()) { java.util.MapNS.Entry <Object, Object> keyValuePair = pairsIterator.next(); java.util.Collection <Object> coll = (java.util.Collection <Object>)keyValuePair.getValue(); if (coll.contains(value)) { return(true); } } return(false); }
/** * Clear the map. * <p> * This clears each collection in the map, and so may be slow. */ public override void clear() { // For gc, clear each list in the map java.util.Set <java.util.MapNS.Entry <Object, Object> > pairs = base.entrySet(); java.util.Iterator <java.util.MapNS.Entry <Object, Object> > pairsIterator = pairs.iterator(); while (pairsIterator.hasNext()) { java.util.MapNS.Entry <Object, Object> keyValuePair = pairsIterator.next(); java.util.Collection <Object> coll = (java.util.Collection <Object>)keyValuePair.getValue(); coll.clear(); } base.clear(); }