View Javadoc
1   package org.apache.maven.shared.utils.logging;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *  http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  /**
23   * Message builder implementation that just ignores styling, for Maven version earlier than 3.4.0.
24   */
25  class PlainMessageBuilder
26      implements MessageBuilder
27  {
28      private StringBuilder buffer;
29  
30      PlainMessageBuilder()
31      {
32          buffer = new StringBuilder();
33      }
34  
35      PlainMessageBuilder( StringBuilder builder )
36      {
37          buffer = builder;
38      }
39  
40      PlainMessageBuilder( int size )
41      {
42          buffer = new StringBuilder( size );
43      }
44  
45      public PlainMessageBuilder debug( Object message )
46      {
47          return a( message );
48      }
49      
50      public PlainMessageBuilder info( Object message )
51      {
52          return a( message );
53      }
54      
55      public PlainMessageBuilder warning( Object message )
56      {
57          return a( message );
58      }
59      
60      public PlainMessageBuilder error( Object message )
61      {
62          return a( message );
63      }
64  
65      public PlainMessageBuilder success( Object message )
66      {
67          return a( message );
68      }
69  
70      public PlainMessageBuilder failure( Object message )
71      {
72          return a( message );
73      }
74  
75      public PlainMessageBuilder strong( Object message )
76      {
77          return a( message );
78      }
79  
80      public PlainMessageBuilder mojo( Object message )
81      {
82          return a( message );
83      }
84  
85      public PlainMessageBuilder project( Object message )
86      {
87          return a( message );
88      }
89  
90      public PlainMessageBuilder a( char[] value, int offset, int len )
91      {
92          buffer.append( value, offset, len );
93          return this;
94      }
95  
96      public PlainMessageBuilder a( char[] value )
97      {
98          buffer.append( value );
99          return this;
100     }
101 
102     public PlainMessageBuilder a( CharSequence value, int start, int end )
103     {
104         buffer.append( value, start, end );
105         return this;
106     }
107 
108     public PlainMessageBuilder a( CharSequence value )
109     {
110         buffer.append( value );
111         return this;
112     }
113 
114     public PlainMessageBuilder a( Object value )
115     {
116         buffer.append( value );
117         return this;
118     }
119 
120     public PlainMessageBuilder newline()
121     {
122         buffer.append( System.getProperty( "line.separator" ) );
123         return this;
124     }
125 
126     public PlainMessageBuilder format( String pattern, Object... args )
127     {
128         buffer.append( String.format( pattern, args ) );
129         return this;
130     }
131 
132     @Override
133     public String toString()
134     {
135         return buffer.toString();
136     }
137 }