• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

evolvedbinary / j8xu / 25

02 May 2024 01:35PM UTC coverage: 92.169% (-0.9%) from 93.082%
25

push

circleci

adamretter
[doc] Add artifact coordinates

153 of 166 relevant lines covered (92.17%)

0.92 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

86.96
/src/main/java/com/evolvedbinary/j8xu/builder/impl/string/StringXmlBuilder.java
1
/*
2
 * Copyright © 2024, Evolved Binary Ltd. <tech@evolvedbinary.com>
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *     * Redistributions of source code must retain the above copyright
8
 *       notice, this list of conditions and the following disclaimer.
9
 *     * Redistributions in binary form must reproduce the above copyright
10
 *       notice, this list of conditions and the following disclaimer in the
11
 *       documentation and/or other materials provided with the distribution.
12
 *     * Neither the name of the <organization> nor the
13
 *       names of its contributors may be used to endorse or promote products
14
 *       derived from this software without specific prior written permission.
15
 *
16
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
 * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 */
27
package com.evolvedbinary.j8xu.builder.impl.string;
28

29
import com.evolvedbinary.j8xu.builder.api.*;
30

31
import javax.annotation.Nullable;
32

33
/**
34
 * An implementation of an XML Builder that builds a string representation.
35
 */
36
public class StringXmlBuilder implements XmlBuilder<String> {
37

38
  @SuppressWarnings("unchecked")
39
  private static final XmlChildNodeBuilder<String>[] NO_CHILDREN = new XmlChildNodeBuilder[0];
1✔
40

41
  private final StringContext context;
42

43
  /**
44
   * Default constructor.
45
   */
46
  public StringXmlBuilder() {
47
    this(null);
1✔
48
  }
1✔
49

50
  /**
51
   * Constructor.
52
   *
53
   * @param indent if you want the XML output to be indented you should set this to the indentation character(s), otherwise set it to null.
54
   */
55
  public StringXmlBuilder(@Nullable final String indent) {
1✔
56
    this.context = new StringContext(indent);
1✔
57
  }
1✔
58

59
  @SafeVarargs
60
  @Override
61
  public final XmlDocumentBuilder<String> document(final XmlChildNodeBuilder<String>... children) {
62
    return new StringXmlDocumentBuilder(context, children);
×
63
  }
64

65
  @Override
66
  public final XmlElementBuilder<String> element(final String localName, final XmlAttributesBuilder<String> attributes) {
67
    return element(null, localName, null, attributes, NO_CHILDREN);
1✔
68
  }
69

70
  @SafeVarargs
71
  @Override
72
  public final XmlElementBuilder<String> element(final String localName, final XmlAttributesBuilder<String> attributes, final XmlChildNodeBuilder<String>... children) {
73
    return element(null, localName, null, attributes, children);
×
74
  }
75

76
  @Override
77
  public final XmlElementBuilder<String> element(final String namespace, final String localName, final XmlAttributesBuilder<String> attributes) {
78
    return element(namespace, localName, null, attributes, NO_CHILDREN);
1✔
79
  }
80

81
  @SafeVarargs
82
  @Override
83
  public final XmlElementBuilder<String> element(final String namespace, final String localName, final XmlAttributesBuilder<String> attributes, final XmlChildNodeBuilder<String>... children) {
84
    return element(namespace, localName, null, attributes, children);
×
85
  }
86

87
  @Override
88
  public final XmlElementBuilder<String> element(@Nullable final String namespace, final String localName, @Nullable final String prefix, @Nullable final XmlAttributesBuilder<String> attributes) {
89
    return new StringXmlElementBuilder(context, namespace, localName, prefix, attributes, NO_CHILDREN);
1✔
90
  }
91

92
  @SafeVarargs
93
  @Override
94
  public final XmlElementBuilder<String> element(@Nullable final String namespace, final String localName, @Nullable final String prefix, @Nullable final XmlAttributesBuilder<String> attributes, final XmlChildNodeBuilder<String>... children) {
95
    return new StringXmlElementBuilder(context, namespace, localName, prefix, attributes, children);
1✔
96
  }
97

98
  @Override
99
  public final XmlElementBuilder<String> element(final String localName) {
100
    return element(null, localName, null, null, NO_CHILDREN);
1✔
101
  }
102

103
  @SafeVarargs
104
  @Override
105
  public final XmlElementBuilder<String> element(final String localName, final XmlChildNodeBuilder<String>... children) {
106
    return element(null, localName, null, null, children);
1✔
107
  }
108

109
  @Override
110
  public final XmlElementBuilder<String> element(final String namespace, final String localName) {
111
    return element(namespace, localName, null, null, NO_CHILDREN);
1✔
112
  }
113

114
  @SafeVarargs
115
  @Override
116
  public final XmlElementBuilder<String> element(final String namespace, final String localName, final XmlChildNodeBuilder<String>... children) {
117
    return element(namespace, localName, null, null, children);
1✔
118
  }
119

120
  @Override
121
  public final XmlElementBuilder<String> element(final String namespace, final String localName, final String prefix) {
122
    return element(namespace, localName, prefix, null, NO_CHILDREN);
1✔
123
  }
124

125
  @SafeVarargs
126
  @Override
127
  public final XmlElementBuilder<String> element(final String namespace, final String localName, final String prefix, final XmlChildNodeBuilder<String>... children) {
128
    return element(namespace, localName, prefix, null, children);
1✔
129
  }
130

131
  @SafeVarargs
132
  @Override
133
  public final XmlAttributesBuilder<String> attributes(final XmlAttribute... attributes) {
134
    return new StringXmlAttributesBuilder(attributes);
1✔
135
  }
136

137
  @Override
138
  public final XmlTextBuilder<String> text(final String content) {
139
    return new StringXmlTextBuilder(context, content);
1✔
140
  }
141

142
  @Override
143
  public final XmlCommentBuilder<String> comment(final String content) {
144
    return new StringXmlCommentBuilder(context, content);
1✔
145
  }
146

147
  @Override
148
  public final XmlCdataBuilder<String> cdata(final String content) {
149
    return new StringXmlCdataBuilder(context, content);
1✔
150
  }
151
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc