Esempio n. 1
0
 /// <exception cref="VPackException"/>
 public virtual string toJson(VPackSlice vpack, bool includeNullValues
                              )
 {
     java.lang.StringBuilder json = new java.lang.StringBuilder();
     this.parse(null, null, vpack, json, includeNullValues);
     return(json.ToString());
 }
Esempio n. 2
0
        public static string Join(string separator, IEnumerable <string> values)
        {
            if (values == null)
            {
                throw new ArgumentNullException("values");
            }
            if (separator == null)
            {
                separator = string.Empty;
            }

            javaStringBuilder resultBuilder = new javaStringBuilder();
            bool first = true;

            foreach (string v in values)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    resultBuilder.append(separator);
                }

                if (v != null)
                {
                    resultBuilder.append(v);
                }
            }
            return(resultBuilder.ToString());
        }
Esempio n. 3
0
 public string encode(string s, java.nio.charset.Charset charset)
 {
     // Guess a bit larger for encoded form
     java.lang.StringBuilder builder = new java.lang.StringBuilder(s.Length + 16);
     appendEncoded(builder, s, charset, false);
     return(builder.ToString());
 }
Esempio n. 4
0
 public override string ToString()
 {
     java.lang.StringBuilder sb = new java.lang.StringBuilder(128);
     sb.append("{");
     sb.append(applicationDensity);
     sb.append("dpi");
     if (isScalingRequired())
     {
         sb.append(" ");
         sb.append(applicationScale);
         sb.append("x");
     }
     if (!supportsScreen())
     {
         sb.append(" resizing");
     }
     if (neverSupportsScreen())
     {
         sb.append(" never-compat");
     }
     if (alwaysSupportsScreen())
     {
         sb.append(" always-compat");
     }
     sb.append("}");
     return(sb.ToString());
 }
Esempio n. 5
0
        public static string Replace(java.lang.String str, string oldStr, string newStr)
        {
            ThrowHelper.ThrowIfNull(oldStr);
            int lenOld = ((java.lang.String)(object) oldStr).length();

            if (lenOld == 0)
            {
                throw new System.ArgumentException();
            }

            int idx1 = str.indexOf(oldStr, 0);

            if (idx1 == -1)
            {
                return((string)(object)str);
            }
            int idx0 = 0;
            int len  = str.length();
            var sb   = new java.lang.StringBuilder();

            for (;;)
            {
                sb.append(str.substring(idx0, idx1));
                if (newStr != null)
                {
                    sb.append(newStr);
                }
                if ((idx0 = idx1 + lenOld) >= len ||
                    (idx1 = str.indexOf(oldStr, idx0)) == -1)
                {
                    sb.append(str.substring(idx0));
                    return(sb.ToString());
                }
            }
        }
Esempio n. 6
0
            static string ToStringMulti(long v, java.lang.reflect.Field[] fields, int n)
            {
                var  v0    = v;
                var  sb    = new java.lang.StringBuilder();
                bool comma = false;

                for (int i = 0; i < n; i++)
                {
                    var f = fields[i];
                    if (f.getModifiers() == (java.lang.reflect.Modifier.PUBLIC
                                             | java.lang.reflect.Modifier.STATIC))
                    {
                        f.setAccessible(true);
                        var fv = f.getLong(null);

                        if ((fv & v) == fv)
                        {
                            if (fv == 0 && v0 != 0)
                            {
                                // skip field for zero, if value was not zero
                                continue;
                            }
                            v &= ~fv;
                            if (comma)
                            {
                                sb.append(", ");
                            }
                            sb.append(f.getName());
                            comma = true;
                        }
                    }
                }

                return((v == 0) ? sb.ToString() : null);
            }
Esempio n. 7
0
 internal string toString(long now)
 {
     java.lang.StringBuilder b = new java.lang.StringBuilder();
     b.append("{ what=");
     b.append(what);
     b.append(" when=");
     android.util.TimeUtils.formatDuration(when - now, b);
     if (arg1 != 0)
     {
         b.append(" arg1=");
         b.append(arg1);
     }
     if (arg2 != 0)
     {
         b.append(" arg2=");
         b.append(arg2);
     }
     if (obj != null)
     {
         b.append(" obj=");
         b.append(obj);
     }
     b.append(" }");
     return(b.ToString());
 }
Esempio n. 8
0
        /// <summary>
        /// Returns the ASCII characters up to but not including the next "\r\n", or
        /// "\n".
        /// </summary>
        /// <remarks>
        /// Returns the ASCII characters up to but not including the next "\r\n", or
        /// "\n".
        /// </remarks>
        /// <exception cref="java.io.EOFException">
        /// if the stream is exhausted before the next newline
        /// character.
        /// </exception>
        /// <exception cref="System.IO.IOException"></exception>
        public static string readAsciiLine(java.io.InputStream @in)
        {
            // TODO: support UTF-8 here instead
            java.lang.StringBuilder result = new java.lang.StringBuilder(80);
            while (true)
            {
                int c = @in.read();
                if (c == -1)
                {
                    throw new java.io.EOFException();
                }
                else
                {
                    if (c == '\n')
                    {
                        break;
                    }
                }
                result.append((char)c);
            }
            int length = result.Length;

            if (length > 0 && result[length - 1] == '\r')
            {
                result.setLength(length - 1);
            }
            return(result.ToString());
        }
Esempio n. 9
0
 private void updateText(long now)
 {
     lock (this)
     {
         long seconds = now - mBase;
         seconds /= 1000;
         string text = android.text.format.DateUtils.formatElapsedTime(mRecycle, seconds);
         if (mFormat != null)
         {
             System.Globalization.CultureInfo loc = System.Globalization.CultureInfo.CurrentCulture;
             if (mFormatter == null || !loc.Equals(mFormatterLocale))
             {
                 mFormatterLocale = loc;
                 mFormatter       = new java.util.Formatter(mFormatBuilder, loc);
             }
             mFormatBuilder.setLength(0);
             mFormatterArgs[0] = text;
             try
             {
                 mFormatter.format(mFormat, mFormatterArgs);
                 text = mFormatBuilder.ToString();
             }
             catch (java.util.IllegalFormatException)
             {
                 if (!mLogged)
                 {
                     android.util.Log.w(TAG, "Illegal format string: " + mFormat);
                     mLogged = true;
                 }
             }
         }
         setText(java.lang.CharSequenceProxy.Wrap(text));
     }
 }
Esempio n. 10
0
 /// <summary>Print a progress bar and percent of progress to console.</summary>
 /// <remarks>
 /// Print a progress bar and percent of progress to console. In this format:
 /// [====================================================================================================]
 /// 100%
 /// </remarks>
 /// <param name="percentProgress">
 /// Percent of progress. Integer value has to be
 /// between 0 and 100.
 /// </param>
 public static void printProgressBar(int percentProgress)
 {
     if (percentProgress >= 0 || percentProgress <= 100)
     {
         java.lang.StringBuilder sb = new java.lang.StringBuilder();
         sb.append("[");
         for (int i = 0; i < percentProgress; i++)
         {
             sb.append("=");
         }
         for (int i_1 = 100; i_1 > percentProgress; i_1--)
         {
             sb.append(".");
         }
         sb.append("] ");
         sb.append(percentProgress);
         sb.append("%");
         sb.append("\r");
         Console.Out.Write(sb.ToString());
     }
     else
     {
         Console.Out.Write("Input has to between 0 and 100.");
     }
 }
Esempio n. 11
0
 public override string ToString()
 {
     java.lang.StringBuilder sb = new java.lang.StringBuilder(64);
     sb.append("Transformation");
     toShortString(sb);
     return(sb.ToString());
 }
Esempio n. 12
0
 public override string ToString()
 {
     if (isEmpty())
     {
         return("[]");
     }
     java.lang.StringBuilder buffer = new java.lang.StringBuilder(size() * 16);
     buffer.append('[');
     java.util.Iterator <E> it = iterator();
     while (it.hasNext())
     {
         object next = it.next();
         if (next != this)
         {
             buffer.append(next);
         }
         else
         {
             buffer.append("(this Collection)");
         }
         if (it.hasNext())
         {
             buffer.append(", ");
         }
     }
     buffer.append(']');
     return(buffer.ToString());
 }
Esempio n. 13
0
        public RewriterResults rewrite(Gadget gadget, MutableContent content)
        {
            if (gadget.getSpec().getModulePrefs().getFeatures().ContainsKey("caja") ||
                "1".Equals(gadget.getContext().getParameter("caja")))
            {
                URI          retrievedUri = gadget.getContext().getUrl();
                UriCallback2 cb           = new UriCallback2(retrievedUri);

                MessageQueue          mq    = new SimpleMessageQueue();
                DefaultGadgetRewriter rw    = new DefaultGadgetRewriter(mq);
                CharProducer          input = CharProducer.Factory.create(
                    new java.io.StringReader(content.getContent()),
                    FilePosition.instance(new InputSource(new java.net.URI(retrievedUri.ToString())), 2, 1, 1));
                java.lang.StringBuilder output = new java.lang.StringBuilder();

                try
                {
                    rw.rewriteContent(new java.net.URI(retrievedUri.ToString()), input, cb, output);
                }
                catch (GadgetRewriteException e)
                {
                    throwCajolingException(e, mq);
                    return(RewriterResults.notCacheable());
                }
                catch (IOException e)
                {
                    throwCajolingException(e, mq);
                    return(RewriterResults.notCacheable());
                }
                content.setContent(tameCajaClientApi() + output.ToString());
            }
            return(null);
        }
