protected AbstractPolicy handleDocument ( Document doc , PolicyFinder policyFinder ) throws ParsingException { // handle the policy, if it's a known type Element root = doc . getDocumentElement ( ) ; String name = root . getTagName ( ) ; // see what type of policy this is if ( name . equals ( "Policy" ) ) { return Policy . getInstance ( root ) ; } else if ( name . equals ( "PolicySet" ) ) { return PolicySet . getInstance ( root , policyFinder ) ; } else { // this isn't a root type that we know how to handle throw new ParsingException ( "Unknown root document type: " + name ) ; } }
A private method that handles reading the policy and creates the correct kind of AbstractPolicy . Because this makes use of the policyFinder it cannot be reused between finders . Consider moving to policyManager which is not intended to be reused outside of a policyFinderModule which is not intended to be reused amongst PolicyFinder instances .