1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 package com.jcabi.xml;
31
32 import java.io.InputStream;
33 import java.io.Reader;
34 import java.nio.charset.StandardCharsets;
35 import org.cactoos.io.ResourceOf;
36 import org.cactoos.text.TextOf;
37 import org.w3c.dom.ls.LSInput;
38
39
40
41
42
43
44 final class ClasspathInput implements LSInput {
45
46
47
48
49 private transient String publicid;
50
51
52
53
54 private transient String systemid;
55
56
57
58
59
60
61 ClasspathInput(final String pubid, final String sysid) {
62 this.publicid = pubid;
63 this.systemid = sysid;
64 }
65
66 @Override
67 public String getPublicId() {
68 return this.publicid;
69 }
70
71 @Override
72 public void setPublicId(final String pubid) {
73 this.publicid = pubid;
74 }
75
76 @Override
77 public String getSystemId() {
78 return this.systemid;
79 }
80
81 @Override
82 public void setSystemId(final String sysid) {
83 this.systemid = sysid;
84 }
85
86 @Override
87 public String getBaseURI() {
88 return null;
89 }
90
91 @Override
92 public InputStream getByteStream() {
93 return null;
94 }
95
96 @Override
97 @SuppressWarnings("PMD.BooleanGetMethodName")
98 public boolean getCertifiedText() {
99 return false;
100 }
101
102 @Override
103 public Reader getCharacterStream() {
104 return null;
105 }
106
107 @Override
108 public String getEncoding() {
109 return null;
110 }
111
112 @Override
113 public String getStringData() {
114 try {
115 return new TextOf(
116 new ResourceOf(
117 this.systemid,
118 path -> {
119 throw new IllegalArgumentException(
120 String.format(
121 "SystemID \"%s\" resource does not exist or can't be opened.",
122 path
123 )
124 );
125 }
126 ),
127 StandardCharsets.UTF_8
128 ).asString();
129
130 } catch (final Exception ex) {
131 throw new IllegalArgumentException(
132 String.format(
133 "Unable to read input stream of SystemID \"%s\"",
134 this.systemid
135 ),
136 ex
137 );
138 }
139 }
140
141 @Override
142 public void setBaseURI(final String baseuri) {
143
144 }
145
146 @Override
147 public void setByteStream(final InputStream bytestream) {
148
149 }
150
151 @Override
152 public void setCertifiedText(final boolean certifiedtext) {
153
154 }
155
156 @Override
157 public void setCharacterStream(final Reader characterstream) {
158
159 }
160
161 @Override
162 public void setEncoding(final String encoding) {
163
164 }
165
166 @Override
167 public void setStringData(final String stringdata) {
168
169 }
170 }