Esempio n. 14
0
        public static string Join(string separator, params object[] values)
        {
            if (values == null)
            {
                throw new ArgumentNullException("values");
            }
            if ((values.Length == 0) || (values[0] == null))
            {
                return(string.Empty);
            }
            if (separator == null)
            {
                separator = string.Empty;
            }

            javaStringBuilder resultBuilder = new javaStringBuilder();

            resultBuilder.append(values[0].ToString() ?? string.Empty);

            for (int i = 1; i < values.Length; i++)
            {
                resultBuilder.append(separator);
                resultBuilder.append(values[i].ToString() ?? string.Empty);
            }

            return(resultBuilder.ToString());
        }
Esempio n. 15
0
        //
        // Format
        //

        public static string Format(System.IFormatProvider provider,
                                    java.lang.String format, object[] args)
        {
            var sb = new java.lang.StringBuilder();

            system.text.StringBuilder.AppendFormatHelper(sb, provider, format, args);
            return(sb.ToString());
        }
Esempio n. 16
0
 /// <summary>Method convert public key String to block format and add a title.</summary>
 /// <remarks>Method convert public key String to block format and add a title.</remarks>
 /// <param name="publicKey">String converted to char array and than to block String</param>
 /// <returns>Return block String of publicKey</returns>
 public static string printPublicKeyBlock(string publicKey)
 {
     java.lang.StringBuilder sb = new java.lang.StringBuilder();
     sb.append("\nPublic Key:\n");
     sb.append(CryptobyHelper.charToBlockString(publicKey.ToCharArray()));
     sb.append(EOB);
     return(sb.ToString());
 }
Esempio n. 17
0
 private void flushBuilder()
 {
     if (mBuilder.Length > 0)
     {
         android.util.Log.println_native(mBuffer, mPriority, mTag, mBuilder.ToString());
         mBuilder.delete(0, mBuilder.Length);
     }
 }
Esempio n. 18
0
        public static string Concat(object objA, object objB, object objC, object objD)
        {
            var sb = new java.lang.StringBuilder();

            AppendIfNotNull(sb, objA);
            AppendIfNotNull(sb, objB);
            AppendIfNotNull(sb, objC);
            AppendIfNotNull(sb, objD);
            return(sb.ToString());
        }
Esempio n. 19
0
 /// <summary>
 /// Method merge inputs and add a title to return String which can print
 /// encrypted text and title in User Interfaces.
 /// </summary>
 /// <remarks>
 /// Method merge inputs and add a title to return String which can print
 /// encrypted text and title in User Interfaces.
 /// </remarks>
 /// <param name="cryptType">Type of cryptology implementation as String</param>
 /// <param name="inputKeySize">Size of used key as integer</param>
 /// <param name="inputCharTextHex">
 /// Char array of String which will be converted to
 /// block
 /// </param>
 /// <returns>Return String of merged input parameter and text</returns>
 public static string printHexBlock(string cryptType, int inputKeySize, char[] inputCharTextHex
                                    )
 {
     java.lang.StringBuilder sb = new java.lang.StringBuilder();
     sb.append("\n").append(cryptType).append("-").append(inputKeySize).append(" encrypted Text in Hex form (Copy with '"
                                                                               + EOB + "'):\n");
     sb.append(CryptobyHelper.charToBlockString(inputCharTextHex));
     sb.append(EOB);
     return(sb.ToString());
 }
Esempio n. 20
0
        private static string ConcatArray(string[] strArray, int resultLength)
        {
            javaStringBuilder builder = new javaStringBuilder(resultLength);

            for (int i = 0; i < strArray.Length; i++)
            {
                builder.append(strArray[i]);
            }
            return(builder.ToString());
        }
Esempio n. 21
0
        public static string Concat(string strA, string strB, string strC, string strD)
        {
            var sb = new java.lang.StringBuilder();

            AppendIfNotNull(sb, strA);
            AppendIfNotNull(sb, strB);
            AppendIfNotNull(sb, strC);
            AppendIfNotNull(sb, strD);
            return(sb.ToString());
        }
Esempio n. 22
0
        public static string Concat(IEnumerable <string> values)
        {
            javaStringBuilder builder = new javaStringBuilder();

            foreach (string val in values)
            {
                builder.append(val ?? string.Empty);
            }
            return(builder.ToString());
        }
Esempio n. 23
0
        public static string Concat <T>(IEnumerable <T> values)
        {
            javaStringBuilder builder = new javaStringBuilder();

            foreach (T val in values)
            {
                string text = val.ToString();
                builder.append(text ?? string.Empty);
            }
            return(builder.ToString());
        }
Esempio n. 24
0
        //
        // Concat string
        //

        public static string Concat(string[] strs)
        {
            ThrowHelper.ThrowIfNull(strs);
            var sb = new java.lang.StringBuilder();

            foreach (var str in strs)
            {
                AppendIfNotNull(sb, str);
            }
            return(sb.ToString());
        }
Esempio n. 25
0
        public static string Concat(object[] objs)
        {
            ThrowHelper.ThrowIfNull(objs);
            var sb = new java.lang.StringBuilder();

            foreach (var obj in objs)
            {
                AppendIfNotNull(sb, obj);
            }
            return(sb.ToString());
        }
Esempio n. 26
0
        //
        // Concat enumerator
        //

        public static string Concat <T>(System.Collections.Generic.IEnumerable <T> enumerable)
        {
            ThrowHelper.ThrowIfNull(enumerable);
            var sb = new java.lang.StringBuilder();

            foreach (var obj in enumerable)
            {
                AppendIfNotNull(sb, obj);
            }
            return(sb.ToString());
        }
Esempio n. 27
0
 public override string ToString()
 {
     java.lang.StringBuilder result = new java.lang.StringBuilder(_limit - _position);
     {
         for (int i = _position; i < _limit; i++)
         {
             result.append(get(i));
         }
     }
     return(result.ToString());
 }
Esempio n. 28
0
 public override string ToString()
 {
     java.lang.StringBuilder buf = new java.lang.StringBuilder();
     buf.append(GetType().FullName);
     buf.append(", status: capacity=");
     buf.append(_capacity);
     buf.append(" position=");
     buf.append(_position);
     buf.append(" limit=");
     buf.append(_limit);
     return(buf.ToString());
 }
Esempio n. 29
0
 public override string ToString()
 {
     java.lang.StringBuilder sb = new java.lang.StringBuilder(32);
     sb.append("Rect(");
     sb.append(left);
     sb.append(", ");
     sb.append(top);
     sb.append(" - ");
     sb.append(right);
     sb.append(", ");
     sb.append(bottom);
     sb.append(")");
     return(sb.ToString());
 }
Esempio n. 30
0
 /// <summary>Return a string representation of the rectangle in a well-defined format.
 ///     </summary>
 /// <remarks>
 /// Return a string representation of the rectangle in a well-defined format.
 /// <p>You can later recover the Rect from this string through
 /// <see cref="unflattenFromString(string)">unflattenFromString(string)</see>
 /// .
 /// </remarks>
 /// <returns>Returns a new String of the form "left top right bottom"</returns>
 public string flattenToString()
 {
     java.lang.StringBuilder sb = new java.lang.StringBuilder(32);
     // WARNING: Do not change the format of this string, it must be
     // preserved because Rects are saved in this flattened format.
     sb.append(left);
     sb.append(' ');
     sb.append(top);
     sb.append(' ');
     sb.append(right);
     sb.append(' ');
     sb.append(bottom);
     return(sb.ToString());
 }
Esempio n. 31
0
		public override string ToString ()
		{
			java.lang.StringBuilder sb = new java.lang.StringBuilder ();
			sb.append ("TypedValue{t=0x").append (Sharpen.Util.IntToHexString (type));
			sb.append ("/d=0x").append (Sharpen.Util.IntToHexString (data));
			if (type == TYPE_STRING) {
				java.lang.CharSequence strseq = @string != null ? @string :
					java.lang.CharSequenceProxy.Wrap ("<null>");
				sb.append (" \"").append (strseq).append ("\"");
			}
			if (assetCookie != 0) {
				sb.append (" a=").append (assetCookie);
			}
			if (resourceId != 0) {
				sb.append (" r=0x").append (Sharpen.Util.IntToHexString (resourceId));
			}
			sb.append ("}");
			return sb.ToString ();
		}
