Exemplo n.º 1
0
 /*
  * Writes all chars of the given character sequence {@code csq} to the
  * current position of this buffer, and increases the position by the length
  * of the csq.
  * <p/>
  * Calling this method has the same effect as {@code append(csq.toString())}.
  * If the {@code CharSequence} is {@code null} the string "null" will be
  * written to the buffer.
  *
  * @param csq
  *            the {@code CharSequence} to write.
  * @return this buffer.
  * @exception BufferOverflowException
  *                if {@code remaining()} is less than the length of csq.
  * @exception ReadOnlyBufferException
  *                if no changes may be made to the contents of this buffer.
  */
 public virtual CharBuffer append(java.lang.CharSequence csq)
 {
     if (csq != null)
     {
         return(put(csq.toString()));
     }
     return(put("null")); //$NON-NLS-1$
 }
Exemplo n.º 2
0
        /*
         * Appends a subsequence of the character sequence {@code csq} to this
         * writer's {@code StringBuffer}. This method works the same way as {@code
         * StringWriter.writer(csq.subsequence(start, end).toString())}. If {@code
         * csq} is {@code null}, then the specified subsequence of the string "null"
         * will be written to the target.
         *
         * @param csq
         *            the character sequence appended to the target.
         * @param start
         *            the index of the first char in the character sequence appended
         *            to the target.
         * @param end
         *            the index of the character following the last character of the
         *            subsequence appended to the target.
         * @return this writer.
         * @throws IndexOutOfBoundsException
         *             if {@code start > end}, {@code start &lt; 0}, {@code end &lt; 0} or
         *             either {@code start} or {@code end} are greater or equal than
         *             the length of {@code csq}.
         */

        public new StringWriter append(java.lang.CharSequence csq, int start, int end)
        {
            if (null == csq)
            {
                csq = new java.lang.StringJ(TOKEN_NULL);
            }
            String output = csq.subSequence(start, end).toString();

            write(output, 0, output.length());
            return(this);
        }
Exemplo n.º 3
0
 /**
  * Appends a subsequence of the character sequence {@code csq} to the target
  * stream. This method works the same way as {@code
  * PrintStream.print(csq.subsequence(start, end).toString())}. If {@code
  * csq} is {@code null}, then the specified subsequence of the string "null"
  * will be written to the target stream.
  *
  * @param csq
  *            the character sequence appended to the target stream.
  * @param start
  *            the index of the first char in the character sequence appended
  *            to the target stream.
  * @param end
  *            the index of the character following the last character of the
  *            subsequence appended to the target stream.
  * @return this stream.
  * @throws IndexOutOfBoundsException
  *             if {@code start &gt; end}, {@code start &lt; 0}, {@code end &lt; 0} or
  *             either {@code start} or {@code end} are greater or equal than
  *             the length of {@code csq}.
  */
 public PrintStream append(java.lang.CharSequence csq, int start, int end)
 {
     if (null == csq)
     {
         print(TOKEN_NULL.substring(start, end));
     }
     else
     {
         print(csq.subSequence(start, end).toString());
     }
     return(this);
 }
Exemplo n.º 4
0
 /**
  * Appends the character sequence {@code csq} to the target stream. This
  * method works the same way as {@code PrintStream.print(csq.toString())}.
  * If {@code csq} is {@code null}, then the string "null" is written to the
  * target stream.
  *
  * @param csq
  *            the character sequence appended to the target stream.
  * @return this stream.
  */
 public PrintStream append(java.lang.CharSequence csq)
 {
     if (null == csq)
     {
         print(TOKEN_NULL);
     }
     else
     {
         print(csq.toString());
     }
     return(this);
 }
Exemplo n.º 5
0
        /*
         * Appends the character sequence {@code csq} to this writer's {@code
         * StringBuffer}. This method works the same way as {@code
         * StringWriter.write(csq.toString())}. If {@code csq} is {@code null}, then
         * the string "null" is written to the target stream.
         *
         * @param csq
         *            the character sequence appended to the target.
         * @return this writer.
         */

        public new StringWriter append(java.lang.CharSequence csq)
        {
            if (null == csq)
            {
                write(TOKEN_NULL);
            }
            else
            {
                write(csq.toString());
            }
            return(this);
        }
