You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by og...@apache.org on 2009/01/09 21:25:53 UTC

svn commit: r733144 - in /maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util: DefaultMonitor.java Monitor.java

Author: ogusakov
Date: Fri Jan  9 12:25:52 2009
New Revision: 733144

URL: http://svn.apache.org/viewvc?rev=733144&view=rev
Log:
added monitor and default implementation

Added:
    maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/DefaultMonitor.java   (with props)
    maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/Monitor.java   (with props)

Added: maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/DefaultMonitor.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/DefaultMonitor.java?rev=733144&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/DefaultMonitor.java (added)
+++ maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/DefaultMonitor.java Fri Jan  9 12:25:52 2009
@@ -0,0 +1,81 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.apache.maven.mercury.util;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.Date;
+
+/**
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public class DefaultMonitor
+    implements Monitor
+{
+    Writer _writer;
+    boolean _timestamp = true;
+    
+
+    public DefaultMonitor( boolean timestamp )
+    {
+        this( System.out );
+        this._timestamp = timestamp;
+    }
+
+    public DefaultMonitor()
+    {
+        this( System.out );
+    }
+
+    public DefaultMonitor( OutputStream os )
+    {
+        _writer = new OutputStreamWriter( os );
+    }
+
+    public DefaultMonitor( Writer writer )
+    {
+        _writer = writer;
+    }
+
+    public void message( String msg )
+    {
+        try
+        {
+            if ( _writer != null )
+            {
+                if( _timestamp )
+                {
+                    _writer.write( new Date().toString() );
+                    _writer.write( ": " );
+                }
+                _writer.write( msg );
+                _writer.write( "\n" );
+                _writer.flush();
+            }
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+    }
+
+}

Propchange: maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/DefaultMonitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/DefaultMonitor.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/Monitor.java
URL: http://svn.apache.org/viewvc/maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/Monitor.java?rev=733144&view=auto
==============================================================================
--- maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/Monitor.java (added)
+++ maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/Monitor.java Fri Jan  9 12:25:52 2009
@@ -0,0 +1,29 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.maven.mercury.util;
+
+/**
+ * @author Oleg Gusakov
+ * @version $Id$
+ */
+public interface Monitor
+{
+    public abstract void message( String msg );
+}

Propchange: maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/Monitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/mercury/trunk/mercury-util/src/main/java/org/apache/maven/mercury/util/Monitor.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision