Ejemplo n.º 1
0
        private static void CharSequenceSolution()
        {
            var numberOfCases = int.Parse(Console.ReadLine());

            for (int inputIndex = 0; inputIndex < numberOfCases; inputIndex++)
            {
                var testCase = Console.ReadLine();
                var sequence = new CharSequence(testCase.Length);

                for (int i = 0; i < testCase.Length; i++)
                {
                    var key = testCase[i];
                    if (key == '<')
                    {
                        sequence.MoveLeft();
                    }
                    else if (key == '>')
                    {
                        sequence.MoveRight();
                    }
                    else if (key == '-')
                    {
                        sequence.Remove();
                    }
                    else
                    {
                        sequence.Add(key);
                    }
                }

                Console.WriteLine(sequence.ToString());
            }
        }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public static CharSequence parse(android.content.Context context, java.util.List<IconFontDescriptorWrapper> iconFontDescriptors, CharSequence text, final android.widget.TextView target)
        public static CharSequence parse(Context context, IList <IconFontDescriptorWrapper> iconFontDescriptors, CharSequence text, TextView target)
        {
            context = context.ApplicationContext;

            // Analyse the text and replace {} blocks with the appropriate character
            // Retain all transformations in the accumulator
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.text.SpannableStringBuilder spannableBuilder = new android.text.SpannableStringBuilder(text);
            SpannableStringBuilder spannableBuilder = new SpannableStringBuilder(text);

            recursivePrepareSpannableIndexes(context, text.ToString(), spannableBuilder, iconFontDescriptors, 0);
            bool isAnimated = hasAnimatedSpans(spannableBuilder);

            // If animated, periodically invalidate the TextView so that the
            // CustomTypefaceSpan can redraw itself
            if (isAnimated)
            {
                if (target == null)
                {
                    throw new System.ArgumentException("You can't use \"spin\" without providing the target TextView.");
                }
                if (!(target is HasOnViewAttachListener))
                {
                    throw new System.ArgumentException(target.GetType().Name + " does not implement " + "HasOnViewAttachListener. Please use IconTextView, IconButton or IconToggleButton.");
                }

                ((HasOnViewAttachListener)target).OnViewAttachListener = new HasOnViewAttachListener_OnViewAttachListenerAnonymousInnerClassHelper(target);
            }
            else if (target is HasOnViewAttachListener)
            {
                ((HasOnViewAttachListener)target).OnViewAttachListener = null;
            }

            return(spannableBuilder);
        }
Ejemplo n.º 3
0
        //JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
        //ORIGINAL LINE: public static CharSequence parse(android.content.Context context, java.util.List<IconFontDescriptorWrapper> iconFontDescriptors, CharSequence text, final android.widget.TextView target)
        public static CharSequence parse(Context context, IList<IconFontDescriptorWrapper> iconFontDescriptors, CharSequence text, TextView target)
        {
            context = context.ApplicationContext;

            // Analyse the text and replace {} blocks with the appropriate character
            // Retain all transformations in the accumulator
            //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
            //ORIGINAL LINE: final android.text.SpannableStringBuilder spannableBuilder = new android.text.SpannableStringBuilder(text);
            SpannableStringBuilder spannableBuilder = new SpannableStringBuilder(text);
            recursivePrepareSpannableIndexes(context, text.ToString(), spannableBuilder, iconFontDescriptors, 0);
            bool isAnimated = hasAnimatedSpans(spannableBuilder);

            // If animated, periodically invalidate the TextView so that the
            // CustomTypefaceSpan can redraw itself
            if (isAnimated)
            {
                if (target == null)
                {
                    throw new System.ArgumentException("You can't use \"spin\" without providing the target TextView.");
                }
                if (!(target is HasOnViewAttachListener))
                {
                    throw new System.ArgumentException(target.GetType().Name + " does not implement " + "HasOnViewAttachListener. Please use IconTextView, IconButton or IconToggleButton.");
                }

                ((HasOnViewAttachListener) target).OnViewAttachListener = new HasOnViewAttachListener_OnViewAttachListenerAnonymousInnerClassHelper(target);

            }
            else if (target is HasOnViewAttachListener)
            {
                ((HasOnViewAttachListener) target).OnViewAttachListener = null;
            }

            return spannableBuilder;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Appends the specified character sequence to this writer.
        ///
        /// <para> An invocation of this method of the form <tt>out.append(csq)</tt>
        /// behaves in exactly the same way as the invocation
        ///
        /// <pre>
        ///     out.write(csq.toString()) </pre>
        ///
        /// </para>
        /// <para> Depending on the specification of <tt>toString</tt> for the
        /// character sequence <tt>csq</tt>, the entire sequence may not be
        /// appended. For instance, invoking the <tt>toString</tt> method of a
        /// character buffer will return a subsequence whose content depends upon
        /// the buffer's position and limit.
        ///
        /// </para>
        /// </summary>
        /// <param name="csq">
        ///         The character sequence to append.  If <tt>csq</tt> is
        ///         <tt>null</tt>, then the four characters <tt>"null"</tt> are
        ///         appended to this writer.
        /// </param>
        /// <returns>  This writer
        ///
        /// @since  1.5 </returns>
        public override CharArrayWriter Append(CharSequence csq)
        {
            String s = (csq == null ? "null" : csq.ToString());

            Write(s, 0, s.Length());
            return(this);
        }
Ejemplo n.º 5
0
        public StringKeyValue PushTag(CharSequence tag)
        {
            string t = tag.ToString();

            flags.Add(t);
            return(AddValue("<" + t + ">"));
        }
Ejemplo n.º 6
0
 public override void characters(CharSequence chars)
 {
     if (isInsideContentElement)
     {
         string[] tokens = tokenizer.tokenize(chars.ToString());
         text.AddRange(Arrays.asList(tokens));
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Constructs a {@code StringJoiner} with no characters in it using copies
 /// of the supplied {@code prefix}, {@code delimiter} and {@code suffix}.
 /// If no characters are added to the {@code StringJoiner} and methods
 /// accessing the string value of it are invoked, it will return the
 /// {@code prefix + suffix} (or properties thereof) in the result, unless
 /// {@code setEmptyValue} has first been called.
 /// </summary>
 /// <param name="delimiter"> the sequence of characters to be used between each
 ///         element added to the {@code StringJoiner} </param>
 /// <param name="prefix"> the sequence of characters to be used at the beginning </param>
 /// <param name="suffix"> the sequence of characters to be used at the end </param>
 /// <exception cref="NullPointerException"> if {@code prefix}, {@code delimiter}, or
 ///         {@code suffix} is {@code null} </exception>
 public StringJoiner(CharSequence delimiter, CharSequence prefix, CharSequence suffix)
 {
     Objects.RequireNonNull(prefix, "The prefix must not be null");
     Objects.RequireNonNull(delimiter, "The delimiter must not be null");
     Objects.RequireNonNull(suffix, "The suffix must not be null");
     // make defensive copies of arguments
     this.Prefix             = prefix.ToString();
     this.Delimiter          = delimiter.ToString();
     this.Suffix             = suffix.ToString();
     this.EmptyValue_Renamed = this.Prefix + this.Suffix;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Appends the specified character sequence to this output stream.
 ///
 /// <para> An invocation of this method of the form <tt>out.append(csq)</tt>
 /// behaves in exactly the same way as the invocation
 ///
 /// <pre>
 ///     out.print(csq.toString()) </pre>
 ///
 /// </para>
 /// <para> Depending on the specification of <tt>toString</tt> for the
 /// character sequence <tt>csq</tt>, the entire sequence may not be
 /// appended.  For instance, invoking then <tt>toString</tt> method of a
 /// character buffer will return a subsequence whose content depends upon
 /// the buffer's position and limit.
 ///
 /// </para>
 /// </summary>
 /// <param name="csq">
 ///         The character sequence to append.  If <tt>csq</tt> is
 ///         <tt>null</tt>, then the four characters <tt>"null"</tt> are
 ///         appended to this output stream.
 /// </param>
 /// <returns>  This output stream
 ///
 /// @since  1.5 </returns>
 public virtual PrintStream Append(CharSequence csq)
 {
     if (csq == null)
     {
         Print("null");
     }
     else
     {
         Print(csq.ToString());
     }
     return(this);
 }
        /**
         * Returns decoded Mime header/field.
         */
        public static StringValue decodeMime(Env env,
                                             CharSequence word,
                                             string charset)

        {
            string decodedStr = MimeUtility.decodeText(word.ToString());

            StringValue str
                = env.createString(MimeUtility.unfold(decodedStr));

            return(str.toBinaryValue(charset));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Appends the specified character sequence to this writer.
        ///
        /// <para> An invocation of this method of the form <tt>out.append(csq)</tt>
        /// behaves in exactly the same way as the invocation
        ///
        /// <pre>
        ///     out.write(csq.toString()) </pre>
        ///
        /// </para>
        /// <para> Depending on the specification of <tt>toString</tt> for the
        /// character sequence <tt>csq</tt>, the entire sequence may not be
        /// appended. For instance, invoking the <tt>toString</tt> method of a
        /// character buffer will return a subsequence whose content depends upon
        /// the buffer's position and limit.
        ///
        /// </para>
        /// </summary>
        /// <param name="csq">
        ///         The character sequence to append.  If <tt>csq</tt> is
        ///         <tt>null</tt>, then the four characters <tt>"null"</tt> are
        ///         appended to this writer.
        /// </param>
        /// <returns>  This writer
        /// </returns>
        /// <exception cref="IOException">
        ///          If an I/O error occurs
        ///
        /// @since  1.5 </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public Writer append(CharSequence csq) throws IOException
        public virtual Writer Append(CharSequence csq)
        {
            if (csq == null)
            {
                Write("null");
            }
            else
            {
                Write(csq.ToString());
            }
            return(this);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Appends the specified character sequence to this writer.
 ///
 /// <para> An invocation of this method of the form <tt>out.append(csq)</tt>
 /// behaves in exactly the same way as the invocation
 ///
 /// <pre>
 ///     out.write(csq.toString()) </pre>
 ///
 /// </para>
 /// <para> Depending on the specification of <tt>toString</tt> for the
 /// character sequence <tt>csq</tt>, the entire sequence may not be
 /// appended. For instance, invoking the <tt>toString</tt> method of a
 /// character buffer will return a subsequence whose content depends upon
 /// the buffer's position and limit.
 ///
 /// </para>
 /// </summary>
 /// <param name="csq">
 ///         The character sequence to append.  If <tt>csq</tt> is
 ///         <tt>null</tt>, then the four characters <tt>"null"</tt> are
 ///         appended to this writer.
 /// </param>
 /// <returns>  This writer
 ///
 /// @since  1.5 </returns>
 public override PrintWriter Append(CharSequence csq)
 {
     if (csq == null)
     {
         Write("null");
     }
     else
     {
         Write(csq.ToString());
     }
     return(this);
 }
        /**
         * Returns the substring at the specified index as a {@link String}.
         *
         * @param index the index of the substring to return.
         *
         * @return the substring at the specified index.
         *
         * @throws ArgumentException if the index is out of range.
         */
        public String substring(int index)
        {
            if (index < 0 || index >= this.count)
            {
                String message = Logging.getMessage("generic.indexOutOfRange", index);
                Logging.logger().severe(message);
                throw new ArgumentException(message);
            }

            CharSequence cs = this.subSequence(index);

            return(cs != null?cs.ToString() : null);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Tells whether or not this encoder can encode the given character
        /// sequence.
        ///
        /// <para> If this method returns <tt>false</tt> for a particular character
        /// sequence then more information about why the sequence cannot be encoded
        /// may be obtained by performing a full <a href="#steps">encoding
        /// operation</a>.
        ///
        /// </para>
        /// <para> This method may modify this encoder's state; it should therefore not
        /// be invoked if an encoding operation is already in progress.
        ///
        /// </para>
        /// <para> The default implementation of this method is not very efficient; it
        /// should generally be overridden to improve performance.  </para>
        /// </summary>
        /// <param name="cs">
        ///          The given character sequence
        /// </param>
        /// <returns>  <tt>true</tt> if, and only if, this encoder can encode
        ///          the given character without throwing any exceptions and without
        ///          performing any replacements
        /// </returns>
        /// <exception cref="IllegalStateException">
        ///          If an encoding operation is already in progress </exception>
        public virtual bool CanEncode(CharSequence cs)
        {
            CharBuffer cb;

            if (cs is CharBuffer)
            {
                cb = ((CharBuffer)cs).Duplicate();
            }
            else
            {
                cb = CharBuffer.Wrap(cs.ToString());
            }
            return(CanEncode(cb));
        }
Ejemplo n.º 14
0
        private bool IsClause(CharSequence text)
        {
            Matcher m = PAT_WHITESPACE.Matcher(text.ToString());
            int     n = 1;

            while (m.Find())
            {
                n++;
                if (n >= minWords)
                {
                    return(true);
                }
            }
            return(n >= minWords);
        }
Ejemplo n.º 15
0
 public virtual bool Matches(Table table, string columnName, object value1, object
                             value2)
 {
     if (!DataTypeUtil.IsTextual(table.GetColumn(columnName).GetDataType()))
     {
         // use simple equality
         return(SimpleColumnMatcher.INSTANCE.Matches(table, columnName, value1, value2));
     }
     // convert both values to Strings and compare case-insensitively
     try
     {
         CharSequence cs1 = Column.ToCharSequence(value1);
         CharSequence cs2 = Column.ToCharSequence(value2);
         return((cs1 == cs2) || ((cs1 != null) && (cs2 != null) && Sharpen.Runtime.EqualsIgnoreCase
                                     (cs1.ToString(), cs2.ToString())));
     }
     catch (IOException e)
     {
         throw new InvalidOperationException("Could not read column " + columnName + " value"
                                             , e);
     }
 }
Ejemplo n.º 16
0
 public static bool Contains(CharSequence key, params CharSequence[] texts)
 {
     foreach (CharSequence text in texts)
     {
         if (key == null && text == null)
         {
             return(true);
         }
         if (text == key || (text != null && string.ReferenceEquals(text?.ToString(), key?.ToString())))
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 17
0
 /// <summary>
 /// Constructs a new exception with the specified message.
 /// </summary>
 /// <param name="message">  the message to use for this exception, may be null </param>
 /// <param name="parsedData">  the parsed text, should not be null </param>
 /// <param name="errorIndex">  the index in the parsed string that was invalid, should be a valid index </param>
 public DateTimeParseException(String message, CharSequence parsedData, int errorIndex) : base(message)
 {
     this.ParsedString_Renamed = parsedData.ToString();
     this.ErrorIndex_Renamed   = errorIndex;
 }
Ejemplo n.º 18
0
 public static ByteBuffer Encode(this Encoding e, CharSequence str)
 {
     return(ByteBuffer.Wrap(e.GetBytes(str.ToString())));
 }
Ejemplo n.º 19
0
 internal sealed override String ToString(int start, int end)
 {
     return(StringHelperClass.SubstringSpecial(Str.ToString(), start + Offset, end + Offset));
 }
Ejemplo n.º 20
0
        /// <summary>Retrieves diagnostics information preserved in the history file</summary>
        /// <returns>diagnostics as of the time of job termination</returns>
        public virtual string GetDiagnostics()
        {
            CharSequence diagnostics = datum.GetDiagnostics();

            return(diagnostics == null ? Nodiags : diagnostics.ToString());
        }
Ejemplo n.º 21
0
 public StringKeyValue RemoveTag(CharSequence tag)
 {
     flags.Remove(tag.ToString());
     return(this);
 }
Ejemplo n.º 22
0
 private string FixGroupDisplayName(CharSequence name)
 {
     return(name.ToString().Replace(".", ".\u200B").Replace("$", "\u200B$"));
 }
Ejemplo n.º 23
0
 /*
  * Constructs a java.lang.StringBuffer and initializes it with the content from the
  * specified {@code CharSequence}. The capacity of the new buffer will be
  * the length of the {@code CharSequence} plus the default capacity.
  *
  * @param cs
  *            the content to initialize the instance.
  * @throws NullPointerException
  *            if {@code cs} is {@code null}.
  * @since 1.5
  */
 public StringBuffer(CharSequence cs) : base(cs.ToString())
 {
 }
Ejemplo n.º 24
0
 /// <summary>Tokenizes the text and returns an array of tokens.</summary>
 /// <remarks>Tokenizes the text and returns an array of tokens.</remarks>
 /// <param name="text">The text</param>
 /// <returns>The tokens</returns>
 public static string[] Tokenize(CharSequence text)
 {
     return(PAT_NOT_WORD_BOUNDARY.Matcher(PAT_WORD_BOUNDARY.Matcher(text.ToString().ReplaceAll("\u00A0", "'\u00A0'")).ReplaceAll("\u2063"
                                                                                                                                 )).ReplaceAll("$1").ReplaceAll("[ \u2063]+", " ").Trim().Split("[ ]+"));
 }
Ejemplo n.º 25
0
 public ByteBuffer Encode(CharSequence str)
 {
     return(Encode(str.ToString()));
 }
Ejemplo n.º 26
0
        public StringKeyValue PopTag(CharSequence tag)
        {
            string tmp = flags.Pop();

            return(AddValue("</" + ((tag == null || tag.Length() == 0 || " ".Equals(tag.ToString())) ? tmp : tag.ToString()) + ">"));
        }
Ejemplo n.º 27
0
		public Matcher Reset (CharSequence str)
		{
			return Reset (str.ToString ());
		}
Ejemplo n.º 28
0
 public Matcher Reset(CharSequence str)
 {
     return(Reset(str.ToString()));
 }
Ejemplo n.º 29
0
 /**
  * Constructs a java.lang.StringBuffer and initializes it with the content from the
  * specified {@code CharSequence}. The capacity of the new buffer will be
  * the length of the {@code CharSequence} plus the default capacity.
  *
  * @param cs
  *            the content to initialize the instance.
  * @throws NullPointerException
  *            if {@code cs} is {@code null}.
  * @since 1.5
  */
 public StringBuffer(CharSequence cs)
     : base(cs.ToString())
 {
 }
Ejemplo n.º 30
0
 public StringKeyValue AddTag(CharSequence tag)
 {
     flags.Add(tag.ToString());
     return(this);
 }
Ejemplo n.º 31
0
 public ByteBuffer Encode(CharSequence str)
 {
     return Encode (str.ToString ());
 }
Ejemplo n.º 32
0
 /*
  * Constructs an instance that's initialized with the contents of the
  * specified {@code CharSequence}. The capacity of the new builder will be
  * the length of the {@code CharSequence} plus 16.
  *
  * @param seq
  *            the {@code CharSequence} to copy into the builder.
  * @throws NullPointerException
  *            if {@code seq} is {@code null}.
  */
 public StringBuilder(CharSequence seq) : base(seq.ToString())
 {
 }
Ejemplo n.º 33
0
 /**
  * Constructs an instance that's initialized with the contents of the
  * specified {@code CharSequence}. The capacity of the new builder will be
  * the length of the {@code CharSequence} plus 16.
  *
  * @param seq
  *            the {@code CharSequence} to copy into the builder.
  * @throws NullPointerException
  *            if {@code seq} is {@code null}.
  */
 public StringBuilder(CharSequence seq)
     : base(seq.ToString())
 {
 }
Ejemplo n.º 34
0
 /// <exception cref="System.IO.IOException"></exception>
 protected internal override void WriteOne(CharSequence line)
 {
     pckOut.WriteString(line.ToString());
 }
Ejemplo n.º 35
0
 public virtual string GetText()
 {
     return(text.ToString());
 }