MCPcopy Create free account
hub / github.com/w3c/epubcheck / parse

Method parse

src/main/java/com/adobe/epubcheck/util/SourceSet.java:140–276  ·  view source on GitHub ↗
(CharSequence srcset)

Source from the content-addressed store, hash-verified

138 }
139
140 public SourceSet parse(CharSequence srcset)
141 {
142 Builder builder = new Builder();
143 if (srcset == null || srcset.length() == 0)
144 {
145 error(ParseError.NULL_OR_EMPTY, -1);
146 return builder.build();
147 }
148 CharBuffer input = CharBuffer.wrap(srcset);
149 List<String> descriptors = new LinkedList<>();
150 StringBuilder url = new StringBuilder();
151 StringBuilder descriptor = new StringBuilder();
152 State state = State.SPLIT;
153 boolean consume = true;
154 char c = ' ';
155 while (!consume || input.hasRemaining())
156 {
157 if (consume)
158 {
159 c = input.get();
160 }
161 else
162 {
163 consume = true;
164 }
165 switch (state)
166 {
167 case SPLIT:
168 assert (url.length() == 0);
169 if (InfraUtil.isASCIIWhitespace(c))
170 {
171 // skip whitespace
172 }
173 else if (c == ',')
174 {
175 if (!builder.hasSources())
176 {
177 error(ParseError.EMPTY_START, input.position());
178 }
179 else
180 {
181 error(ParseError.EMPTY_MIDDLE, input.position());
182 }
183 }
184 else
185 {
186 state = State.COLLECT_URL;
187 consume = false;
188 }
189 break;
190 case COLLECT_URL:
191 if (isASCIIWhitespace(c))
192 {
193 if (url.charAt(url.length() - 1) == ',')
194 {
195 builder.add(finalizeSource(url, descriptors));
196 state = State.SPLIT;
197 }

Callers

nothing calls this directly

Calls 10

errorMethod · 0.95
buildMethod · 0.95
isASCIIWhitespaceMethod · 0.95
hasSourcesMethod · 0.95
addMethod · 0.95
finalizeSourceMethod · 0.95
getMethod · 0.65
addMethod · 0.65
appendMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected