コード例 #1
0
ファイル: StreamHandler.cs プロジェクト: bastie/NetVampire
        /**
         * Sets the character encoding used by this handler. A {@code null} value
         * indicates that the default encoding should be used.
         *
         * @param encoding
         *            the character encoding to set.
         * @throws SecurityException
         *             if a security manager determines that the caller does not
         *             have the required permission.
         * @throws UnsupportedEncodingException
         *             if the specified encoding is not supported by the runtime.
         */

        public virtual void setEncoding(String encoding)// throws SecurityException,
        //  UnsupportedEncodingException {
        // flush first before set new encoding
        {
            this.flush();
            base.setEncoding(encoding);
            // renew writer only if the writer exists
            if (null != this.writer)
            {
                if (null == getEncoding())
                {
                    this.writer = new java.io.OutputStreamWriter(this.os);
                }
                else
                {
                    try {
                        this.writer = new java.io.OutputStreamWriter(this.os, getEncoding());
                    } catch (java.io.UnsupportedEncodingException e) {
                        /*
                         * Should not happen because it's checked in
                         * super.initProperties().
                         */
                        throw new java.lang.AssertionError(e);
                    }
                }
            }
        }
コード例 #2
0
ファイル: JavaPropertyWriter.cs プロジェクト: minam365/JavApi
        /// <summary>
        /// Write the properties to the output stream.
        /// </summary>
        /// <param name="stream">The output stream where the properties are written.</param>
        /// <param name="comments">Optional comments that are placed at the beginning of the output.</param>
        public void Write(java.io.Writer stream, String comments)
        {
            // Create a writer to output to an ISO-8859-1 encoding (code page 28592).
            //StreamWriter writer = new StreamWriter( stream, System.Text.Encoding.GetEncoding( 28592 ) );
            java.io.BufferedWriter writer = new java.io.BufferedWriter(stream);

            if (comments != null)
            {
                comments = "# " + comments;
            }
            writer.write(comments);
            writer.newLine();

            writer.write("# " + DateTime.Now.ToString());
            writer.newLine();

            writer.flush();

            for (IEnumerator e = hashtable.Keys.GetEnumerator(); e.MoveNext();)
            {
                String key = e.Current.ToString();
                String val = hashtable[key].ToString();

                writer.write(escapeKey(key) + "=" + escapeValue(val));
                writer.newLine();

                writer.flush();
            }
        }
コード例 #3
0
ファイル: StreamHandler.cs プロジェクト: bastie/NetVampire
 /**
  * Constructs a {@code StreamHandler} object. The new stream handler
  * does not have an associated output stream.
  */
 public StreamHandler()
 {
     initProperties("INFO", null, "java.util.logging.SimpleFormatter", //$NON-NLS-1$//$NON-NLS-2$
                    null);
     this.os     = null;
     this.writer = null;
     this.writerNotInitialized = true;
 }
コード例 #4
0
ファイル: StreamHandler.cs プロジェクト: sailesh341/JavApi
 /**
  * Constructs a {@code StreamHandler} object. The new stream handler
  * does not have an associated output stream.
  */
 public StreamHandler()
 {
     initProperties("INFO", null, "java.util.logging.SimpleFormatter", //$NON-NLS-1$//$NON-NLS-2$
         null);
     this.os = null;
     this.writer = null;
     this.writerNotInitialized = true;
 }
コード例 #5
0
ファイル: StreamHandler.cs プロジェクト: bastie/NetVampire
 /**
  * Constructs a {@code StreamHandler} object. The specified default values
  * will be used if the corresponding properties are not found in the log
  * manager's properties.
  */
 internal StreamHandler(String defaultLevel, String defaultFilter,
                        String defaultFormatter, String defaultEncoding)
 {
     initProperties(defaultLevel, defaultFilter, defaultFormatter,
                    defaultEncoding);
     this.os     = null;
     this.writer = null;
     this.writerNotInitialized = true;
 }
コード例 #6
0
ファイル: XMLParser.cs プロジェクト: minam365/JavApi
 private static void closeQuietly(java.io.Writer outJ)
 {
     if (outJ == null)
     {
         return;
     }
     try {
         outJ.close();
     } catch (java.io.IOException e) {
     }
 }