Esempio n. 32
0
		/// <summary>
		/// Combines two arrays (of library names) such that they are
		/// concatenated in order but are devoid of duplicates.
		/// </summary>
		/// <remarks>
		/// Combines two arrays (of library names) such that they are
		/// concatenated in order but are devoid of duplicates. The
		/// result is a single string with the names of the libraries
		/// separated by colons, or <code>null</code> if both lists
		/// were <code>null</code> or empty.
		/// </remarks>
		/// <param name="list1">null-ok; the first list</param>
		/// <param name="list2">null-ok; the second list</param>
		/// <returns>null-ok; the combination</returns>
		private static string combineLibs(string[] list1, string[] list2)
		{
			java.lang.StringBuilder result = new java.lang.StringBuilder(300);
			bool first = true;
			if (list1 != null)
			{
				foreach (string s in list1)
				{
					if (first)
					{
						first = false;
					}
					else
					{
						result.append(':');
					}
					result.append(s);
				}
			}
			// Only need to check for duplicates if list1 was non-empty.
			bool dupCheck = !first;
			if (list2 != null)
			{
				foreach (string s in list2)
				{
					if (dupCheck && [email protected](list1, s))
					{
						continue;
					}
					if (first)
					{
						first = false;
					}
					else
					{
						result.append(':');
					}
					result.append(s);
				}
			}
			return result.ToString();
		}
Esempio n. 33
0
		public override string ToString()
		{
			java.lang.StringBuilder buf = new java.lang.StringBuilder();
			buf.append(GetType().FullName);
			buf.append(", status: capacity=");
			buf.append(_capacity);
			buf.append(" position=");
			buf.append(_position);
			buf.append(" limit=");
			buf.append(_limit);
			return buf.ToString();
		}
Esempio n. 34
0
        public RewriterResults rewrite(Gadget gadget, MutableContent content)
        {
            if (gadget.getSpec().getModulePrefs().getFeatures().ContainsKey("caja") ||
                "1".Equals(gadget.getContext().getParameter("caja"))) 
            {
                URI retrievedUri = gadget.getContext().getUrl();
                UriCallback2 cb = new UriCallback2(retrievedUri);

                MessageQueue mq = new SimpleMessageQueue();
                DefaultGadgetRewriter rw = new DefaultGadgetRewriter(mq);
                CharProducer input = CharProducer.Factory.create(
                    new java.io.StringReader(content.getContent()),
                    FilePosition.instance(new InputSource(new java.net.URI(retrievedUri.ToString())), 2, 1, 1));
                java.lang.StringBuilder output = new java.lang.StringBuilder();

                try 
                {
                    rw.rewriteContent(new java.net.URI(retrievedUri.ToString()), input, cb, output);
                }
                catch (GadgetRewriteException e)
                {
                    throwCajolingException(e, mq);
                    return RewriterResults.notCacheable();
                }
                catch (IOException e) 
                {
                    throwCajolingException(e, mq);
                    return RewriterResults.notCacheable();
                }
                content.setContent(tameCajaClientApi() + output.ToString());

            }
            return null;
        }
Esempio n. 35
0
		public static string dump(int[] states)
		{
			java.lang.StringBuilder sb = new java.lang.StringBuilder();
			int count = states.Length;
			{
				for (int i = 0; i < count; i++)
				{
					switch (states[i])
					{
						case [email protected]_window_focused:
						{
							sb.append("W ");
							break;
						}

						case [email protected]_pressed:
						{
							sb.append("P ");
							break;
						}

						case [email protected]_selected:
						{
							sb.append("S ");
							break;
						}

						case [email protected]_focused:
						{
							sb.append("F ");
							break;
						}

						case [email protected]_enabled:
						{
							sb.append("E ");
							break;
						}
					}
				}
			}
			return sb.ToString();
		}
Esempio n. 36
0
		/// <summary>
		/// Returns the ASCII characters up to but not including the next "\r\n", or
		/// "\n".
		/// </summary>
		/// <remarks>
		/// Returns the ASCII characters up to but not including the next "\r\n", or
		/// "\n".
		/// </remarks>
		/// <exception cref="java.io.EOFException">
		/// if the stream is exhausted before the next newline
		/// character.
		/// </exception>
		/// <exception cref="System.IO.IOException"></exception>
		public static string readAsciiLine(java.io.InputStream @in)
		{
			// TODO: support UTF-8 here instead
			java.lang.StringBuilder result = new java.lang.StringBuilder(80);
			while (true)
			{
				int c = @in.read();
				if (c == -1)
				{
					throw new java.io.EOFException();
				}
				else
				{
					if (c == '\n')
					{
						break;
					}
				}
				result.append((char)c);
			}
			int length = result.Length;
			if (length > 0 && result[length - 1] == '\r')
			{
				result.setLength(length - 1);
			}
			return result.ToString();
		}
Esempio n. 37
0
		public override string ToString()
		{
			java.lang.StringBuilder sb = new java.lang.StringBuilder(64);
			sb.append("Matrix{");
			toShortString(sb);
			sb.append('}');
			return sb.ToString();
		}
