View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  package org.apache.log4j.spi;
    18
    19  import java.io.PrintWriter;
    20  import java.util.Vector;
    21
    22  /***
    23    * VectorWriter is an obsolete class provided only for
    24    *  binary compatibility with earlier versions of log4j and should not be used.
    25    *
    26    * @deprecated
    27    */
    28  class VectorWriter extends PrintWriter {
    29
    30    private Vector v;
    31
    32      /***
    33       * @deprecated
    34       */
    35    VectorWriter() {
    36      super(new NullWriter());
    37      v = new Vector();
    38    }
    39
    40    public void print(Object o) {
    41      v.addElement(String.valueOf(o));
    42    }
    43
    44    public void print(char[] chars) {
    45      v.addElement(new String(chars));
    46    }
    47
    48    public void print(String s) {
    49      v.addElement(s);
    50    }
    51
    52    public void println(Object o) {
    53      v.addElement(String.valueOf(o));
    54    }
    55
    56    // JDK 1.1.x apprenly uses this form of println while in
    57    // printStackTrace()
    58    public
    59    void println(char[] chars) {
    60      v.addElement(new String(chars));
    61    }
    62
    63    public
    64    void println(String s) {
    65      v.addElement(s);
    66    }
    67
    68    public void write(char[] chars) {
    69      v.addElement(new String(chars));
    70    }
    71
    72    public void write(char[] chars, int off, int len) {
    73      v.addElement(new String(chars, off, len));
    74    }
    75
    76    public void write(String s, int off, int len) {
    77      v.addElement(s.substring(off, off+len));
    78    }
    79
    80    public void write(String s) {
    81       v.addElement(s);
    82    }
    83
    84    public String[] toStringArray() {
    85      int len = v.size();
    86      String[] sa = new String[len];
    87      for(int i = 0; i < len; i++) {
    88        sa[i] = (String) v.elementAt(i);
    89      }
    90      return sa;
    91    }
    92
    93  }
    94