private void parseSelector ( String selector ) throws InvalidXPathSyntaxException { if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) tc . entry ( cclass , "parseSelector" , "selector: " + selector ) ; // Set the locationStep to -1 locationStep = - 1 ; int start = 0 ; // find number of path separators // Pre-check selector for multi-level wildcards. We can't handle these in // the optimised code. Simply wrap the entire expression int posWildCard = selector . indexOf ( "//" , start ) ; if ( posWildCard >= 0 ) { // We have a multi-level wildcard, process the whole thing locationStep = 0 ; selOperands . add ( createIdentifierForWildExpression ( selector ) ) ; return ; } // Locate the first path separator int posSeparator = selector . indexOf ( "/" , start ) ; // Handle an initial separator character if ( posSeparator == 0 ) { // An initial slash String step = selector . substring ( start , start + 1 ) ; // Add an IdentifierImpl for the location step to the array list selOperands . add ( createIdentifierForSubExpression ( step , step , true , false ) ) ; // Bump the start counter start ++ ; } // Now iterate over the rest of the selector string attempting to isolate // Individual location path steps. int stepEnd = 0 ; while ( stepEnd >= 0 ) { StepProperties stepProperties = new StepProperties ( ) ; // Drive the method that isolates the next step isolateNextStep ( selector , start , stepProperties ) ; stepEnd = stepProperties . endOfStep ; // Useful debug if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isDebugEnabled ( ) ) { if ( stepEnd < 0 ) { tc . debug ( this , cclass , "parsePredicate" , "isolated Step: " + selector . substring ( start ) + " and wrapStep is " + stepProperties . wrapStep ) ; } else { tc . debug ( this , cclass , "parsePredicate" , "isolated Step: " + selector . substring ( start , stepEnd ) + " and wrapStep is " + stepProperties . wrapStep ) ; } } // Should the entire location step be wrapped in an Identifier if ( stepProperties . wrapStep ) { if ( stepEnd < 0 ) { // Wrap entire location step in an Identifier wrapLastLocationStep ( selector , start , true ) ; } else { // Wrap intermediate location step in an Identifier wrapLocationStep ( selector , start , stepEnd ) ; } } else { // We can attempt to parse the step using the MatchParser if ( stepEnd < 0 ) { // This is the final location step parseLastLocationStep ( selector , start ) ; } else { // An intermediate location step parseLocationStep ( selector , start , stepEnd ) ; } } // Bump the start parameter and then look for next step if ( stepEnd >= 0 ) start = stepEnd + 1 ; } if ( TraceComponent . isAnyTracingEnabled ( ) && tc . isEntryEnabled ( ) ) tc . exit ( this , cclass , "parseSelector" ) ; }
Parse the XPath Selector expression .