/**
         * Returns a set of attributes present in the {@code AttributedString}.
         * An empty set returned indicates that no attributes where defined.
         *
         * @return a set of attribute keys that may be empty.
         */
        public java.util.Set <AttributedCharacterIteratorNS.Attribute> getAllAttributeKeys()
        {
            if (begin == 0 && end == attrString.text.Length &&
                attributesAllowed == null)
            {
                return(attrString.attributeMap.keySet());
            }

            java.util.Set <AttributedCharacterIteratorNS.Attribute> result = new java.util.HashSet <AttributedCharacterIteratorNS.Attribute>();//(attrString.attributeMap.size() * 4 / 3) + 1);
            java.util.Iterator <java.util.MapNS.Entry <AttributedCharacterIteratorNS.Attribute, java.util.List <IAC_Range> > > it = attrString.attributeMap
                                                                                                                                    .entrySet().iterator();
            while (it.hasNext())
            {
                java.util.MapNS.Entry <AttributedCharacterIteratorNS.Attribute, java.util.List <IAC_Range> > entry = it.next();
                if (attributesAllowed == null ||
                    attributesAllowed.contains(entry.getKey()))
                {
                    java.util.List <IAC_Range> ranges = entry.getValue();
                    if (inRange(ranges))
                    {
                        result.add(entry.getKey());
                    }
                }
            }
            return(result);
        }
 public AppSecurityPermissions(android.content.Context context, string packageName
                               )
 {
     mContext   = context;
     mPm        = mContext.getPackageManager();
     mPermsList = new java.util.ArrayList <android.content.pm.PermissionInfo>();
     java.util.Set <android.content.pm.PermissionInfo> permSet = new java.util.HashSet <
         android.content.pm.PermissionInfo>();
     android.content.pm.PackageInfo pkgInfo;
     try
     {
         pkgInfo = mPm.getPackageInfo(packageName, android.content.pm.PackageManager.GET_PERMISSIONS
                                      );
     }
     catch (android.content.pm.PackageManager.NameNotFoundException)
     {
         android.util.Log.w(TAG, "Could'nt retrieve permissions for package:" + packageName
                            );
         return;
     }
     // Extract all user permissions
     if ((pkgInfo.applicationInfo != null) && (pkgInfo.applicationInfo.uid != -1))
     {
         getAllUsedPermissions(pkgInfo.applicationInfo.uid, permSet);
     }
     foreach (android.content.pm.PermissionInfo tmpInfo in Sharpen.IterableProxy.Create
                  (permSet))
     {
         mPermsList.add(tmpInfo);
     }
 }
Exemple #3
0
        /**
         * Factory method to create an ordered set using the supplied list to retain order.
         * <p>
         * A <code>HashSet</code> is used for the set behaviour.
         * <p>
         * NOTE: If the list contains duplicates, the duplicates are removed,
         * altering the specified list.
         *
         * @param list  the list to decorate, must not be null
         * @throws IllegalArgumentException if list is null
         */
        public static ListOrderedSet decorate(java.util.List <Object> list)
        {
            if (list == null)
            {
                throw new java.lang.IllegalArgumentException("List must not be null");
            }
            java.util.Set <Object> set = new java.util.HashSet <Object>(list);
            list.retainAll(set);

            return(new ListOrderedSet(set, list));
        }
Exemple #4
0
        /// <summary>Turns an IntBuffer into a HashSet of integers</summary>
        /// <param name="buffer"/>
        /// <returns/>
        public static java.util.HashSet <int> toHashSet(java.nio.IntBuffer buffer)
        {
            int limit = buffer.limit();

            java.util.HashSet <int> ints = new java.util.HashSet <int>(limit);
            for (int i = 0; i < limit; i++)
            {
                ints.add(buffer.get(i));
            }
            return(ints);
        }