Esempio n. 38
0
		/// <summary>
		/// Returns a replacement string for the given one that has all backslashes
		/// and dollar signs escaped.
		/// </summary>
		/// <remarks>
		/// Returns a replacement string for the given one that has all backslashes
		/// and dollar signs escaped.
		/// </remarks>
		/// <param name="s">the input string.</param>
		/// <returns>
		/// the input string, with all backslashes and dollar signs having
		/// been escaped.
		/// </returns>
		public static string quoteReplacement(string s)
		{
			java.lang.StringBuilder result = new java.lang.StringBuilder(s.Length);
			{
				for (int i = 0; i < s.Length; i++)
				{
					char c = s[i];
					if (c == '\\' || c == '$')
					{
						result.append('\\');
					}
					result.append(c);
				}
			}
			return result.ToString();
		}
Esempio n. 39
0
		/// <param name="convertPlus">true to convert '+' to ' '.</param>
		public static string decode(string s, bool convertPlus, java.nio.charset.Charset 
			charset)
		{
			if (s.IndexOf('%') == -1 && (!convertPlus || s.IndexOf('+') == -1))
			{
				return s;
			}
			java.lang.StringBuilder result = new java.lang.StringBuilder(s.Length);
			java.io.ByteArrayOutputStream @out = new java.io.ByteArrayOutputStream();
			{
				for (int i = 0; i < s.Length; )
				{
					char c = s[i];
					if (c == '%')
					{
						do
						{
							if (i + 2 >= s.Length)
							{
								throw new System.ArgumentException("Incomplete % sequence at: " + i);
							}
							int d1 = hexToInt(s[i + 1]);
							int d2 = hexToInt(s[i + 2]);
							if (d1 == -1 || d2 == -1)
							{
								throw new System.ArgumentException("Invalid % sequence " + Sharpen.StringHelper.Substring
									(s, i, i + 3) + " at " + i);
							}
							@out.write(unchecked((byte)((d1 << 4) + d2)));
							i += 3;
						}
						while (i < s.Length && s[i] == '%');
						result.append(XobotOS.Runtime.Util.GetStringForBytes(@out.toByteArray(), charset)
							);
						@out.reset();
					}
					else
					{
						if (convertPlus && c == '+')
						{
							c = ' ';
						}
						result.append(c);
						i++;
					}
				}
			}
			return result.ToString();
		}
Esempio n. 40
0
		public string encode(string s, java.nio.charset.Charset charset)
		{
			// Guess a bit larger for encoded form
			java.lang.StringBuilder builder = new java.lang.StringBuilder(s.Length + 16);
			appendEncoded(builder, s, charset, false);
			return builder.ToString();
		}
Esempio n. 41
0
        /// <summary>
        /// Method merge inputs and add a title to return String which can print
        /// encrypted text and title in User Interfaces.
        /// </summary>
        /// <remarks>
        /// Method merge inputs and add a title to return String which can print
        /// encrypted text and title in User Interfaces.
        /// </remarks>
        /// <param name="cryptType">Type of cryptology implementation as String</param>
        /// <param name="inputKeySize">Size of used key as integer</param>
        /// <param name="inputCharTextHex">
        /// Char array of String which will be converted to
        /// block
        /// </param>
        /// <returns>Return String of merged input parameter and text</returns>
        public static string printHexBlock(string cryptType, int inputKeySize, char[] inputCharTextHex
			)
        {
            java.lang.StringBuilder sb = new java.lang.StringBuilder();
            sb.append("\n").append(cryptType).append("-").append(inputKeySize).append(" encrypted Text in Hex form (Copy with '"
                 + EOB + "'):\n");
            sb.append(CryptobyHelper.charToBlockString(inputCharTextHex));
            sb.append(EOB);
            return sb.ToString();
        }
Esempio n. 42
0
 /// <summary>Print a progress bar and percent of progress to console.</summary>
 /// <remarks>
 /// Print a progress bar and percent of progress to console. In this format:
 /// [====================================================================================================]
 /// 100%
 /// </remarks>
 /// <param name="percentProgress">
 /// Percent of progress. Integer value has to be
 /// between 0 and 100.
 /// </param>
 public static void printProgressBar(int percentProgress)
 {
     if (percentProgress >= 0 || percentProgress <= 100)
     {
         java.lang.StringBuilder sb = new java.lang.StringBuilder();
         sb.append("[");
         for (int i = 0; i < percentProgress; i++)
         {
             sb.append("=");
         }
         for (int i_1 = 100; i_1 > percentProgress; i_1--)
         {
             sb.append(".");
         }
         sb.append("] ");
         sb.append(percentProgress);
         sb.append("%");
         sb.append("\r");
         Console.Out.Write(sb.ToString());
     }
     else
     {
         Console.Out.Write("Input has to between 0 and 100.");
     }
 }
