001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.log4j.spi;
018
019import java.io.PrintWriter;
020import java.util.Vector;
021
022/**
023  * VectorWriter is an obsolete class provided only for
024  *  binary compatibility with earlier versions of log4j and should not be used.
025  *
026  * @deprecated
027  */
028class VectorWriter extends PrintWriter {
029
030  private Vector v;
031
032    /**
033     * @deprecated
034     */
035  VectorWriter() {
036    super(new NullWriter());
037    v = new Vector();
038  }
039
040  public void print(Object o) {
041    v.addElement(String.valueOf(o));
042  }
043
044  public void print(char[] chars) {
045    v.addElement(new String(chars));
046  }
047
048  public void print(String s) {
049    v.addElement(s);
050  }
051
052  public void println(Object o) {
053    v.addElement(String.valueOf(o));
054  }
055
056  // JDK 1.1.x apprenly uses this form of println while in
057  // printStackTrace()
058  public
059  void println(char[] chars) {
060    v.addElement(new String(chars));
061  }
062
063  public
064  void println(String s) {
065    v.addElement(s);
066  }
067
068  public void write(char[] chars) {
069    v.addElement(new String(chars));
070  }
071
072  public void write(char[] chars, int off, int len) {
073    v.addElement(new String(chars, off, len));
074  }
075
076  public void write(String s, int off, int len) {
077    v.addElement(s.substring(off, off+len));
078  }
079
080  public void write(String s) {
081     v.addElement(s);
082  }
083
084  public String[] toStringArray() {
085    int len = v.size();
086    String[] sa = new String[len];
087    for(int i = 0; i < len; i++) {
088      sa[i] = (String) v.elementAt(i);
089    }
090    return sa;
091  }
092
093}
094