Exemple #5
0
 /**
  * Returns a {@code Set} of all registered algorithms for the specified
  * cryptographic service. {@code "Signature"}, {@code "Cipher"} and {@code
  * "KeyStore"} are examples for such kind of services.
  *
  * @param serviceName
  *            the case-insensitive name of the service.
  * @return a {@code Set} of all registered algorithms for the specified
  *         cryptographic service, or an empty {@code Set} if {@code
  *         serviceName} is {@code null} or if no registered provider
  *         provides the requested service.
  */
 public static java.util.Set <String> getAlgorithms(String serviceName)
 {
     java.util.HashSet <String> result = new java.util.HashSet <String>();
     Provider[] p = getProviders();
     for (int i = 0; i < p.Length; i++)
     {
         for (java.util.Iterator <Provider.Service> it = p[i].getServices().iterator(); it.hasNext();)
         {
             Provider.Service s = (Provider.Service)it.next();
             if (Util.equalsIgnoreCase(s.getType(), serviceName))
             {
                 result.add(s.getAlgorithm());
             }
         }
     }
     return(result);
 }
 public AppSecurityPermissions(android.content.Context context, android.content.pm.PackageParser
                               .Package pkg)
 {
     mContext   = context;
     mPm        = mContext.getPackageManager();
     mPermsList = new java.util.ArrayList <android.content.pm.PermissionInfo>();
     java.util.Set <android.content.pm.PermissionInfo> permSet = new java.util.HashSet <
         android.content.pm.PermissionInfo>();
     if (pkg == null)
     {
         return;
     }
     // Get requested permissions
     if (pkg.requestedPermissions != null)
     {
         java.util.ArrayList <string> strList = pkg.requestedPermissions;
         int size = strList.size();
         if (size > 0)
         {
             extractPerms(strList.toArray(new string[size]), permSet);
         }
     }
     // Get permissions related to  shared user if any
     if (pkg.mSharedUserId != null)
     {
         int sharedUid;
         try
         {
             sharedUid = mPm.getUidForSharedUser(pkg.mSharedUserId);
             getAllUsedPermissions(sharedUid, permSet);
         }
         catch (android.content.pm.PackageManager.NameNotFoundException)
         {
             android.util.Log.w(TAG, "Could'nt retrieve shared user id for:" + pkg.packageName
                                );
         }
     }
     // Retrieve list of permissions
     foreach (android.content.pm.PermissionInfo tmpInfo in Sharpen.IterableProxy.Create
                  (permSet))
     {
         mPermsList.add(tmpInfo);
     }
 }
        //
        // GetInterfaces
        //

        public override Type[] GetInterfaces()
        {
            var output = new java.util.HashSet();

            GetInterfacesInternal(JavaClass, output);
            return((Type[])output.toArray(System.Type.EmptyTypes));

            void GetInterfacesInternal(java.lang.Class input, java.util.HashSet output)
            {
                foreach (var javaType in input.getGenericInterfaces())
                {
                    output.add(FromJavaGenericType(javaType));
                    if (javaType is java.lang.Class classType)
                    {
                        GetInterfacesInternal(classType, output);
                    }
                }
            }
        }
Exemple #8
0
        /// <summary>
        /// <para>
        /// Finds the resource URL closure for the given starting assembly list.
        /// </para>
        /// The closure is computed recursively from the referenced assemblies;
        /// satellite assemblies for the current culture are included also.
        /// </summary>
        /// <remarks>
        /// Referenced System, IKVM, Hsqldb core and NUnit assemblies are excluded.
        /// </remarks>
        /// <param name="startingList">The starting assembly list.</param>
        /// <returns>
        /// An array of <c>ikvmres:</c> protocol URLs describing the useful portion
        /// of the reference closure for the starting list.
        /// </returns>
        //[CLSCompliant(false)]
        public static URL[] FindResourceURLClosure(List <Assembly> startingList)
        {
            if (startingList == null)
            {
                throw new ArgumentNullException("startingList");
            }

            Set included    = new HashSet();
            Set encountered = new HashSet();

            foreach (Assembly entry in startingList)
            {
                AddAssembly(encountered, included, entry);
            }

            Assembly[] assemblies = new Assembly[included.size()];

            included.toArray(assemblies);

            URL[] urls = new URL[included.size()];

            for (int i = 0; i < assemblies.Length; i++)
            {
                Assembly entry     = assemblies[i];
                string   entryName = URLEncoder.encode(entry.FullName, "UTF-8");
                string   entryUrl  = string.Concat("ikvmres://", entryName, "/");

                try
                {
                    urls[i] = new URL(entryUrl);
                }
                catch (Exception ex)
                {
#if DEBUG
                    Debug.WriteLine("URL: " + entryUrl);
                    Debug.WriteLine(ex);
#endif
                }
            }

            return(urls);
        }
Exemple #9
0
 /*
  * Constructs a <code>Charset</code> object. Duplicated aliases are
  * ignored.
  *
  * @param canonicalName
  *            the canonical name of the charset.
  * @param aliases
  *            an array containing all aliases of the charset. May be null.
  * @throws IllegalCharsetNameException
  *             on an illegal value being supplied for either
  *             <code>canonicalName</code> or for any element of
  *             <code>aliases</code>.
  */
 protected Charset(String canonicalName, String[] aliases)
 {
     if (null == canonicalName)
     {
         throw new java.lang.NullPointerException();
     }
     // check whether the given canonical name is legal
     checkCharsetName(canonicalName);
     this.canonicalName = canonicalName;
     // check each alias and put into a set
     this.aliasesSet = new java.util.HashSet <String>();
     if (null != aliases)
     {
         for (int i = 0; i < aliases.Length; i++)
         {
             checkCharsetName(aliases[i]);
             this.aliasesSet.add(aliases[i]);
         }
     }
 }