Exemplo n.º 6
0
        /**
         * Appends a {@code CharSequence} to the {@code CharArrayWriter}. The method
         * works the same way as {@code write(csq.toString())}. If {@code csq} is
         * {@code null}, then it will be substituted with the string {@code "null"}.
         *
         * @param csq
         *            the {@code CharSequence} appended to the {@code
         *            CharArrayWriter}, may be {@code null}.
         * @return this CharArrayWriter.
         */

        public new virtual CharArrayWriter append(java.lang.CharSequence csq)
        {
            if (null == csq)
            {
                append(new java.lang.StringJ(TOKEN_NULL), 0, TOKEN_NULL.length());
            }
            else
            {
                append(csq, 0, csq.length());
            }
            return(this);
        }
Exemplo n.º 7
0
 /*
  * Appends a subsequence of the character sequence {@code csq} to the
  * target. This method works the same way as {@code
  * Writer.writer(csq.subsequence(start, end).toString())}. If {@code
  * csq} is {@code null}, then the specified subsequence of the string "null"
  * will be written to the target.
  *
  * @param csq
  *            the character sequence appended to the target.
  * @param start
  *            the index of the first char in the character sequence appended
  *            to the target.
  * @param end
  *            the index of the character following the last character of the
  *            subsequence appended to the target.
  * @return this writer.
  * @throws IOException
  *             if this writer is closed or another I/O error occurs.
  * @throws IndexOutOfBoundsException
  *             if {@code start > end}, {@code start &lt; 0}, {@code end &lt; 0} or
  *             either {@code start} or {@code end} are greater or equal than
  *             the length of {@code csq}.
  */
 public virtual Writer append(java.lang.CharSequence csq, int start, int end)
 {//throws IOException {
     if (null == csq)
     {
         write(TOKEN_NULL.substring(start, end));
     }
     else
     {
         write(csq.subSequence(start, end).toString());
     }
     return(this);
 }
Exemplo n.º 8
0
 /*
  * Appends the character sequence {@code csq} to the target. This method
  * works the same way as {@code Writer.write(csq.toString())}. If {@code
  * csq} is {@code null}, then the string "null" is written to the target
  * stream.
  *
  * @param csq
  *            the character sequence appended to the target.
  * @return this writer.
  * @throws IOException
  *             if this writer is closed or another I/O error occurs.
  */
 public virtual Writer append(java.lang.CharSequence csq)
 {// throws IOException {
     if (null == csq)
     {
         write(TOKEN_NULL);
     }
     else
     {
         write(csq.toString());
     }
     return(this);
 }
Exemplo n.º 9
0
        /*
         * Checks if a given <code>CharSequence</code> can be encoded by this
         * encoder.
         *
         * Note that this method can change the internal status of this encoder, so
         * it should not be called when another encode process is ongoing, otherwise
         * it will throw an <code>IllegalStateException</code>.
         *
         * This method can be overridden for performance improvement.
         *
         * @param sequence
         *            the given <code>CharSequence</code>.
         * @return true if the given <code>CharSequence</code> can be encoded by
         *         this encoder.
         * @throws IllegalStateException
         *             if current internal status is neither RESET or FLUSH.
         */
        public virtual bool canEncode(java.lang.CharSequence sequence)
        {
            CharBuffer cb;

            if (sequence is CharBuffer)
            {
                cb = ((CharBuffer)sequence).duplicate();
            }
            else
            {
                cb = CharBuffer.wrap(sequence);
            }
            return(implCanEncode(cb));
        }
