MCPcopy Create free account
hub / github.com/BaseXdb/basex / check

Method check

basex-core/src/main/java/org/basex/util/XMLToken.java:241–256  ·  view source on GitHub ↗

Returns a valid token representation of the specified value. @param value object (can be null, will be converted to token otherwise) @param validate validate input @return token, or null if validation is enabled and if invalid characters are found

(final Object value, final boolean validate)

Source from the content-addressed store, hash-verified

239 * @return token, or {@code null} if validation is enabled and if invalid characters are found
240 */
241 public static byte[] check(final Object value, final boolean validate) {
242 if(value == null) return Token.EMPTY;
243
244 final TokenBuilder tb = new TokenBuilder();
245 final TokenParser tp = new TokenParser(Token.token(value));
246 while(tp.more()) {
247 final int cp = tp.next();
248 if(valid(cp)) {
249 tb.add(cp);
250 } else {
251 if(validate) return null;
252 tb.add(Token.REPLACEMENT);
253 }
254 }
255 return tb.finish();
256 }
257
258 /**
259 * Checks the specified token as an NCName.

Callers 2

namesMethod · 0.95
getMethod · 0.95

Calls 6

tokenMethod · 0.95
moreMethod · 0.95
nextMethod · 0.95
validMethod · 0.95
addMethod · 0.95
finishMethod · 0.95

Tested by

no test coverage detected