Exemple #10
0
            /// <summary>
            /// Gets an embedded session using the given properties.
            /// </summary>
            /// <remarks>
            /// It is assumed (but not checked) that the given properties
            /// object requests a session with a res: protocol database
            /// instance; work is performed toward configuring and locking
            /// the ambient class loading environment to correctly handle
            /// searching the transitive closure of <c>ikvmres:</c>
            /// protocol resources reachable by compile-time reference,
            /// starting with the assemblies referenced on the call stack,
            /// as well as the entry level, calling and executing assemblies
            /// and their related satellite assemblies.
            /// </remarks>
            /// <param name="properties">The properties.</param>
            /// <returns>an embedded session</returns>
            internal static HsqlSession NewEmbeddedResSession(
                HsqlProperties properties)
            {
                StackTrace trace = new StackTrace();

                java.util.Set set = new java.util.HashSet();

                foreach (StackFrame frame in trace.GetFrames())
                {
                    set.add(frame.GetMethod().DeclaringType.Assembly.FullName);
                }

                List <Assembly> startingList = new List <Assembly>();

                foreach (string name in set.toArray())
                {
                    try
                    {
                        startingList.Add(Assembly.Load(name));
                    }
                    catch { }
                }

                startingList.Add(Assembly.GetExecutingAssembly());
                startingList.Add(Assembly.GetCallingAssembly());

                if (Assembly.GetEntryAssembly() != null)
                {
                    startingList.Add(Assembly.GetEntryAssembly());
                }

                java.lang.ClassLoader loader
                    = IkvmResourceLoaderFactory.CreateLoader(startingList);

                lock (s_resLock)
                {
                    org.hsqldb.lib.ResourceStreamProvider.setLoader(loader);

                    return(HsqlSession.Factory.NewEmbeddedSession(properties));
                }
            }
Exemple #11
0
 internal AttributedIterator(AttributedString attrString,
                             AttributedCharacterIteratorNS.Attribute[] attributes, int begin,
                             int end)
 {
     if (begin < 0 || end > attrString.text.Length || begin > end)
     {
         throw new java.lang.IllegalArgumentException();
     }
     this.begin      = begin;
     this.end        = end;
     offset          = begin;
     this.attrString = attrString;
     if (attributes != null)
     {
         java.util.HashSet <AttributedCharacterIteratorNS.Attribute> set = new java.util.HashSet <AttributedCharacterIteratorNS.Attribute>(
             (attributes.Length * 4 / 3) + 1);
         for (int i = attributes.Length; --i >= 0;)
         {
             set.add(attributes[i]);
         }
         attributesAllowed = set;
     }
 }
Exemple #12
0
 /*
  * Adds an unresolved permission to this {@code
  * UnresolvedPermissionCollection}.
  *
  * @param permission
  *            the permission to be added.
  * @throws SecurityException
  *             if this collection is read only.
  * @throws IllegalArgumentException
  *             if {@code permission} is {@code null} or not an {@code
  *             UnresolvedPermission}.
  */
 public override void add(Permission permission)
 {
     if (isReadOnly())
     {
         throw new java.lang.SecurityException("collection is read-only"); //$NON-NLS-1$
     }
     if (permission == null ||
         permission.getClass() != typeof(UnresolvedPermission).getClass())
     {
         throw new java.lang.IllegalArgumentException("invalid permission: " + permission);
     }
     lock (klasses)
     {
         String klass = permission.getName();
         java.util.Collection <Permission> klassMates = (java.util.Collection <Permission>)klasses.get(klass);
         if (klassMates == null)
         {
             klassMates = new java.util.HashSet <Permission>();
             klasses.put(klass, klassMates);
         }
         klassMates.add(permission);
     }
 }
 /**
  * Adds an unresolved permission to this {@code
  * UnresolvedPermissionCollection}.
  *
  * @param permission
  *            the permission to be added.
  * @throws SecurityException
  *             if this collection is read only.
  * @throws IllegalArgumentException
  *             if {@code permission} is {@code null} or not an {@code
  *             UnresolvedPermission}.
  */
 public override void add(Permission permission)
 {
     if (isReadOnly())
     {
         throw new java.lang.SecurityException("collection is read-only"); //$NON-NLS-1$
     }
     if (permission == null
         || permission.getClass() != typeof(UnresolvedPermission).getClass())
     {
         throw new java.lang.IllegalArgumentException("invalid permission: " + permission);
     }
     lock (klasses)
     {
         String klass = permission.getName();
         java.util.Collection<Permission> klassMates = (java.util.Collection<Permission>)klasses.get(klass);
         if (klassMates == null)
         {
             klassMates = new java.util.HashSet<Permission>();
             klasses.put(klass, klassMates);
         }
         klassMates.add(permission);
     }
 }
Exemple #14
0
		/// <summary>Read a HashSet object from an XmlPullParser.</summary>
		/// <remarks>
		/// Read a HashSet object from an XmlPullParser. The XML data could previously
		/// have been generated by writeSetXml(). The XmlPullParser must be positioned
		/// <em>after</em> the tag that begins the set.
		/// </remarks>
		/// <param name="parser">The XmlPullParser from which to read the set data.</param>
		/// <param name="endTag">Name of the tag that will end the set, usually "set".</param>
		/// <param name="name">
		/// An array of one string, used to return the name attribute
		/// of the set's tag.
		/// </param>
		/// <returns>HashSet The newly generated set.</returns>
		/// <exception cref="org.xmlpull.v1.XmlPullParserException">org.xmlpull.v1.XmlPullParserException
		/// 	</exception>
		/// <exception cref="System.IO.IOException">System.IO.IOException</exception>
		/// <seealso cref="readSetXml(java.io.InputStream)">readSetXml(java.io.InputStream)</seealso>
		public static java.util.HashSet<object> readThisSetXml(org.xmlpull.v1.XmlPullParser
			 parser, string endTag, string[] name)
		{
			java.util.HashSet<object> set = new java.util.HashSet<object>();
			int eventType = parser.getEventType();
			do
			{
				if (eventType == org.xmlpull.v1.XmlPullParserClass.START_TAG)
				{
					object val = readThisValueXml(parser, name);
					set.add(val);
				}
				else
				{
					//System.out.println("Adding to set: " + val);
					if (eventType == org.xmlpull.v1.XmlPullParserClass.END_TAG)
					{
						if (parser.getName().Equals(endTag))
						{
							return set;
						}
						throw new org.xmlpull.v1.XmlPullParserException("Expected " + endTag + " end tag at: "
							 + parser.getName());
					}
				}
				eventType = parser.next();
			}
			while (eventType != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT);
			throw new org.xmlpull.v1.XmlPullParserException("Document ended before " + endTag
				 + " end tag");
		}
Exemple #15
0
            /*
             * Parse the provider-configuration file as specified
             * @see <a href="http://java.sun.com/j2se/1.5.0/docs/guide/jar/jar.html#Provider Configuration File">JAR File Specification</a>
             */
            private java.util.Set <String> parse(java.net.URL u)
            {
                java.io.InputStream    input  = null;
                java.io.BufferedReader reader = null;
                java.util.Set <String> names  = new java.util.HashSet <String>();
                try
                {
                    input  = u.openStream();
                    reader = new java.io.BufferedReader(new java.io.InputStreamReader(input, "utf-8")); //$NON-NLS-1$

                    String line;
                    while ((line = reader.readLine()) != null)
                    {
                        // The comment character is '#' (0x23)
                        // on each line all characters following the first comment character are ignored
                        int sharpIndex = line.indexOf('#');
                        if (sharpIndex >= 0)
                        {
                            line = line.substring(0, sharpIndex);
                        }

                        // Whitespaces are ignored
                        line = line.trim();

                        if (line.length() > 0)
                        {
                            // a java class name, check if identifier correct
                            char[] namechars = line.toCharArray();
                            for (int i = 0; i < namechars.Length; i++)
                            {
                                if (!(java.lang.Character.isJavaIdentifierPart(namechars[i]) || namechars[i] == '.'))
                                {
                                    throw new ServiceConfigurationError(Messages.getString("imageio.99", line));
                                }
                            }
                            names.add(line);
                        }
                    }
                }
                catch (java.io.IOException e)
                {
                    throw new ServiceConfigurationError(e.toString());
                }
                finally
                {
                    try
                    {
                        if (reader != null)
                        {
                            reader.close();
                        }
                        if (input != null)
                        {
                            input.close();
                        }
                    }
                    catch (java.io.IOException e)
                    {
                        throw new ServiceConfigurationError(e.toString());
                    }
                }

                return(names);
            }
Exemple #16
0
 /**
  * Returns a {@code Set} of all registered algorithms for the specified
  * cryptographic service. {@code "Signature"}, {@code "Cipher"} and {@code
  * "KeyStore"} are examples for such kind of services.
  *
  * @param serviceName
  *            the case-insensitive name of the service.
  * @return a {@code Set} of all registered algorithms for the specified
  *         cryptographic service, or an empty {@code Set} if {@code
  *         serviceName} is {@code null} or if no registered provider
  *         provides the requested service.
  */
 public static java.util.Set<String> getAlgorithms(String serviceName)
 {
     java.util.HashSet<String> result = new java.util.HashSet<String>();
     Provider[] p = getProviders();
     for (int i = 0; i < p.Length; i++)
     {
         for (java.util.Iterator<Provider.Service> it = p[i].getServices().iterator(); it.hasNext(); )
         {
             Provider.Service s = (Provider.Service)it.next();
             if (Util.equalsIgnoreCase(s.getType(), serviceName))
             {
                 result.add(s.getAlgorithm());
             }
         }
     }
     return result;
 }
Exemple #17
0
		internal override void dispatchDetachedFromWindow()
		{
			// If we still have a touch target, we are still in the process of
			// dispatching motion events to a child; we need to get rid of that
			// child to avoid dispatching events to it after the window is torn
			// down. To make sure we keep the child in a consistent state, we
			// first send it an ACTION_CANCEL motion event.
			cancelAndClearTouchTargets(null);
			// In case view is detached while transition is running
			mLayoutSuppressed = false;
			// Tear down our drag tracking
			mDragNotifiedChildren = null;
			if (mCurrentDrag != null)
			{
				mCurrentDrag.recycle();
				mCurrentDrag = null;
			}
			int count = mChildrenCount;
			android.view.View[] children = mChildren;
			{
				for (int i = 0; i < count; i++)
				{
					children[i].dispatchDetachedFromWindow();
				}
			}
			base.dispatchDetachedFromWindow();
		}
            /// <summary>
            /// Gets an embedded session using the given properties.
            /// </summary>
            /// <remarks>
            /// It is assumed (but not checked) that the given properties
            /// object requests a session with a res: protocol database
            /// instance; work is performed toward configuring and locking
            /// the ambient class loading environment to correctly handle
            /// searching the transitive closure of <c>ikvmres:</c>
            /// protocol resources reachable by compile-time reference, 
            /// starting with the assemblies referenced on the call stack,
            /// as well as the entry level, calling and executing assemblies
            /// and their related satellite assemblies.
            /// </remarks>
            /// <param name="properties">The properties.</param>
            /// <returns>an embedded session</returns>
            internal static HsqlSession NewEmbeddedResSession(
                HsqlProperties properties)
            {
                StackTrace trace = new StackTrace();
                java.util.Set set = new java.util.HashSet();

                foreach (StackFrame frame in trace.GetFrames())
                {
                    set.add(frame.GetMethod().DeclaringType.Assembly.FullName);
                }

                List<Assembly> startingList = new List<Assembly>();

                foreach (string name in set.toArray())
                {
                    try
                    {
                        startingList.Add(Assembly.Load(name));
                    }
                    catch { }
                }

                startingList.Add(Assembly.GetExecutingAssembly());
                startingList.Add(Assembly.GetCallingAssembly());

                if (Assembly.GetEntryAssembly() != null)
                {
                    startingList.Add(Assembly.GetEntryAssembly());
                }

                java.lang.ClassLoader loader
                    = IkvmResourceLoaderFactory.CreateLoader(startingList);

                lock (s_resLock)
                {
                    org.hsqldb.lib.ResourceStreamProvider.setLoader(loader);

                    return HsqlSession.Factory.NewEmbeddedSession(properties);
                }
            }
