/**
* Parse the useragent and return every part that was found.
*
* @param userAgent The useragent instance that needs to be parsed
* @return If the parse was valid (i.e. were there any parser errors: true=valid; false=has errors
*/
private MutableUserAgent parseIntoCleanUserAgent(MutableUserAgent userAgent) {
if (userAgent.getUserAgentString() == null) {
userAgent.set(SYNTAX_ERROR, "true", 1);
return userAgent; // Cannot parse this
}
// Parse the userAgent into tree
UserAgentContext userAgentContext = parseUserAgent(userAgent);
// Walk the tree an inform the calling analyzer about all the nodes found
state = new ParseTreeProperty<>();
State rootState = new State(AGENT);
rootState.calculatePath(PathType.CHILD, false);
state.put(userAgentContext, rootState);
if (userAgent.hasSyntaxError()) {
inform(null, SYNTAX_ERROR, "true");
} else {
inform(null, SYNTAX_ERROR, "false");
}
ParseTreeWalker.DEFAULT.walk(this, userAgentContext);
return userAgent;
}