Exemplo n.º 10
0
 /*
  * Writes chars of the given {@code CharSequence} to the current position of
  * this buffer, and increases the position by the number of chars written.
  *
  * @param csq
  *            the {@code CharSequence} to write.
  * @param start
  *            the first char to write, must not be negative and not greater
  *            than {@code csq.length()}.
  * @param end
  *            the last char to write (excluding), must be less than
  *            {@code start} and not greater than {@code csq.length()}.
  * @return this buffer.
  * @exception BufferOverflowException
  *                if {@code remaining()} is less than {@code end - start}.
  * @exception IndexOutOfBoundsException
  *                if either {@code start} or {@code end} is invalid.
  * @exception ReadOnlyBufferException
  *                if no changes may be made to the contents of this buffer.
  */
 public virtual CharBuffer append(java.lang.CharSequence csq, int start, int end)
 {
     if (csq == null)
     {
         //csq = "null";
         return(put("null"));
     }
     java.lang.CharSequence cs = csq.subSequence(start, end);
     if (cs.length() > 0)
     {
         return(put(cs.toString()));
     }
     else
     {
         return(this);
     }
 }
Exemplo n.º 11
0
        /*
         * Creates a new char buffer by wrapping the given char sequence.
         * <p/>
         * The new buffer's position will be {@code start}, limit will be
         * {@code end}, capacity will be the length of the char sequence. The new
         * buffer is read-only.
         *
         * @param chseq
         *            the char sequence which the new buffer will be based on.
         * @param start
         *            the start index, must not be negative and not greater than
         *            {@code chseq.length()}.
         * @param end
         *            the end index, must be no less than {@code start} and no
         *            greater than {@code chseq.length()}.
         * @return the created char buffer.
         * @exception IndexOutOfBoundsException
         *                if either {@code start} or {@code end} is invalid.
         */
        public static CharBuffer wrap(java.lang.CharSequence chseq, int start, int end)
        {
            if (chseq == null)
            {
                throw new java.lang.NullPointerException();
            }
            if (start < 0 || end < start || end > chseq.length())
            {
                throw new java.lang.IndexOutOfBoundsException();
            }

            CharBuffer result = BufferFactory.newCharBuffer(chseq);

            result.positionJ = start;
            result.limitJ    = end;
            return(result);
        }
Exemplo n.º 12
0
 /*
  * Creates a new char buffer by wrapping the given char sequence.
  * <p/>
  * Calling this method has the same effect as
  * {@code wrap(chseq, 0, chseq.length())}.
  *
  * @param chseq
  *            the char sequence which the new buffer will be based on.
  * @return the created char buffer.
  */
 public static CharBuffer wrap(java.lang.CharSequence chseq)
 {
     return(BufferFactory.newCharBuffer(chseq));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Returns a new readonly char buffer based on the specified char sequence.
 ///
 /// @param chseq
 ///            The char sequence
 /// @return A new readonly char buffer based on the specified char sequence.
 /// </summary>
 public static CharBuffer newCharBuffer(java.lang.CharSequence chseq)
 {
     return(new CharSequenceAdapter(chseq));
 }
Exemplo n.º 14
0
        /// <summary>
        /// Match input agains pattern.
        /// </summary>
        /// <param name="pattern"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        public static bool matches(String pattern, java.lang.CharSequence input)
        {
            Regex p = new Regex(pattern);

            return(p.Match(input.ToString()).Success);
        }
Exemplo n.º 15
0
 java.lang.Appendable java.lang.Appendable.append(java.lang.CharSequence csq, int start, int end)
 {
     return(this.append(csq, start, end));
 }
Exemplo n.º 16
0
 java.lang.Appendable java.lang.Appendable.append(java.lang.CharSequence csq)
 {
     return(this.append(csq));
 }
Exemplo n.º 17
0
 internal CharSequenceAdapter(java.lang.CharSequence chseq)
     : base(chseq.length())
 {
     sequence = chseq;
 }
Exemplo n.º 18
0
 internal CharSequenceAdapter(java.lang.CharSequence chseq) : base(chseq.length())
 {
     sequence = chseq;
 }