コード例 #7
0
ファイル: StreamHandler.cs プロジェクト: bastie/NetVampire
 /**
  * Sets the output stream this handler writes to. If there's an existing
  * output stream, the tail string of the associated formatter will be
  * written to it. Then it will be flushed, closed and replaced with
  * {@code os}.
  *
  * @param os
  *            the new output stream.
  * @throws SecurityException
  *             if a security manager determines that the caller does not
  *             have the required permission.
  * @throws NullPointerException
  *             if {@code os} is {@code null}.
  */
 protected void setOutputStream(java.io.OutputStream os)
 {
     if (null == os)
     {
         throw new java.lang.NullPointerException();
     }
     LogManager.getLogManager().checkAccess();
     close(true);
     this.writer = null;
     this.os     = os;
     this.writerNotInitialized = true;
 }
コード例 #8
0
ファイル: Properties.cs プロジェクト: bastie/NetVampire
        public void store(java.io.Writer toWrite, String comments)
        {
            Kajabity.Tools.Java.JavaPropertyWriter reader = new Kajabity.Tools.Java.JavaPropertyWriter(this);
            reader.Write(
                new biz.ritter.io.StreamWrapper(
                    null,
                    new WriterOutputStream(toWrite) // better replace by converted Apache commons IO
                    ),
                comments
                );

            /* old but only with changes usable
             * Kajabity.Tools.Java.JavaPropertyWriter writer = new Kajabity.Tools.Java.JavaPropertyWriter(this);
             * writer.Write(toWrite, comments);
             */
        }
コード例 #9
0
ファイル: StreamHandler.cs プロジェクト: bastie/NetVampire
 // initialize the writer
 private void initializeWritter()
 {
     this.writerNotInitialized = false;
     if (null == getEncoding())
     {
         this.writer = new java.io.OutputStreamWriter(this.os);
     }
     else
     {
         try {
             this.writer = new java.io.OutputStreamWriter(this.os, getEncoding());
         } catch (java.io.UnsupportedEncodingException) {
             /*
              * Should not happen because it's checked in
              * super.initProperties().
              */
         }
     }
     write(getFormatter().getHead(this));
 }
コード例 #10
0
ファイル: StreamHandler.cs プロジェクト: bastie/NetVampire
 /**
  * Closes this handler, but the underlying output stream is only closed if
  * {@code closeStream} is {@code true}. Security is not checked.
  *
  * @param closeStream
  *            whether to close the underlying output stream.
  */
 protected void close(bool closeStream)
 {
     if (null != this.os)
     {
         if (this.writerNotInitialized)
         {
             initializeWritter();
         }
         write(getFormatter().getTail(this));
         try {
             this.writer.flush();
             if (closeStream)
             {
                 this.writer.close();
                 this.writer = null;
                 this.os     = null;
             }
         } catch (java.lang.Exception e) {
             // logging.15=Exception occurred when closing the output stream.
             getErrorManager().error("Exception occurred when closing the output stream.", e,                     //$NON-NLS-1$
                                     ErrorManager.CLOSE_FAILURE);
         }
     }
 }
コード例 #11
0
 /**
  * Outputs this rpm in an XML format to the specified i/o writer.
  *
  * @param writer         Writer stream.
  * @param excludePayload If this is true, the payload will not be included in the XML.
  * @throws IOException If an error occurred writing to the writer.
  */
 public void toXML(java.io.Writer writer, bool excludePayload)
 {//throws IOException {
  // TODO
 }
コード例 #12
0
ファイル: StreamHandler.cs プロジェクト: sailesh341/JavApi
 /**
  * Sets the character encoding used by this handler. A {@code null} value
  * indicates that the default encoding should be used.
  *
  * @param encoding
  *            the character encoding to set.
  * @throws SecurityException
  *             if a security manager determines that the caller does not
  *             have the required permission.
  * @throws UnsupportedEncodingException
  *             if the specified encoding is not supported by the runtime.
  */
 public virtual void setEncoding(String encoding)
 {
     // throws SecurityException,
       //  UnsupportedEncodingException {
     // flush first before set new encoding
     this.flush();
     base.setEncoding(encoding);
     // renew writer only if the writer exists
     if (null != this.writer) {
     if (null == getEncoding()) {
         this.writer = new java.io.OutputStreamWriter(this.os);
     } else {
         try {
             this.writer = new java.io.OutputStreamWriter(this.os, getEncoding());
         } catch (java.io.UnsupportedEncodingException e) {
             /*
              * Should not happen because it's checked in
              * super.initProperties().
              */
             throw new java.lang.AssertionError(e);
         }
     }
     }
 }
コード例 #13
0
ファイル: Properties.cs プロジェクト: minam365/JavApi
 public void store(java.io.Writer toWrite, String comments)
 {
     Kajabity.Tools.Java.JavaPropertyWriter writer = new Kajabity.Tools.Java.JavaPropertyWriter(this);
     writer.Write(toWrite, comments);
 }
コード例 #14
0
ファイル: StreamHandler.cs プロジェクト: sailesh341/JavApi
 // initialize the writer
 private void initializeWritter()
 {
     this.writerNotInitialized = false;
     if (null == getEncoding()) {
     this.writer = new java.io.OutputStreamWriter(this.os);
     } else {
     try {
         this.writer = new java.io.OutputStreamWriter(this.os, getEncoding());
     } catch (java.io.UnsupportedEncodingException e) {
         /*
          * Should not happen because it's checked in
          * super.initProperties().
          */
     }
     }
     write(getFormatter().getHead(this));
 }
コード例 #15
0
ファイル: StreamHandler.cs プロジェクト: sailesh341/JavApi
 /**
  * Sets the output stream this handler writes to. If there's an existing
  * output stream, the tail string of the associated formatter will be
  * written to it. Then it will be flushed, closed and replaced with
  * {@code os}.
  *
  * @param os
  *            the new output stream.
  * @throws SecurityException
  *             if a security manager determines that the caller does not
  *             have the required permission.
  * @throws NullPointerException
  *             if {@code os} is {@code null}.
  */
 protected void setOutputStream(java.io.OutputStream os)
 {
     if (null == os) {
     throw new java.lang.NullPointerException();
     }
     LogManager.getLogManager().checkAccess();
     close(true);
     this.writer = null;
     this.os = os;
     this.writerNotInitialized = true;
 }
コード例 #16
0
ファイル: StreamHandler.cs プロジェクト: sailesh341/JavApi
 /**
  * Closes this handler, but the underlying output stream is only closed if
  * {@code closeStream} is {@code true}. Security is not checked.
  *
  * @param closeStream
  *            whether to close the underlying output stream.
  */
 protected void close(bool closeStream)
 {
     if (null != this.os) {
     if (this.writerNotInitialized) {
         initializeWritter();
     }
     write(getFormatter().getTail(this));
     try {
         this.writer.flush();
         if (closeStream) {
             this.writer.close();
             this.writer = null;
             this.os = null;
         }
     } catch (java.lang.Exception e) {
         // logging.15=Exception occurred when closing the output stream.
             getErrorManager().error("Exception occurred when closing the output stream.", e, //$NON-NLS-1$
                 ErrorManager.CLOSE_FAILURE);
     }
     }
 }
コード例 #17
0
ファイル: StreamWrapper.cs プロジェクト: bastie/NetVampire
 public WriterOutputStream(java.io.Writer writer)
 {
     this.baseWriter = writer;
 }
コード例 #18
0
ファイル: StreamHandler.cs プロジェクト: sailesh341/JavApi
 /**
  * Constructs a {@code StreamHandler} object. The specified default values
  * will be used if the corresponding properties are not found in the log
  * manager's properties.
  */
 internal StreamHandler(String defaultLevel, String defaultFilter,
     String defaultFormatter, String defaultEncoding)
 {
     initProperties(defaultLevel, defaultFilter, defaultFormatter,
         defaultEncoding);
     this.os = null;
     this.writer = null;
     this.writerNotInitialized = true;
 }