Beispiel #1
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);
        }
Beispiel #2
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);
        }
Beispiel #3
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);
 }
Beispiel #4
0
        //
        // 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);
                    }
                }
            }
        }
Beispiel #5
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));
                }
            }
Beispiel #6
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;
     }
 }
Beispiel #7
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");
		}
Beispiel #8
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);
            }
Beispiel #9
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;
 }
            /// <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);
                }
            }
Beispiel #11
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;
        }
Beispiel #12
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;
     }
 }