Exemple #19
0
        protected internal virtual Shape makeShapeFromNode(ViewGraphNode act, LinkedList queue)
        {
            System.Drawing.Color bg       = getBackgroundColorForNode(act);
            System.Drawing.Color border   = getBorderColorForNode(act);
            System.String        desc     = "";
            BaseNode             reteNode = act.ReteNode;
            HashSet terminalNodes         = new HashSet();

            getCorrespondingTerminalNodes(act, terminalNodes);
            if (reteNode != null)
            {
                desc = reteNode.NodeId.ToString();
            }
            Shape s;

            if (reteNode == null)
            {
                // ROOT NODE
                s = new Ellipse();
            }
            else if (reteNode is BaseJoin || act.ReteNode is BaseAlpha2)
            {
                s = new Trapezoid();
            }
            else if (reteNode is TerminalNode)
            {
                s = new RoundedRectangle();
            }
            else if (reteNode is LIANode)
            {
                s = new Ellipse();
            }
            else
            {
                s = new Rectangle();
            }
            s.Bgcolor     = bg;
            s.Bordercolor = border;
            //UPGRADE_WARNING: Narrowing conversions may produce unexpected results in C#. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1042"'
            int x = (spaceHorizontal / 2) + (int)((float)(act.X * (spaceHorizontal + nodeHorizontal)) / 2.0);
            int y = (spaceVertical / 2) + act.Y * (spaceVertical + nodeVertical);

            System.String key = x + "," + y;
            // if there is already a node at the given location, we shift it right
            while (this.coordinates.ContainsKey(key))
            {
                x   = x + ((spaceHorizontal + nodeHorizontal) * 2);
                key = x + "," + y;
            }
            SupportClass.PutElement(coordinates, key, s);
            s.X      = x;
            s.Y      = y;
            s.Width  = nodeHorizontal;
            s.Height = nodeVertical;
            System.String longdesc = "";
            if (reteNode == null)
            {
                longdesc = "Root Node";
            }
            else
            {
                longdesc  = "ID:" + reteNode.NodeId + "  NodeType:" + reteNode.GetType().FullName;
                longdesc += "  Details:" + reteNode.toPPString();
            }
            longdesc += "  Rules:";
            Iterator iter = terminalNodes.iterator();

            while (iter.hasNext())
            {
                TerminalNode t = (TerminalNode)iter.next();

                longdesc += t.Rule.Name;
                if (iter.hasNext())
                {
                    longdesc += ";";
                }
            }
            s.LongDescription = longdesc;
            if (reteNode is LIANode)
            {
                s.incWidth(-nodeHorizontal / 3);
            }
            s.Text    = desc;
            act.Shape = s;
            addPrimitive(s);
            for (Iterator it = act.Successors.iterator(); it.hasNext();)
            {
                ViewGraphNode n = (ViewGraphNode)it.next();
                queue.add(n);
            }
            return(s);
        }
        /// <summary>
        /// <para>
        /// Finds the resource URL closure for the given starting assembly list.
        /// </para>
        /// The closure is computed recursively from the referenced assemblies;
        /// satellite assemblies for the current culture are included also.
        /// </summary>
        /// <remarks>
        /// Referenced System, IKVM, Hsqldb core and NUnit assemblies are excluded.
        /// </remarks>
        /// <param name="startingList">The starting assembly list.</param>
        /// <returns>
        /// An array of <c>ikvmres:</c> protocol URLs describing the useful portion
        /// of the reference closure for the starting list.
        /// </returns>
        //[CLSCompliant(false)]
        public static URL[] FindResourceURLClosure(List<Assembly> startingList)
        {
            if (startingList == null)
            {
                throw new ArgumentNullException("startingList");
            }

            Set included = new HashSet();
            Set encountered = new HashSet();

            foreach (Assembly entry in startingList)
            {
                AddAssembly(encountered, included, entry);
            }

            Assembly[] assemblies = new Assembly[included.size()];

            included.toArray(assemblies);

            URL[] urls = new URL[included.size()];

            for (int i = 0; i < assemblies.Length; i++)
            {
                Assembly entry = assemblies[i];
                string entryName = URLEncoder.encode(entry.FullName, "UTF-8");
                string entryUrl = string.Concat("ikvmres://", entryName, "/");

                try
                {
                    urls[i] = new URL(entryUrl);
                }
                catch (Exception ex)
                {
            #if DEBUG
                    Debug.WriteLine("URL: " + entryUrl);
                    Debug.WriteLine(ex);
            #endif
                }
            }

            return urls;
        }
Exemple #21
0
 internal AttributedIterator(AttributedString attrString,
         AttributedCharacterIteratorNS.Attribute[] attributes, int begin,
         int end)
 {
     if (begin < 0 || end > attrString.text.Length || begin > end) {
         throw new java.lang.IllegalArgumentException();
     }
     this.begin = begin;
     this.end = end;
     offset = begin;
     this.attrString = attrString;
     if (attributes != null) {
         java.util.HashSet<AttributedCharacterIteratorNS.Attribute> set = new java.util.HashSet<AttributedCharacterIteratorNS.Attribute>(
                 (attributes.Length * 4 / 3) + 1);
         for (int i = attributes.Length; --i >= 0;) {
             set.add(attributes[i]);
         }
         attributesAllowed = set;
     }
 }
Exemple #22
0
        /**
            * Returns a set of attributes present in the {@code AttributedString}.
            * An empty set returned indicates that no attributes where defined.
            *
            * @return a set of attribute keys that may be empty.
            */
        public java.util.Set<AttributedCharacterIteratorNS.Attribute> getAllAttributeKeys()
        {
            if (begin == 0 && end == attrString.text.Length
                    && attributesAllowed == null) {
                return attrString.attributeMap.keySet();
            }

            java.util.Set<AttributedCharacterIteratorNS.Attribute> result = new java.util.HashSet<AttributedCharacterIteratorNS.Attribute>();//(attrString.attributeMap.size() * 4 / 3) + 1);
            java.util.Iterator<java.util.MapNS.Entry<AttributedCharacterIteratorNS.Attribute, java.util.List<IAC_Range>>> it = attrString.attributeMap
                    .entrySet().iterator();
            while (it.hasNext()) {
                java.util.MapNS.Entry<AttributedCharacterIteratorNS.Attribute, java.util.List<IAC_Range>> entry = it.next();
                if (attributesAllowed == null
                        || attributesAllowed.contains(entry.getKey())) {
                    java.util.List<IAC_Range> ranges = entry.getValue();
                    if (inRange(ranges)) {
                        result.add(entry.getKey());
                    }
                }
            }
            return result;
        }
 /**
  * Returns a {@link Collection} containing the intersection
  * of the given {@link Collection}s.
  * <p>
  * The cardinality of each element in the returned {@link Collection}
  * will be equal to the minimum of the cardinality of that element
  * in the two given {@link Collection}s.
  *
  * @param a  the first collection, must not be null
  * @param b  the second collection, must not be null
  * @return the intersection of the two collections
  * @see Collection#retainAll
  * @see #containsAny
  */
 public static java.util.Collection<Object> intersection(java.util.Collection<Object> a, java.util.Collection<Object> b)
 {
     java.util.ArrayList<Object> list = new java.util.ArrayList<Object>();
     java.util.Map<Object, Object> mapa = getCardinalityMap(a);
     java.util.Map<Object, Object> mapb = getCardinalityMap(b);
     java.util.Set<Object> elts = new java.util.HashSet<Object>(a);
     elts.addAll(b);
     java.util.Iterator<Object> it = elts.iterator();
     while (it.hasNext())
     {
         Object obj = it.next();
         for (int i = 0, m = java.lang.Math.min(getFreq(obj, mapa), getFreq(obj, mapb)); i < m; i++)
         {
             list.add(obj);
         }
     }
     return list;
 }
Exemple #24
0
        protected internal virtual Shape makeShapeFromNode(ViewGraphNode act, LinkedList queue)
        {
            System.Drawing.Color bg = getBackgroundColorForNode(act);
            System.Drawing.Color border = getBorderColorForNode(act);
            System.String desc = "";
            BaseNode reteNode = act.ReteNode;
            HashSet terminalNodes = new HashSet();
            getCorrespondingTerminalNodes(act, terminalNodes);
            if (reteNode != null)
                desc = reteNode.NodeId.ToString();
            Shape s;
            if (reteNode == null)
            {
                // ROOT NODE
                s = new Ellipse();
            }
            else if (reteNode is BaseJoin || act.ReteNode is BaseAlpha2)
            {
                s = new Trapezoid();
            }
            else if (reteNode is TerminalNode)
            {
                s = new RoundedRectangle();
            }
            else if (reteNode is LIANode)
            {
                s = new Ellipse();
            }
            else
            {
                s = new Rectangle();
            }
            s.Bgcolor = bg;
            s.Bordercolor = border;
            //UPGRADE_WARNING: Narrowing conversions may produce unexpected results in C#. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1042"'
            int x = (spaceHorizontal / 2) + (int) ((float) (act.X * (spaceHorizontal + nodeHorizontal)) / 2.0);
            int y = (spaceVertical / 2) + act.Y * (spaceVertical + nodeVertical);
            System.String key = x + "," + y;
            // if there is already a node at the given location, we shift it right
            while (this.coordinates.ContainsKey(key))
            {
                x = x + ((spaceHorizontal + nodeHorizontal) * 2);
                key = x + "," + y;
            }
            SupportClass.PutElement(coordinates, key, s);
            s.X = x;
            s.Y = y;
            s.Width = nodeHorizontal;
            s.Height = nodeVertical;
            System.String longdesc = "";
            if (reteNode == null)
            {
                longdesc = "Root Node";
            }
            else
            {
                longdesc = "ID:" + reteNode.NodeId + "  NodeType:" + reteNode.GetType().FullName;
                longdesc += "  Details:" + reteNode.toPPString();
            }
            longdesc += "  Rules:";
            Iterator iter = terminalNodes.iterator();
            while (iter.hasNext())
            {
                TerminalNode t = (TerminalNode) iter.next();

                longdesc += t.Rule.Name;
                if (iter.hasNext())
                    longdesc += ";";
            }
            s.LongDescription = longdesc;
            if (reteNode is LIANode)
                s.incWidth(- nodeHorizontal / 3);
            s.Text = desc;
            act.Shape = s;
            addPrimitive(s);
            for (Iterator it = act.Successors.iterator(); it.hasNext(); )
            {
                ViewGraphNode n = (ViewGraphNode) it.next();
                queue.add(n);
            }
            return s;
        }
Exemple #25
0
		public override bool dispatchDragEvent(android.view.DragEvent @event)
		{
			bool retval = false;
			float tx = @event.mX;
			float ty = @event.mY;
			android.view.ViewRootImpl root = getViewRootImpl();
			switch (@event.mAction)
			{
				case android.view.DragEvent.ACTION_DRAG_STARTED:
				{
					// Dispatch down the view hierarchy
					// clear state to recalculate which views we drag over
					mCurrentDragView = null;
					// Set up our tracking of drag-started notifications
					mCurrentDrag = android.view.DragEvent.obtain(@event);
					if (mDragNotifiedChildren == null)
					{
						mDragNotifiedChildren = new java.util.HashSet<android.view.View>();
					}
					else
					{
						mDragNotifiedChildren.clear();
					}
					// Now dispatch down to our children, caching the responses
					mChildAcceptsDrag = false;
					int count = mChildrenCount;
					android.view.View[] children = mChildren;
					{
						for (int i = 0; i < count; i++)
						{
							android.view.View child = children[i];
							child.mPrivateFlags2 &= ~android.view.View.DRAG_MASK;
							if (child.getVisibility() == VISIBLE)
							{
								bool handled = notifyChildOfDrag(children[i]);
								if (handled)
								{
									mChildAcceptsDrag = true;
								}
							}
						}
					}
					// Return HANDLED if one of our children can accept the drag
					if (mChildAcceptsDrag)
					{
						retval = true;
					}
					break;
				}

				case android.view.DragEvent.ACTION_DRAG_ENDED:
				{
					// Release the bookkeeping now that the drag lifecycle has ended
					if (mDragNotifiedChildren != null)
					{
						foreach (android.view.View child in Sharpen.IterableProxy.Create(mDragNotifiedChildren
							))
						{
							// If a child was notified about an ongoing drag, it's told that it's over
							child.dispatchDragEvent(@event);
							child.mPrivateFlags2 &= ~android.view.View.DRAG_MASK;
							child.refreshDrawableState();
						}
						mDragNotifiedChildren.clear();
						mCurrentDrag.recycle();
						mCurrentDrag = null;
					}
					// We consider drag-ended to have been handled if one of our children
					// had offered to handle the drag.
					if (mChildAcceptsDrag)
					{
						retval = true;
					}
					break;
				}

				case android.view.DragEvent.ACTION_DRAG_LOCATION:
				{
					// Find the [possibly new] drag target
					android.view.View target = findFrontmostDroppableChildAt(@event.mX, @event.mY, mLocalPoint
						);
					// If we've changed apparent drag target, tell the view root which view
					// we're over now [for purposes of the eventual drag-recipient-changed
					// notifications to the framework] and tell the new target that the drag
					// has entered its bounds.  The root will see setDragFocus() calls all
					// the way down to the final leaf view that is handling the LOCATION event
					// before reporting the new potential recipient to the framework.
					if (mCurrentDragView != target)
					{
						root.setDragFocus(target);
						int action = @event.mAction;
						// If we've dragged off of a child view, send it the EXITED message
						if (mCurrentDragView != null)
						{
							android.view.View view = mCurrentDragView;
							@event.mAction = android.view.DragEvent.ACTION_DRAG_EXITED;
							view.dispatchDragEvent(@event);
							view.mPrivateFlags2 &= ~android.view.View.DRAG_HOVERED;
							view.refreshDrawableState();
						}
						mCurrentDragView = target;
						// If we've dragged over a new child view, send it the ENTERED message
						if (target != null)
						{
							@event.mAction = android.view.DragEvent.ACTION_DRAG_ENTERED;
							target.dispatchDragEvent(@event);
							target.mPrivateFlags2 |= android.view.View.DRAG_HOVERED;
							target.refreshDrawableState();
						}
						@event.mAction = action;
					}
					// restore the event's original state
					// Dispatch the actual drag location notice, localized into its coordinates
					if (target != null)
					{
						@event.mX = mLocalPoint.x;
						@event.mY = mLocalPoint.y;
						retval = target.dispatchDragEvent(@event);
						@event.mX = tx;
						@event.mY = ty;
					}
					break;
				}

				case android.view.DragEvent.ACTION_DRAG_EXITED:
				{
					if (mCurrentDragView != null)
					{
						android.view.View view = mCurrentDragView;
						view.dispatchDragEvent(@event);
						view.mPrivateFlags2 &= ~android.view.View.DRAG_HOVERED;
						view.refreshDrawableState();
						mCurrentDragView = null;
					}
					break;
				}

				case android.view.DragEvent.ACTION_DROP:
				{
					android.view.View target = findFrontmostDroppableChildAt(@event.mX, @event.mY, mLocalPoint
						);
					if (target != null)
					{
						@event.mX = mLocalPoint.x;
						@event.mY = mLocalPoint.y;
						retval = target.dispatchDragEvent(@event);
						@event.mX = tx;
						@event.mY = ty;
					}
					break;
				}
			}
			// If none of our children could handle the event, try here
			if (!retval)
			{
				// Call up to the View implementation that dispatches to installed listeners
				retval = base.dispatchDragEvent(@event);
			}
			return retval;
		}