public static java.lang.String test() { java.lang.StringBuilder sb = new java.lang.StringBuilder(); sb.append('a'); sb.append('\u0062'); sb.append('\x63'); return sb.toString(); }
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()); }
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()); }
// first selector == class name // check potential attributes /// <hide></hide> public static void buildShortClassTag(object cls, java.lang.StringBuilder @out) { if (cls == null) { @out.append("null"); } else { string simpleName = cls.GetType().Name; if (simpleName == null || string.IsNullOrEmpty(simpleName)) { simpleName = cls.GetType().FullName; int end = simpleName.LastIndexOf('.'); if (end > 0) { simpleName = Sharpen.StringHelper.Substring(simpleName, end + 1); } } @out.append(simpleName); @out.append('{'); @out.append(Sharpen.Util.IntToHexString(Sharpen.Util.IdentityHashCode(cls))); } }
/// <summary> /// Creates a new instance of a XML Pull Parser /// using the currently configured factory features. /// </summary> /// <remarks> /// Creates a new instance of a XML Pull Parser /// using the currently configured factory features. /// </remarks> /// <returns>A new instance of a XML Pull Parser.</returns> /// <exception cref="XmlPullParserException"> /// if a parser cannot be created which satisfies the /// requested configuration. /// </exception> /// <exception cref="org.xmlpull.v1.XmlPullParserException"></exception> public virtual org.xmlpull.v1.XmlPullParser newPullParser() { if (parserClasses == null) { throw new org.xmlpull.v1.XmlPullParserException("Factory initialization was incomplete - has not tried " + classNamesLocation); } if (parserClasses.size() == 0) { throw new org.xmlpull.v1.XmlPullParserException("No valid parser classes found in " + classNamesLocation); } java.lang.StringBuilder issues = new java.lang.StringBuilder(); { for (int i = 0; i < parserClasses.size(); i++) { System.Type ppClass = (System.Type)parserClasses.get(i); try { org.xmlpull.v1.XmlPullParser pp = (org.xmlpull.v1.XmlPullParser)System.Activator.CreateInstance (ppClass); { for (java.util.Iterator <object> iter = features.keySet().iterator(); iter.hasNext ();) { string key = (string)iter.next(); bool value = (bool)features.get(key); if (value != null && value) { pp.setFeature(key, true); } } } return(pp); } catch (System.Exception ex) { issues.append(ppClass.FullName + ": " + ex.ToString() + "; "); } } } throw new org.xmlpull.v1.XmlPullParserException("could not create parser: " + issues ); }
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 (); }
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(); }
/// <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(); }
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); }
/// <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."); } }
/// <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(); }
/// <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<K, V>, 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"); }
/// <summary> /// Creates a new instance of a XML Pull Parser /// using the currently configured factory features. /// </summary> /// <remarks> /// Creates a new instance of a XML Pull Parser /// using the currently configured factory features. /// </remarks> /// <returns>A new instance of a XML Pull Parser.</returns> /// <exception cref="XmlPullParserException"> /// if a parser cannot be created which satisfies the /// requested configuration. /// </exception> /// <exception cref="org.xmlpull.v1.XmlPullParserException"></exception> public virtual org.xmlpull.v1.XmlPullParser newPullParser() { if (parserClasses == null) { throw new org.xmlpull.v1.XmlPullParserException("Factory initialization was incomplete - has not tried " + classNamesLocation); } if (parserClasses.size() == 0) { throw new org.xmlpull.v1.XmlPullParserException("No valid parser classes found in " + classNamesLocation); } java.lang.StringBuilder issues = new java.lang.StringBuilder(); { for (int i = 0; i < parserClasses.size(); i++) { System.Type ppClass = (System.Type)parserClasses.get(i); try { org.xmlpull.v1.XmlPullParser pp = (org.xmlpull.v1.XmlPullParser)System.Activator.CreateInstance (ppClass); { for (java.util.Iterator<object> iter = features.keySet().iterator(); iter.hasNext (); ) { string key = (string)iter.next(); bool value = (bool)features.get(key); if (value != null && value) { pp.setFeature(key, true); } } } return pp; } catch (System.Exception ex) { issues.append(ppClass.FullName + ": " + ex.ToString() + "; "); } } } throw new org.xmlpull.v1.XmlPullParserException("could not create parser: " + issues ); }
/// <summary> /// Returns a CharSequence corresponding to /// <code>s</code> /// with all the ASCII digits replaced /// by digits appropriate to this formatter's locale. Other characters remain unchanged. /// </summary> private java.lang.CharSequence localizeDigits(java.lang.CharSequence s) { int length = s.Length; int offsetToLocalizedDigits = localeData.zeroDigit - '0'; java.lang.StringBuilder result = new java.lang.StringBuilder(length); { for (int i = 0; i < length; ++i) { char ch = s[i]; if (ch >= '0' && ch <= '9') { ch += (char)offsetToLocalizedDigits; } result.append(ch); } } return result; }
/// <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(); }
/// <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); } } } }
public string queueAll() { var columns = new [] { KEY_CONTENT }; Cursor cursor = sqLiteDatabase.query(MYDATABASE_TABLE, columns, null, null, null, null, null); var result = new java.lang.StringBuilder(); int index_CONTENT = cursor.getColumnIndex(KEY_CONTENT); for (cursor.moveToFirst(); !(cursor.isAfterLast()); cursor.moveToNext()) { result.append( cursor.getString(index_CONTENT)).append( "\n"); } return result.ToAndroidString(); }
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(); }
/// <summary>Inserts the grouping separator every 3 digits.</summary> /// <remarks> /// Inserts the grouping separator every 3 digits. DecimalFormat lets you configure grouping /// size, but you can't access that from Formatter, and the default is every 3 digits. /// </remarks> private java.lang.CharSequence insertGrouping(java.lang.CharSequence s) { java.lang.StringBuilder result = new java.lang.StringBuilder(s.Length + s.Length / 3); // A leading '-' doesn't want to be included in the grouping. int digitsLength = s.Length; int i = 0; if (s[0] == '-') { --digitsLength; ++i; result.append('-'); } // Append the digits that come before the first separator. int headLength = digitsLength % 3; if (headLength == 0) { headLength = 3; } result.append(s, i, i + headLength); i += headLength; // Append the remaining groups. for (; i < s.Length; i += 3) { result.append(localeData.groupingSeparator); result.append(s, i, i + 3); } return result; }
/// <summary>Creates a new instance of a XML Serializer.</summary> /// <remarks> /// Creates a new instance of a XML Serializer. /// <p><b>NOTE:</b> factory features are not used for XML Serializer. /// </remarks> /// <returns>A new instance of a XML Serializer.</returns> /// <exception cref="XmlPullParserException"> /// if a parser cannot be created which satisfies the /// requested configuration. /// </exception> /// <exception cref="org.xmlpull.v1.XmlPullParserException"></exception> public virtual org.xmlpull.v1.XmlSerializer newSerializer() { if (serializerClasses == null) { throw new org.xmlpull.v1.XmlPullParserException("Factory initialization incomplete - has not tried " + classNamesLocation); } if (serializerClasses.size() == 0) { throw new org.xmlpull.v1.XmlPullParserException("No valid serializer classes found in " + classNamesLocation); } java.lang.StringBuilder issues = new java.lang.StringBuilder(); { for (int i = 0; i < serializerClasses.size(); i++) { System.Type ppClass = (System.Type)serializerClasses.get(i); try { org.xmlpull.v1.XmlSerializer ser = (org.xmlpull.v1.XmlSerializer)System.Activator.CreateInstance (ppClass); return ser; } catch (System.Exception ex) { issues.append(ppClass.FullName + ": " + ex.ToString() + "; "); } } } throw new org.xmlpull.v1.XmlPullParserException("could not create serializer: " + issues); }
/// <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(); }
/// <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(); }
/// <summary> /// Quotes the given /// <code>string</code> /// using "\Q" and "\E", so that all /// meta-characters lose their special meaning. This method correctly /// escapes embedded instances of "\Q" or "\E". If the entire result /// is to be passed verbatim to /// <see cref="compile()">compile()</see> /// , it's usually clearer /// to use the /// <see cref="LITERAL">LITERAL</see> /// flag instead. /// </summary> public static string quote(string @string) { java.lang.StringBuilder sb = new java.lang.StringBuilder(); sb.append("\\Q"); int apos = 0; int k; while ((k = @string.IndexOf("\\E", apos)) >= 0) { sb.append(Sharpen.StringHelper.Substring(@string, apos, k + 2)).append("\\\\E\\Q" ); apos = k + 2; } return sb.append(Sharpen.StringHelper.Substring(@string, apos)).append("\\E").ToString (); }
public override string ToString() { java.lang.StringBuilder sb = new java.lang.StringBuilder(64); sb.append("Transformation"); toShortString(sb); return sb.ToString(); }
/// <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(); }
/// <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(); }
public override string ToString() { java.lang.StringBuilder sb = new java.lang.StringBuilder(64); sb.append("Matrix{"); toShortString(sb); sb.append('}'); return sb.ToString(); }
/// <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(); }