1 /*
2 * dpkg - Debian Package library and the Debian Package Maven plugin
3 * (c) Copyright 2016 Gerrit Hohl
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19 package net.sourceforge.javadpkg.impl;
20
21 import java.util.ArrayList;
22 import java.util.List;
23
24 import net.sourceforge.javadpkg.Symbols;
25 import net.sourceforge.javadpkg.SymbolsEntry;
26
27
28 /**
29 * <p>
30 * A {@link Symbols} implementation.
31 * </p>
32 *
33 * @author Gerrit Hohl (gerrit-hohl@users.sourceforge.net)
34 * @version <b>1.0</b>, 10.01.2016 by Gerrit Hohl
35 */
36 public class SymbolsImpl implements Symbols {
37
38
39 /** The entries. */
40 private List<SymbolsEntry> entries;
41
42
43 /**
44 * <p>
45 * Creates symbols.
46 * </p>
47 */
48 public SymbolsImpl() {
49 super();
50
51 this.entries = new ArrayList<>();
52 }
53
54
55 /**
56 * <p>
57 * Adds an entry.
58 * </p>
59 *
60 * @param entry
61 * The entry.
62 * @throws IllegalArgumentException
63 * If the entry is <code>null</code>.
64 */
65 public void addEntry(SymbolsEntry entry) {
66 if (entry == null)
67 throw new IllegalArgumentException("Argument entry is null.");
68
69 this.entries.add(entry);
70 }
71
72
73 @Override
74 public String getText() {
75 StringBuilder sb;
76
77
78 sb = new StringBuilder();
79 for (SymbolsEntry entry : this.entries) {
80 if (sb.length() > 0)
81 sb.append('\n');
82 sb.append(entry.getText());
83 }
84 return sb.toString();
85 }
86
87
88 }