PluggablePolicy getDelegate(final StreamingValidator streamer) { PluggablePolicy delegate = null; // factory hack if (policyDelegateClass.equals(BracePolicy.class)) { delegate = new SyntaxChecker().new BracePolicy(); } if (delegate != null) { delegate.inject(streamer); } return delegate; }
Result validate() { if (state == State.PROCESSING) { throw new UnsupportedOperationException( "This instance is processing a validation request. Please wait for completion or fork another instance"); } state = State.PROCESSING; Result result = new Result(); for (ValidationPolicy policy : policies) { PluggablePolicy delegate = policy.getDelegate(this); result.addResult(delegate.validate()); } memoryBuffer.clear(); // purge buffer return result; }