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

evolvedbinary / j8xu / 16

02 May 2024 01:02PM UTC coverage: 93.082%. First build
16

push

circleci

adamretter
[feature] Initial version of a String implementation of the XML Builder API

142 of 153 new or added lines in 9 files covered. (92.81%)

148 of 159 relevant lines covered (93.08%)

0.93 hits per line

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

93.75
/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
  private final StringContext context;
39

40
  /**
41
   * Default constructor.
42
   */
43
  public StringXmlBuilder() {
44
    this(null);
1✔
45
  }
1✔
46

47
  /**
48
   * Constructor.
49
   *
50
   * @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.
51
   */
52
  public StringXmlBuilder(@Nullable final String indent) {
1✔
53
    this.context = new StringContext(indent);
1✔
54
  }
1✔
55

56
  @Override
57
  public XmlDocumentBuilder<String> document(final XmlChildNodeBuilder<String>... children) {
NEW
58
    return new StringXmlDocumentBuilder(context, children);
×
59
  }
60

61
  @Override
62
  public XmlElementBuilder<String> element(final String localName, final XmlAttributesBuilder<String> attributes, final XmlChildNodeBuilder<String>... children) {
63
    return element(null, localName, null, attributes, children);
1✔
64
  }
65

66
  @Override
67
  public XmlElementBuilder<String> element(final String namespace, final String localName, final XmlAttributesBuilder<String> attributes, final XmlChildNodeBuilder<String>... children) {
68
    return element(namespace, localName, null, attributes, children);
1✔
69
  }
70

71
  @Override
72
  public XmlElementBuilder<String> element(@Nullable final String namespace, final String localName, @Nullable final String prefix, @Nullable final XmlAttributesBuilder<String> attributes, final XmlChildNodeBuilder<String>... children) {
73
    return new StringXmlElementBuilder(context, namespace, localName, prefix, attributes, children);
1✔
74
  }
75

76
  @Override
77
  public XmlElementBuilder<String> element(final String localName, final XmlChildNodeBuilder<String>... children) {
78
    return element(null, localName, null, null, children);
1✔
79
  }
80

81
  @Override
82
  public XmlElementBuilder<String> element(final String namespace, final String localName, final XmlChildNodeBuilder<String>... children) {
83
    return element(namespace, localName, null, null, children);
1✔
84
  }
85

86
  @Override
87
  public XmlElementBuilder<String> element(final String namespace, final String localName, final String prefix, final XmlChildNodeBuilder<String>... children) {
88
    return element(namespace, localName, prefix, null, children);
1✔
89
  }
90

91
  @Override
92
  public XmlAttributesBuilder<String> attributes(final XmlAttribute... attributes) {
93
    return new StringXmlAttributesBuilder(attributes);
1✔
94
  }
95

96
  @Override
97
  public XmlTextBuilder<String> text(final String content) {
98
    return new StringXmlTextBuilder(context, content);
1✔
99
  }
100

101
  @Override
102
  public XmlCommentBuilder<String> comment(final String content) {
103
    return new StringXmlCommentBuilder(context, content);
1✔
104
  }
105

106
  @Override
107
  public XmlCdataBuilder<String> cdata(final String content) {
108
    return new StringXmlCdataBuilder(context, content);
1✔
109
  }
110
}
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