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