private ClassMatcher buildMatcher ( String tagText ) { // check there are at least @match <type> and a parameter String [ ] strings = StringUtil . tokenize ( tagText ) ; if ( strings . length < 2 ) { System . err . println ( "Skipping uncomplete @match tag, type missing: " + tagText + " in view " + viewDoc ) ; return null ; } try { if ( strings [ 0 ] . equals ( "class" ) ) { return new PatternMatcher ( Pattern . compile ( strings [ 1 ] ) ) ; } else if ( strings [ 0 ] . equals ( "context" ) ) { return new ContextMatcher ( root , Pattern . compile ( strings [ 1 ] ) , getGlobalOptions ( ) , false ) ; } else if ( strings [ 0 ] . equals ( "outgoingContext" ) ) { return new ContextMatcher ( root , Pattern . compile ( strings [ 1 ] ) , getGlobalOptions ( ) , false ) ; } else if ( strings [ 0 ] . equals ( "interface" ) ) { return new InterfaceMatcher ( root , Pattern . compile ( strings [ 1 ] ) ) ; } else if ( strings [ 0 ] . equals ( "subclass" ) ) { return new SubclassMatcher ( root , Pattern . compile ( strings [ 1 ] ) ) ; } else { System . err . println ( "Skipping @match tag, unknown match type, in view " + viewDoc ) ; } } catch ( PatternSyntaxException pse ) { System . err . println ( "Skipping @match tag due to invalid regular expression '" + tagText + "'" + " in view " + viewDoc ) ; } catch ( Exception e ) { System . err . println ( "Skipping @match tag due to an internal error '" + tagText + "'" + " in view " + viewDoc ) ; e . printStackTrace ( ) ; } return null ; }
Factory method that builds the appropriate matcher for