Esempio n. 43
0
 /// <summary>Method convert public key String to block format and add a title.</summary>
 /// <remarks>Method convert public key String to block format and add a title.</remarks>
 /// <param name="publicKey">String converted to char array and than to block String</param>
 /// <returns>Return block String of publicKey</returns>
 public static string printPublicKeyBlock(string publicKey)
 {
     java.lang.StringBuilder sb = new java.lang.StringBuilder();
     sb.append("\nPublic Key:\n");
     sb.append(CryptobyHelper.charToBlockString(publicKey.ToCharArray()));
     sb.append(EOB);
     return sb.ToString();
 }
Esempio n. 44
0
		/// <returns>
		/// The label to show for the shortcut. This includes the chording
		/// key (for example 'Menu+a'). Also, any non-human readable
		/// characters should be human readable (for example 'Menu+enter').
		/// </returns>
		internal string getShortcutLabel()
		{
			char shortcut = getShortcut();
			if (shortcut == 0)
			{
				return string.Empty;
			}
			java.lang.StringBuilder sb = new java.lang.StringBuilder(sPrependShortcutLabel);
			switch (shortcut)
			{
				case '\n':
				{
					sb.append(sEnterShortcutLabel);
					break;
				}

				case '\b':
				{
					sb.append(sDeleteShortcutLabel);
					break;
				}

				case ' ':
				{
					sb.append(sSpaceShortcutLabel);
					break;
				}

				default:
				{
					sb.append(shortcut);
					break;
				}
			}
			return sb.ToString();
		}
Esempio n. 45
0
		/// <summary>Flatten a byte[] into an XmlSerializer.</summary>
		/// <remarks>
		/// Flatten a byte[] into an XmlSerializer.  The list can later be read back
		/// with readThisByteArrayXml().
		/// </remarks>
		/// <param name="val">The byte array to be flattened.</param>
		/// <param name="name">
		/// Name attribute to include with this array's tag, or null for
		/// none.
		/// </param>
		/// <param name="out">XmlSerializer to write the array into.</param>
		/// <seealso cref="writeMapXml(java.util.Map{K, V}, java.io.OutputStream)">writeMapXml(java.util.Map&lt;K, V&gt;, java.io.OutputStream)
		/// 	</seealso>
		/// <seealso cref="writeValueXml(object, string, org.xmlpull.v1.XmlSerializer)">writeValueXml(object, string, org.xmlpull.v1.XmlSerializer)
		/// 	</seealso>
		/// <exception cref="org.xmlpull.v1.XmlPullParserException"></exception>
		/// <exception cref="System.IO.IOException"></exception>
		public static void writeByteArrayXml(byte[] val, string name, org.xmlpull.v1.XmlSerializer
			 @out)
		{
			if (val == null)
			{
				@out.startTag(null, "null");
				@out.endTag(null, "null");
				return;
			}
			@out.startTag(null, "byte-array");
			if (name != null)
			{
				@out.attribute(null, "name", name);
			}
			int N = val.Length;
			@out.attribute(null, "num", System.Convert.ToString(N));
			java.lang.StringBuilder sb = new java.lang.StringBuilder(val.Length * 2);
			{
				for (int i = 0; i < N; i++)
				{
					int b = val[i];
					int h = b >> 4;
					sb.append(h >= 10 ? ('a' + h - 10) : ('0' + h));
					h = b & unchecked((int)(0xff));
					sb.append(h >= 10 ? ('a' + h - 10) : ('0' + h));
				}
			}
			@out.text(sb.ToString());
			@out.endTag(null, "byte-array");
		}
Esempio n. 46
0
		public override string ToString()
		{
			java.lang.StringBuilder sb = new java.lang.StringBuilder(64);
			sb.append("Transformation");
			toShortString(sb);
			return sb.ToString();
		}
Esempio n. 47
0
 /// <summary>Convert a char array to block format with defined line length.</summary>
 /// <remarks>Convert a char array to block format with defined line length.</remarks>
 /// <param name="charTextHex">Char array from a String to convert</param>
 /// <returns>Return converted block String</returns>
 public static string charToBlockString(char[] charTextHex)
 {
     int lenLine = 64;
     java.lang.StringBuilder sb = new java.lang.StringBuilder();
     char[] temp = new char[lenLine];
     for (int i = 0; i < charTextHex.Length; i = i + lenLine)
     {
         if ((charTextHex.Length - i) < lenLine)
         {
             temp = new char[(charTextHex.Length - i)];
             Array.Copy(charTextHex, i, temp, 0, (charTextHex.Length - i));
             sb.append(new string(temp));
             sb.append("\n");
         }
         else
         {
             Array.Copy(charTextHex, i, temp, 0, lenLine);
             sb.append(new string(temp));
             sb.append("\n");
         }
     }
     return sb.ToString();
 }
