home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-tomcat-addon-1.4.9-installer.exe / servlet-api.jar / javax / servlet / ServletOutputStream.class (.txt) < prev    next >
Encoding:
Java Class File  |  2004-08-28  |  3.1 KB  |  107 lines

  1. package javax.servlet;
  2.  
  3. import java.io.CharConversionException;
  4. import java.io.IOException;
  5. import java.io.OutputStream;
  6. import java.text.MessageFormat;
  7. import java.util.ResourceBundle;
  8.  
  9. public abstract class ServletOutputStream extends OutputStream {
  10.    private static final String LSTRING_FILE = "javax.servlet.LocalStrings";
  11.    private static ResourceBundle lStrings = ResourceBundle.getBundle("javax.servlet.LocalStrings");
  12.  
  13.    protected ServletOutputStream() {
  14.    }
  15.  
  16.    public void print(String s) throws IOException {
  17.       if (s == null) {
  18.          s = "null";
  19.       }
  20.  
  21.       int len = s.length();
  22.  
  23.       for(int i = 0; i < len; ++i) {
  24.          char c = s.charAt(i);
  25.          if ((c & '\uff00') != 0) {
  26.             String errMsg = lStrings.getString("err.not_iso8859_1");
  27.             Object[] errArgs = new Object[]{new Character(c)};
  28.             errMsg = MessageFormat.format(errMsg, errArgs);
  29.             throw new CharConversionException(errMsg);
  30.          }
  31.  
  32.          this.write(c);
  33.       }
  34.  
  35.    }
  36.  
  37.    public void print(boolean b) throws IOException {
  38.       String msg;
  39.       if (b) {
  40.          msg = lStrings.getString("value.true");
  41.       } else {
  42.          msg = lStrings.getString("value.false");
  43.       }
  44.  
  45.       this.print(msg);
  46.    }
  47.  
  48.    public void print(char c) throws IOException {
  49.       this.print(String.valueOf(c));
  50.    }
  51.  
  52.    public void print(int i) throws IOException {
  53.       this.print(String.valueOf(i));
  54.    }
  55.  
  56.    public void print(long l) throws IOException {
  57.       this.print(String.valueOf(l));
  58.    }
  59.  
  60.    public void print(float f) throws IOException {
  61.       this.print(String.valueOf(f));
  62.    }
  63.  
  64.    public void print(double d) throws IOException {
  65.       this.print(String.valueOf(d));
  66.    }
  67.  
  68.    public void println() throws IOException {
  69.       this.print("\r\n");
  70.    }
  71.  
  72.    public void println(String s) throws IOException {
  73.       this.print(s);
  74.       this.println();
  75.    }
  76.  
  77.    public void println(boolean b) throws IOException {
  78.       this.print(b);
  79.       this.println();
  80.    }
  81.  
  82.    public void println(char c) throws IOException {
  83.       this.print(c);
  84.       this.println();
  85.    }
  86.  
  87.    public void println(int i) throws IOException {
  88.       this.print(i);
  89.       this.println();
  90.    }
  91.  
  92.    public void println(long l) throws IOException {
  93.       this.print(l);
  94.       this.println();
  95.    }
  96.  
  97.    public void println(float f) throws IOException {
  98.       this.print(f);
  99.       this.println();
  100.    }
  101.  
  102.    public void println(double d) throws IOException {
  103.       this.print(d);
  104.       this.println();
  105.    }
  106. }
  107.