View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.message.internal;
20  
21  import org.apache.maven.message.MessageBuilder;
22  
23  class DefaultMessageBuilder implements MessageBuilder {
24  
25      private final StringBuilder buffer;
26  
27      DefaultMessageBuilder() {
28          this(new StringBuilder());
29      }
30  
31      DefaultMessageBuilder(StringBuilder buffer) {
32          this.buffer = buffer;
33      }
34  
35      @Override
36      public MessageBuilder style(String style) {
37          return this;
38      }
39  
40      @Override
41      public MessageBuilder resetStyle() {
42          return this;
43      }
44  
45      @Override
46      public MessageBuilder append(CharSequence cs) {
47          buffer.append(cs);
48          return this;
49      }
50  
51      @Override
52      public MessageBuilder append(CharSequence cs, int start, int end) {
53          buffer.append(cs, start, end);
54          return this;
55      }
56  
57      @Override
58      public MessageBuilder append(char c) {
59          buffer.append(c);
60          return this;
61      }
62  
63      @Override
64      public MessageBuilder setLength(int length) {
65          buffer.setLength(length);
66          return this;
67      }
68  
69      @Override
70      public String build() {
71          return buffer.toString();
72      }
73  
74      @Override
75      public String toString() {
76          return build();
77      }
78  }