Esempio n. 48
0
		/// <summary>Returns the next line of text available from this reader.</summary>
		/// <remarks>
		/// Returns the next line of text available from this reader. A line is
		/// represented by zero or more characters followed by
		/// <code>'\n'</code>
		/// ,
		/// <code>'\r'</code>
		/// ,
		/// <code>"\r\n"</code>
		/// or the end of the reader. The string does
		/// not include the newline sequence.
		/// </remarks>
		/// <returns>
		/// the contents of the line or
		/// <code>null</code>
		/// if no characters were
		/// read before the end of the reader has been reached.
		/// </returns>
		/// <exception cref="IOException">if this reader is closed or some other I/O error occurs.
		/// 	</exception>
		/// <exception cref="System.IO.IOException"></exception>
		public virtual string readLine()
		{
			lock (@lock)
			{
				checkNotClosed();
				if (pos == end && fillBuf() == -1)
				{
					return null;
				}
				{
					for (int charPos = pos; charPos < end; charPos++)
					{
						char ch = buf[charPos];
						if (ch > '\r')
						{
							continue;
						}
						if (ch == '\n')
						{
							string res = new string(buf, pos, charPos - pos);
							pos = charPos + 1;
							return res;
						}
						else
						{
							if (ch == '\r')
							{
								string res = new string(buf, pos, charPos - pos);
								pos = charPos + 1;
								if (((pos < end) || (fillBuf() != -1)) && (buf[pos] == '\n'))
								{
									pos++;
								}
								return res;
							}
						}
					}
				}
				char eol = '\0';
				java.lang.StringBuilder result = new java.lang.StringBuilder(80);
				result.append(buf, pos, end - pos);
				while (true)
				{
					pos = end;
					if (eol == '\n')
					{
						return result.ToString();
					}
					// attempt to fill buffer
					if (fillBuf() == -1)
					{
						// characters or null.
						return result.Length > 0 || eol != '\0' ? result.ToString() : null;
					}
					{
						for (int charPos_1 = pos; charPos_1 < end; charPos_1++)
						{
							char c = buf[charPos_1];
							if (eol == '\0')
							{
								if ((c == '\n' || c == '\r'))
								{
									eol = c;
								}
							}
							else
							{
								if (eol == '\r' && c == '\n')
								{
									if (charPos_1 > pos)
									{
										result.append(buf, pos, charPos_1 - pos - 1);
									}
									pos = charPos_1 + 1;
									return result.ToString();
								}
								else
								{
									if (charPos_1 > pos)
									{
										result.append(buf, pos, charPos_1 - pos - 1);
									}
									pos = charPos_1;
									return result.ToString();
								}
							}
						}
					}
					if (eol == '\0')
					{
						result.append(buf, pos, end - pos);
					}
					else
					{
						result.append(buf, pos, end - pos - 1);
					}
				}
			}
		}
Esempio n. 49
0
		public virtual string toShortString()
		{
			java.lang.StringBuilder sb = new java.lang.StringBuilder(64);
			toShortString(sb);
			return sb.ToString();
		}
Esempio n. 50
0
		private void maybeLogQueryToEventLog(long durationMillis, System.Uri uri, string[]
			 projection, string selection, string sortOrder)
		{
			int samplePercent = samplePercentForDuration(durationMillis);
			if (samplePercent < 100)
			{
				lock (mRandom)
				{
					if (Sharpen.Util.Random_NextInt(mRandom, 100) >= samplePercent)
					{
						return;
					}
				}
			}
			java.lang.StringBuilder projectionBuffer = new java.lang.StringBuilder(100);
			if (projection != null)
			{
				{
					for (int i = 0; i < projection.Length; ++i)
					{
						// Note: not using a comma delimiter here, as the
						// multiple arguments to EventLog.writeEvent later
						// stringify with a comma delimiter, which would make
						// parsing uglier later.
						if (i != 0)
						{
							projectionBuffer.append('/');
						}
						projectionBuffer.append(projection[i]);
					}
				}
			}
			// ActivityThread.currentPackageName() only returns non-null if the
			// current thread is an application main thread.  This parameter tells
			// us whether an event loop is blocked, and if so, which app it is.
			string blockingPackage = android.app.AppGlobals.getInitialPackage();
			android.util.EventLog.writeEvent(android.content.EventLogTags.CONTENT_QUERY_SAMPLE
				, uri.ToString(), projectionBuffer.ToString(), selection != null ? selection : string.Empty
				, sortOrder != null ? sortOrder : string.Empty, durationMillis, blockingPackage 
				!= null ? blockingPackage : string.Empty, samplePercent);
		}