signature:
public class SVRLHelper { /** * Get a list of all successful reports in a given schematron output , with an
 * error level equally or more severe than the passed error level .
 * @ param aSchematronOutput
 * The schematron output to be used . May be < code > null < / code > .
 * @ param aErrorLevel
 * Minimum error level to be queried
 * @ return A non - < code > null < / code > list with all successful reports . */
@ Nonnull @ ReturnsMutableCopy public static ICommonsList < SVRLSuccessfulReport > getAllSuccessfulReportsMoreOrEqualSevereThan ( @ Nullable final SchematronOutputType aSchematronOutput , @ Nonnull final IErrorLevel aErrorLevel ) { } }

implementation: final ICommonsList < SVRLSuccessfulReport > ret = new CommonsArrayList < > ( ) ; if ( aSchematronOutput != null ) for ( final Object aObj : aSchematronOutput . getActivePatternAndFiredRuleAndFailedAssert ( ) ) if ( aObj instanceof SuccessfulReport ) { final SVRLSuccessfulReport aSR = new SVRLSuccessfulReport ( ( SuccessfulReport ) aObj ) ; if ( aSR . getFlag ( ) . isGE ( aErrorLevel ) ) ret . add ( aSR ) ; } return ret ;


signature:
public class SVRLHelper { /** * Get a list of all failed assertions and successful reports in a given
 * schematron output .
 * @ param aSchematronOutput
 * The schematron output to be used . May be < code > null < / code > .
 * @ return A non - < code > null < / code > list with all failed assertions and
 * successful reports . Maybe an empty list if the input is
 * < code > null < / code > . */
@ Nonnull @ ReturnsMutableCopy public static ICommonsList < AbstractSVRLMessage > getAllFailedAssertionsAndSuccessfulReports ( @ Nullable final SchematronOutputType aSchematronOutput ) { } }

implementation: final ICommonsList < AbstractSVRLMessage > ret = new CommonsArrayList < > ( ) ; if ( aSchematronOutput != null ) for ( final Object aObj : aSchematronOutput . getActivePatternAndFiredRuleAndFailedAssert ( ) ) if ( aObj instanceof FailedAssert ) ret . add ( new SVRLFailedAssert ( ( FailedAssert ) aObj ) ) ; else if ( aObj instanceof SuccessfulReport ) ret . add ( new SVRLSuccessfulReport ( ( SuccessfulReport ) aObj ) ) ; return ret ;


signature:
public class SVRLHelper { /** * Set the global error level determinator .
 * @ param aELD
 * The determinator to use . May not be < code > null < / code > . */
public static void setErrorLevelDeterminator ( @ Nonnull final ISVRLErrorLevelDeterminator aELD ) { } }

implementation: ValueEnforcer . notNull ( aELD , "ErrorLevelDeterminator" ) ; s_aRWLock . readLocked ( ( ) -> s_aELD = aELD ) ;


signature:
public class SVRLHelper { /** * Convert an " unsexy " location string in the for , of
 * < code > * : xx [ namespace - uri ( ) = ' yy ' ] < / code > to something more readable like
 * < code > prefix : xx < / code > by using the mapping registered in the
 * { @ link SVRLLocationBeautifierRegistry } .
 * @ param sLocation
 * The original location string . May not be < code > null < / code > .
 * @ return The beautified string . Never < code > null < / code > . Might be identical
 * to the original string if the pattern was not found .
 * @ since 5.0.1 */
@ Nonnull public static String getBeautifiedLocation ( @ Nonnull final String sLocation ) { } }

implementation:
String sResult = sLocation ; // Handle namespaces :
// Search for " * : xx [ namespace - uri ( ) = ' yy ' ] " where xx is the localname and yy
// is the namespace URI
final Matcher aMatcher = RegExHelper . getMatcher ( "\\Q*:\\E([a-zA-Z0-9_]+)\\Q[namespace-uri()='\\E([^']+)\\Q']\\E" , sResult ) ; while ( aMatcher . find ( ) ) { final String sLocalName = aMatcher . group ( 1 ) ; final String sNamespaceURI = aMatcher . group ( 2 ) ; // Check if there is a known beautifier for this pair of namespace and
// local name
final String sBeautified = SVRLLocationBeautifierRegistry . getBeautifiedLocation ( sNamespaceURI , sLocalName ) ; if ( sBeautified != null ) sResult = StringHelper . replaceAll ( sResult , aMatcher . group ( ) , sBeautified ) ; } return sResult ;


signature:
public class PSQueryBindingRegistry { /** * Get the query binding with the specified name .
 * @ param sName
 * The name to the query binding to retrieve . May be < code > null < / code > .
 * If it is < code > null < / code > than the { @ link # DEFAULT _ QUERY _ BINDING }
 * object is returned .
 * @ return < code > null < / code > if no such query binding was found . */
@ Nullable public static IPSQueryBinding getQueryBindingOfName ( @ Nullable final String sName ) { } }

implementation: if ( sName == null ) return DEFAULT_QUERY_BINDING ; return s_aRWLock . readLocked ( ( ) -> s_aMap . get ( sName ) ) ;


signature:
public class PSQueryBindingRegistry { /** * Get the query binding with the specified name
 * @ param sName
 * The name of the query binding to look up . May be < code > null < / code > .
 * @ return Never < code > null < / code > .
 * @ throws SchematronBindException
 * In case the query binding could not be resolved ! */
@ Nonnull public static IPSQueryBinding getQueryBindingOfNameOrThrow ( @ Nullable final String sName ) throws SchematronBindException { } }

implementation: final IPSQueryBinding aQB = getQueryBindingOfName ( sName ) ; if ( aQB == null ) throw new SchematronBindException ( "No query binding implementation present for query binding '" + sName + "'" ) ; return aQB ;


signature:
public class PSXPathBoundSchema { /** * Compile an XPath expression string to an { @ link XPathExpressionException }
 * object . If expression contains any variables , the
 * { @ link XPathVariableResolver } will be used to resolve them within this
 * method !
 * @ param aXPathContext
 * Context to use . May not be < code > null < / code > .
 * @ param sXPathExpression
 * The expression to be compiled . May not be < code > null < / code > .
 * @ return The precompiled { @ link XPathExpression }
 * @ throws XPathExpressionException
 * If expression cannot be compiled . */
@ Nullable private static XPathExpression _compileXPath ( @ Nonnull final XPath aXPathContext , @ Nonnull final String sXPathExpression ) throws XPathExpressionException { } }

implementation:
XPathExpression ret = null ; try { ret = aXPathContext . compile ( sXPathExpression ) ; } catch ( final XPathExpressionException ex ) { // Do something with it
throw ex ; } return ret ;


signature:
public class PSXPathBoundSchema { /** * Pre - compile all patterns incl . their content
 * @ param aXPathContext
 * @ param aXPathContext
 * Global XPath object to use . May not be < code > null < / code > .
 * @ param aBoundDiagnostics
 * A map from DiagnosticID to its mapped counterpart . May not be
 * < code > null < / code > .
 * @ param aGlobalVariables
 * The global Schematron - let variables . May not be < code > null < / code > .
 * @ return < code > null < / code > if an XPath error is contained */
@ Nullable private ICommonsList < PSXPathBoundPattern > _createBoundPatterns ( @ Nonnull final XPath aXPathContext , @ Nonnull final ICommonsMap < String , PSXPathBoundDiagnostic > aBoundDiagnostics , @ Nonnull final IPSXPathVariables aGlobalVariables ) { } }

implementation:
final ICommonsList < PSXPathBoundPattern > ret = new CommonsArrayList < > ( ) ; boolean bHasAnyError = false ; // For all relevant patterns
for ( final PSPattern aPattern : getAllRelevantPatterns ( ) ) { // Handle pattern specific variables
final PSXPathVariables aPatternVariables = aGlobalVariables . getClone ( ) ; if ( aPattern . hasAnyLet ( ) ) { // The pattern has special variables , so we need to extend the variable
// map
for ( final Map . Entry < String , String > aEntry : aPattern . getAllLetsAsMap ( ) . entrySet ( ) ) if ( aPatternVariables . add ( aEntry ) . isUnchanged ( ) ) error ( aPattern , "Duplicate <let> with name '" + aEntry . getKey ( ) + "' in <pattern>" ) ; } // For all rules of the current pattern
final ICommonsList < PSXPathBoundRule > aBoundRules = new CommonsArrayList < > ( ) ; for ( final PSRule aRule : aPattern . getAllRules ( ) ) { // Handle rule specific variables
final PSXPathVariables aRuleVariables = aPatternVariables . getClone ( ) ; if ( aRule . hasAnyLet ( ) ) { // The rule has special variables , so we need to extend the
// variable map
for ( final Map . Entry < String , String > aEntry : aRule . getAllLetsAsMap ( ) . entrySet ( ) ) if ( aRuleVariables . add ( aEntry ) . isUnchanged ( ) ) error ( aRule , "Duplicate <let> with name '" + aEntry . getKey ( ) + "' in <rule>" ) ; } // For all contained assert and reports within the current rule
final ICommonsList < PSXPathBoundAssertReport > aBoundAssertReports = new CommonsArrayList < > ( ) ; for ( final PSAssertReport aAssertReport : aRule . getAllAssertReports ( ) ) { final String sTest = aRuleVariables . getAppliedReplacement ( aAssertReport . getTest ( ) ) ; try { final XPathExpression aTestExpr = _compileXPath ( aXPathContext , sTest ) ; final ICommonsList < PSXPathBoundElement > aBoundElements = _createBoundElements ( aAssertReport , aXPathContext , aRuleVariables ) ; if ( aBoundElements == null ) { // Error already emitted
bHasAnyError = true ; } else { final PSXPathBoundAssertReport aBoundAssertReport = new PSXPathBoundAssertReport ( aAssertReport , sTest , aTestExpr , aBoundElements , aBoundDiagnostics ) ; aBoundAssertReports . add ( aBoundAssertReport ) ; } } catch ( final Throwable t ) { error ( aAssertReport , "Failed to compile XPath expression in <" + ( aAssertReport . isAssert ( ) ? "assert" : "report" ) + ">: '" + sTest + "' with the following variables: " + aRuleVariables . getAll ( ) , t ) ; bHasAnyError = true ; } } // Evaluate base node set for this rule
final String sRuleContext = aGlobalVariables . getAppliedReplacement ( getValidationContext ( aRule . getContext ( ) ) ) ; PSXPathBoundRule aBoundRule = null ; try { final XPathExpression aRuleContext = _compileXPath ( aXPathContext , sRuleContext ) ; aBoundRule = new PSXPathBoundRule ( aRule , sRuleContext , aRuleContext , aBoundAssertReports ) ; aBoundRules . add ( aBoundRule ) ; } catch ( final XPathExpressionException ex ) { error ( aRule , "Failed to compile XPath expression in <rule>: '" + sRuleContext + "'" , ex . getCause ( ) != null ? ex . getCause ( ) : ex ) ; bHasAnyError = true ; } } // Create the bound pattern
final PSXPathBoundPattern aBoundPattern = new PSXPathBoundPattern ( aPattern , aBoundRules ) ; ret . add ( aBoundPattern ) ; } if ( bHasAnyError ) return null ; return ret ;


signature:
public class XQueryAsXPathFunctionConverter { /** * Load XQuery functions from an input stream . As this function is supposed to
 * work with Saxon HE , this method allows only for loading full XQuery modules
 * and not for XQuery libraries .
 * @ param aXQueryIS
 * The Input Stream to read from . May not be < code > null < / code > . Will be
 * closed automatically in this method .
 * @ return A non - < code > null < / code > { @ link MapBasedXPathFunctionResolver }
 * containing all loaded functions .
 * @ throws XPathException
 * if the syntax of the expression is wrong , or if it references
 * namespaces , variables , or functions that have not been declared , or
 * any other static error is reported .
 * @ throws IOException
 * if a failure occurs reading the supplied input . */
@ Nonnull public MapBasedXPathFunctionResolver loadXQuery ( @ Nonnull @ WillClose final InputStream aXQueryIS ) throws XPathException , IOException { } }

implementation:
ValueEnforcer . notNull ( aXQueryIS , "XQueryIS" ) ; try { final MapBasedXPathFunctionResolver aFunctionResolver = new MapBasedXPathFunctionResolver ( ) ; // create a Configuration object
final Configuration aConfiguration = new Configuration ( ) ; final DynamicQueryContext aDynamicQueryContext = new DynamicQueryContext ( aConfiguration ) ; final StaticQueryContext aStaticQueryCtx = aConfiguration . newStaticQueryContext ( ) ; // The base URI required for resolving within the XQuery
aStaticQueryCtx . setBaseURI ( m_sBaseURL ) ; // null = = auto detect
final String sEncoding = null ; final XQueryExpression exp = aStaticQueryCtx . compileQuery ( aXQueryIS , sEncoding ) ; final Controller aXQController = exp . newController ( aDynamicQueryContext ) ; // find all loaded methods and convert them to XPath functions
final FunctionLibraryList aFuncLibList = exp . getExecutable ( ) . getFunctionLibrary ( ) ; for ( final FunctionLibrary aFuncLib : aFuncLibList . getLibraryList ( ) ) { // Ignore all Vendor , System etc . internal libraries
if ( aFuncLib instanceof FunctionLibraryList ) { // This block works with Saxon HE 9.5.1 - x : )
// This is the custom function library list
final FunctionLibraryList aRealFuncLib = ( FunctionLibraryList ) aFuncLib ; for ( final FunctionLibrary aNestedFuncLib : aRealFuncLib . getLibraryList ( ) ) { // Currently the user functions are in ExecutableFunctionLibrary
if ( aNestedFuncLib instanceof ExecutableFunctionLibrary ) for ( final UserFunction aUserFunc : new IterableIterator < > ( ( ( ExecutableFunctionLibrary ) aNestedFuncLib ) . iterateFunctions ( ) ) ) { // Saxon 9.7 changes " getNumberOfArguments " to " getArity "
aFunctionResolver . addUniqueFunction ( aUserFunc . getFunctionName ( ) . getNamespaceBinding ( ) . getURI ( ) , aUserFunc . getFunctionName ( ) . getLocalPart ( ) , aUserFunc . getArity ( ) , new XPathFunctionFromUserFunction ( aConfiguration , aXQController , aUserFunc ) ) ; } } } else if ( aFuncLib instanceof XQueryFunctionLibrary ) { // This block works with Saxon HE 9.6.0 - x : )
final XQueryFunctionLibrary aRealFuncLib = ( XQueryFunctionLibrary ) aFuncLib ; for ( final XQueryFunction aXQueryFunction : new IterableIterator < > ( aRealFuncLib . getFunctionDefinitions ( ) ) ) { // Ensure the function is compiled
aXQueryFunction . compile ( ) ; aFunctionResolver . addUniqueFunction ( aXQueryFunction . getFunctionName ( ) . getNamespaceBinding ( ) . getURI ( ) , aXQueryFunction . getFunctionName ( ) . getLocalPart ( ) , aXQueryFunction . getNumberOfArguments ( ) , new XPathFunctionFromUserFunction ( aConfiguration , aXQController , aXQueryFunction . getUserFunction ( ) ) ) ; } } } return aFunctionResolver ; } finally { StreamHelper . close ( aXQueryIS ) ; }


signature:
public class Slf4jAdapter { /** * { @ inheritDoc } */
@ Override public void trace ( final String format , final Object first , final Object second ) { } }

implementation: _log ( ) . debug ( _format ( format , first , second ) ) ;


signature:
public class Slf4jAdapter { /** * { @ inheritDoc } */
@ Override public void trace ( final String format , final Object ... array ) { } }

implementation: _log ( ) . debug ( _format ( format , array ) ) ;


signature:
public class Slf4jAdapter { /** * { @ inheritDoc } */
@ Override public void trace ( final String msg , final Throwable thr ) { } }

implementation: _log ( ) . debug ( msg , thr ) ;


signature:
public class Slf4jAdapter { /** * { @ inheritDoc } */
@ Override public void debug ( final String format , final Object arg ) { } }

implementation: _log ( ) . debug ( _format ( format , arg ) ) ;


signature:
public class Slf4jAdapter { /** * { @ inheritDoc } */
@ Override public void info ( final String format , final Object arg ) { } }

implementation: _log ( ) . info ( _format ( format , arg ) ) ;


signature:
public class Slf4jAdapter { /** * { @ inheritDoc } */
@ Override public void info ( final String format , final Object ... array ) { } }

implementation: _log ( ) . info ( _format ( format , array ) ) ;


signature:
public class Slf4jAdapter { /** * { @ inheritDoc } */
@ Override public void info ( final String msg , final Throwable thr ) { } }

implementation: _log ( ) . info ( msg , thr ) ;


signature:
public class Slf4jAdapter { /** * { @ inheritDoc } */
@ Override public void warn ( final String format , final Object arg ) { } }

implementation: _log ( ) . warn ( _format ( format , arg ) ) ;


signature:
public class Slf4jAdapter { /** * { @ inheritDoc } */
@ Override public void warn ( final String format , final Object ... array ) { } }

implementation: _log ( ) . warn ( _format ( format , array ) ) ;


signature:
public class Slf4jAdapter { /** * { @ inheritDoc } */
@ Override public void warn ( final String msg , final Throwable thr ) { } }

implementation: _log ( ) . warn ( msg , thr ) ;


signature:
public class Slf4jAdapter { /** * { @ inheritDoc } */
@ Override public void error ( final String format , final Object arg ) { } }

implementation: _log ( ) . error ( _format ( format , arg ) ) ;


signature:
public class Slf4jAdapter { /** * { @ inheritDoc } */
@ Override public void error ( final String format , final Object ... array ) { } }

implementation: _log ( ) . error ( _format ( format , array ) ) ;


signature:
public class Slf4jAdapter { /** * { @ inheritDoc } */
@ Override public void error ( final String msg , final Throwable thr ) { } }

implementation: _log ( ) . error ( msg , thr ) ;


signature:
public class Slf4jAdapter { /** * Format with one object .
 * @ param format
 * Format to use
 * @ param arg
 * One argument
 * @ return The message */
private String _format ( final String format , final Object arg ) { } }

implementation: final FormattingTuple tuple = MessageFormatter . format ( format , arg ) ; return tuple . getMessage ( ) ;


signature:
public class Slf4jAdapter { /** * Format with two objects .
 * @ param format
 * Format to use
 * @ param first
 * First argument
 * @ param second
 * Second argument
 * @ return The message */
private String _format ( final String format , final Object first , final Object second ) { } }

implementation: final FormattingTuple tuple = MessageFormatter . format ( format , first , second ) ; return tuple . getMessage ( ) ;


signature:
public class SchematronResourceHelper { /** * Convert the passed transform source into a DOM node . Currently on
 * { @ link DOMSource } and { @ link StreamSource } can be handled .
 * @ param aSource
 * The transform source to use . May not be < code > null < / code > .
 * @ param aDRS
 * DOMReader settings to use . May not be < code > null < / code > .
 * @ return The DOM node and never < code > null < / code > .
 * @ throws SAXException
 * In case XML parsing fails
 * @ throws IllegalArgumentException
 * in case an unsupported { @ link Source } implementation is provided . */
@ Nullable public static Node getNodeOfSource ( @ Nonnull final Source aSource , @ Nonnull final DOMReaderSettings aDRS ) throws SAXException { } }

implementation:
ValueEnforcer . notNull ( aSource , "Source" ) ; ValueEnforcer . notNull ( aDRS , "DOMReaderSettings" ) ; if ( aSource instanceof DOMSource ) { // Node is already in DOMSource
return ( ( DOMSource ) aSource ) . getNode ( ) ; } if ( aSource instanceof StreamSource ) { // In StreamSource it can either be a byte stream or a character stream or
// a system ID
final StreamSource aStreamSource = ( StreamSource ) aSource ; final InputStream aIS = aStreamSource . getInputStream ( ) ; if ( aIS != null ) { // Byte stream
final Document aDoc = DOMReader . readXMLDOM ( aIS , aDRS != null ? aDRS : new DOMReaderSettings ( ) ) ; if ( aDoc == null ) throw new IllegalArgumentException ( "Failed to read source " + aSource + " as XML from InputStream " + aIS ) ; return aDoc ; } final Reader aReader = aStreamSource . getReader ( ) ; if ( aReader != null ) { // CHaracter stream
final Document aDoc = DOMReader . readXMLDOM ( aReader , aDRS ) ; if ( aDoc == null ) throw new IllegalArgumentException ( "Failed to read source " + aSource + " as XML from Reader " + aReader ) ; return aDoc ; } final String sSystemID = aStreamSource . getSystemId ( ) ; if ( StringHelper . hasText ( sSystemID ) ) { // System ID
try { final URLResource aURL = new URLResource ( sSystemID ) ; final Document aDoc = DOMReader . readXMLDOM ( aURL , aDRS ) ; if ( aDoc == null ) throw new IllegalArgumentException ( "Failed to read source " + aSource + " as XML from SystemID '" + sSystemID + "'" ) ; return aDoc ; } catch ( final MalformedURLException ex ) { throw new IllegalArgumentException ( "Failed to read source " + aSource + " as XML from SystemID '" + sSystemID + "': " + ex . getMessage ( ) ) ; } } // Neither InputStream nor Reader present
LOGGER . error ( "StreamSource contains neither InputStream nor Reader nor SystemID - cannot handle!" ) ; return null ; } final String sMsg = "Can only handle DOMSource and StreamSource - having " + aSource + " with system ID '" + aSource . getSystemId ( ) + "'" ; LOGGER . error ( sMsg ) ; throw new IllegalArgumentException ( sMsg ) ;


signature:
public class SchematronValidator { /** * Check if the passed micro node is a valid schematron instance .
 * @ param aNode
 * The micro node to check . May be < code > null < / code > .
 * @ return < code > true < / code > if the schematron is valid , < code > false < / code >
 * otherwise . */
public static boolean isValidSchematron ( @ Nullable final IMicroNode aNode ) { } }

implementation: if ( aNode == null ) return false ; return isValidSchematron ( TransformSourceFactory . create ( MicroWriter . getNodeAsString ( aNode ) ) ) ;


signature:
public class SchematronValidator { /** * Check if the passed DOM node is a valid schematron instance .
 * @ param aNode
 * The DOM node to check . May be < code > null < / code > .
 * @ return < code > true < / code > if the schematron is valid , < code > false < / code >
 * otherwise . */
public static boolean isValidSchematron ( @ Nullable final Node aNode ) { } }

implementation: if ( aNode == null ) return false ; return isValidSchematron ( TransformSourceFactory . create ( aNode ) ) ;


signature:
public class SchematronValidator { /** * Check if the passed resource is a valid schematron instance .
 * @ param aRes
 * The resource to check . May be < code > null < / code > .
 * @ return < code > true < / code > if the schematron is valid , < code > false < / code >
 * otherwise . */
public static boolean isValidSchematron ( @ Nullable final IReadableResource aRes ) { } }

implementation: if ( aRes == null ) return false ; return isValidSchematron ( TransformSourceFactory . create ( aRes ) ) ;


signature:
public class SchematronValidator { /** * Check if the passed source is a valid schematron instance .
 * @ param aSource
 * The source to check . May be < code > null < / code > .
 * @ return < code > true < / code > if the schematron is valid , < code > false < / code >
 * otherwise . */
public static boolean isValidSchematron ( @ Nullable final Source aSource ) { } }

implementation:
if ( aSource == null ) return false ; try { // Get a validator from the RNC schema .
final Validator aValidator = RelaxNGCompactSchemaCache . getInstance ( ) . getValidator ( SCHEMATRON_RNC ) ; // Ensure a collecting error handler is set
final ErrorHandler aOldEH = aValidator . getErrorHandler ( ) ; CollectingSAXErrorHandler aCEH ; if ( aOldEH instanceof CollectingSAXErrorHandler ) aCEH = ( CollectingSAXErrorHandler ) aOldEH ; else { aCEH = new CollectingSAXErrorHandler ( ) ; aValidator . setErrorHandler ( aCEH . andThen ( aOldEH ) ) ; } // Perform validation
aValidator . validate ( aSource , null ) ; // Check results
return aCEH . getErrorList ( ) . getMostSevereErrorLevel ( ) . isLT ( EErrorLevel . ERROR ) ; } catch ( final SAXException ex ) { // Document is not valid in respect to XML
} catch ( final IOException ex ) { LOGGER . warn ( "Failed to read source " + aSource , ex ) ; } return false ;


signature:
public class SchematronResourceSCHCache { /** * Create a new Schematron validator for the passed resource .
 * @ param aSchematronResource
 * The resource of the Schematron rules . May not be < code > null < / code > .
 * @ param aTransformerCustomizer
 * The XSLT transformer customizer to be used . May not be
 * < code > null < / code > .
 * @ return < code > null < / code > if the passed Schematron resource does not exist
 * or is invalid . */
@ Nullable public static SchematronProviderXSLTFromSCH createSchematronXSLTProvider ( @ Nonnull final IReadableResource aSchematronResource , @ Nonnull final SCHTransformerCustomizer aTransformerCustomizer ) { } }

implementation:
if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Compiling Schematron instance " + aSchematronResource . toString ( ) ) ; final SchematronProviderXSLTFromSCH aXSLTPreprocessor = new SchematronProviderXSLTFromSCH ( aSchematronResource , aTransformerCustomizer ) ; if ( ! aXSLTPreprocessor . isValidSchematron ( ) ) { // Schematron is invalid - > parsing failed
LOGGER . warn ( "The Schematron resource '" + aSchematronResource . getResourceID ( ) + "' is invalid!" ) ; if ( LOGGER . isDebugEnabled ( ) && aXSLTPreprocessor . getXSLTDocument ( ) != null ) { // Log the created XSLT document for better error tracking
LOGGER . debug ( "  Created XSLT document:\n" + XMLWriter . getNodeAsString ( aXSLTPreprocessor . getXSLTDocument ( ) ) ) ; } return null ; } // If it is a valid schematron , there must be a result XSLT present !
if ( aXSLTPreprocessor . getXSLTDocument ( ) == null ) throw new IllegalStateException ( "No XSLT document retrieved from Schematron resource '" + aSchematronResource . getResourceID ( ) + "'!" ) ; if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Finished compiling Schematron instance " + aSchematronResource . toString ( ) ) ; // Create the main validator for the schematron
return aXSLTPreprocessor ;


signature:
public class SchematronResourceSCHCache { /** * Get the Schematron validator for the passed resource . If no custom
 * parameter are present , the result is cached . The respective cache key is a
 * combination of the Schematron resource path , the phase and the language
 * code .
 * @ param aSchematronResource
 * The resource of the Schematron rules . May not be < code > null < / code > .
 * @ param aTransformerCustomizer
 * The XSLT transformer customizer to be used . May not be
 * < code > null < / code > .
 * @ return < code > null < / code > if the passed Schematron resource does not exist
 * or is invalid . */
@ Nullable public static SchematronProviderXSLTFromSCH getSchematronXSLTProvider ( @ Nonnull final IReadableResource aSchematronResource , @ Nonnull final SCHTransformerCustomizer aTransformerCustomizer ) { } }

implementation:
ValueEnforcer . notNull ( aSchematronResource , "SchematronResource" ) ; ValueEnforcer . notNull ( aTransformerCustomizer , "TransformerCustomizer" ) ; if ( ! aSchematronResource . exists ( ) ) { LOGGER . warn ( "Schematron resource " + aSchematronResource + " does not exist!" ) ; return null ; } if ( ! aTransformerCustomizer . canCacheResult ( ) ) { // Create new object and return without cache handling because the custom
// parameters may have side effects on the created XSLT !
return createSchematronXSLTProvider ( aSchematronResource , aTransformerCustomizer ) ; } // Determine the unique resource ID for caching
final String sCacheKey = StringHelper . < String > getImploded ( ':' , aSchematronResource . getResourceID ( ) , StringHelper . getNotNull ( aTransformerCustomizer . getPhase ( ) ) , StringHelper . getNotNull ( aTransformerCustomizer . getLanguageCode ( ) ) ) ; s_aLock . lock ( ) ; try { // Validator already in the cache ?
SchematronProviderXSLTFromSCH aProvider = s_aCache . get ( sCacheKey ) ; if ( aProvider == null ) { // Create new object and put in cache
aProvider = createSchematronXSLTProvider ( aSchematronResource , aTransformerCustomizer ) ; if ( aProvider != null ) s_aCache . put ( sCacheKey , aProvider ) ; } return aProvider ; } finally { s_aLock . unlock ( ) ; }


signature:
public class PSXPathValidationHandlerSVRL { /** * Get the error text from an assert or report element .
 * @ param aBoundContentElements
 * The list of bound elements to be evaluated .
 * @ param aSourceNode
 * The XML node of the document currently validated .
 * @ return A non - < code > null < / code > String
 * @ throws SchematronValidationException
 * In case evaluating an XPath expression fails . */
@ Nonnull private String _getErrorText ( @ Nonnull final List < PSXPathBoundElement > aBoundContentElements , @ Nonnull final Node aSourceNode ) throws SchematronValidationException { } }

implementation:
final StringBuilder aSB = new StringBuilder ( ) ; for ( final PSXPathBoundElement aBoundElement : aBoundContentElements ) { final Object aContent = aBoundElement . getElement ( ) ; if ( aContent instanceof String ) aSB . append ( ( String ) aContent ) ; else if ( aContent instanceof PSName ) { final PSName aName = ( PSName ) aContent ; if ( aName . hasPath ( ) ) { // XPath present
try { aSB . append ( ( String ) XPathEvaluationHelper . evaluate ( aBoundElement . getBoundExpression ( ) , aSourceNode , XPathConstants . STRING , m_sBaseURI ) ) ; } catch ( final XPathExpressionException ex ) { _error ( aName , "Failed to evaluate XPath expression to a string: '" + aBoundElement . getExpression ( ) + "'" , ex . getCause ( ) != null ? ex . getCause ( ) : ex ) ; // Append the path so that something is present in the output
aSB . append ( aName . getPath ( ) ) ; } } else { // No XPath present
aSB . append ( aSourceNode . getNodeName ( ) ) ; } } else if ( aContent instanceof PSValueOf ) { final PSValueOf aValueOf = ( PSValueOf ) aContent ; try { aSB . append ( ( String ) XPathEvaluationHelper . evaluate ( aBoundElement . getBoundExpression ( ) , aSourceNode , XPathConstants . STRING , m_sBaseURI ) ) ; } catch ( final XPathExpressionException ex ) { _error ( aValueOf , "Failed to evaluate XPath expression to a string: '" + aBoundElement . getExpression ( ) + "'" , ex ) ; // Append the path so that something is present in the output
aSB . append ( aValueOf . getSelect ( ) ) ; } } else if ( aContent instanceof PSEmph ) aSB . append ( ( ( PSEmph ) aContent ) . getAsText ( ) ) ; else if ( aContent instanceof PSDir ) aSB . append ( ( ( PSDir ) aContent ) . getAsText ( ) ) ; else if ( aContent instanceof PSSpan ) aSB . append ( ( ( PSSpan ) aContent ) . getAsText ( ) ) ; else throw new SchematronValidationException ( "Unsupported assert/report content element: " + aContent ) ; } return aSB . toString ( ) ;


signature:
public class PSXPathValidationHandlerSVRL { /** * Handle the diagnostic references of a single assert / report element
 * @ param aSrcDiagnostics
 * The list of diagnostic reference IDs in the source assert / report
 * element . May be < code > null < / code > if no diagnostic references are
 * present
 * @ param aDstList
 * The diagnostic reference list of the SchematronOutput to be filled .
 * May not be < code > null < / code > .
 * @ param aBoundAssertReport
 * The bound assert report element . Never < code > null < / code > .
 * @ param aRuleMatchingNode
 * The XML node of the XML document currently validated . Never
 * < code > null < / code > .
 * @ throws SchematronValidationException */
private void _handleDiagnosticReferences ( @ Nullable final List < String > aSrcDiagnostics , @ Nonnull final List < DiagnosticReference > aDstList , @ Nonnull final PSXPathBoundAssertReport aBoundAssertReport , @ Nonnull final Node aRuleMatchingNode ) throws SchematronValidationException { } }

implementation:
if ( CollectionHelper . isNotEmpty ( aSrcDiagnostics ) ) { if ( m_aSchema . hasDiagnostics ( ) ) { final PSDiagnostics aDiagnostics = m_aSchema . getDiagnostics ( ) ; for ( final String sDiagnosticID : aSrcDiagnostics ) { final PSXPathBoundDiagnostic aDiagnostic = aBoundAssertReport . getBoundDiagnosticOfID ( sDiagnosticID ) ; if ( aDiagnostic == null ) _warn ( aDiagnostics , "Failed to resolve diagnostics with ID '" + sDiagnosticID + "'" ) ; else { // Create the SVRL diagnostic - reference element
final DiagnosticReference aDR = new DiagnosticReference ( ) ; aDR . setDiagnostic ( sDiagnosticID ) ; aDR . setText ( _getErrorText ( aDiagnostic . getAllBoundContentElements ( ) , aRuleMatchingNode ) ) ; aDstList . add ( aDR ) ; } } } else _warn ( m_aSchema , "Failed to resolve diagnostic because schema has no diagnostics" ) ; }


signature:
public class PSAssertReport { /** * Set the diagnostics , as an IDREFS value ( multiple IDREF values separated by
 * spaces )
 * @ param sDiagnostics
 * The value to be set . May be < code > null < / code > . */
public void setDiagnostics ( @ Nullable final String sDiagnostics ) { } }

implementation: if ( StringHelper . hasText ( sDiagnostics ) ) setDiagnostics ( RegExHelper . getSplitToList ( sDiagnostics . trim ( ) , "\\s+" ) ) ; else m_aDiagnostics = null ;


signature:
public class SVRLLocationBeautifierRegistry { /** * Get the beautified location for the given namespace and local name .
 * @ param sNamespaceURI
 * The namespace URI
 * @ param sLocalName
 * The element local name
 * @ return < code > null < / code > if no beautification is available */
@ Nullable public static String getBeautifiedLocation ( @ Nonnull final String sNamespaceURI , @ Nonnull final String sLocalName ) { } }

implementation: for ( final ISVRLLocationBeautifierSPI aBeautifier : s_aList ) { final String sBeautified = aBeautifier . getReplacementText ( sNamespaceURI , sLocalName ) ; if ( sBeautified != null ) return sBeautified ; } if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Unsupported elements for beautification: " + sNamespaceURI + " -- " + sLocalName ) ; return null ;


signature:
public class PSReader { /** * Utility method to get a real attribute value , by trimming spaces , if the
 * value is non - < code > null < / code > .
 * @ param sAttrValue
 * The source attribute value . May be < code > null < / code > .
 * @ return < code > null < / code > if the input parameter is < code > null < / code > . */
@ Nullable private static String _getAttributeValue ( @ Nullable final String sAttrValue ) { } }

implementation: return sAttrValue == null ? null : sAttrValue . trim ( ) ;


signature:
public class PSReader { /** * Emit a warning with the registered error handler .
 * @ param aSourceElement
 * The source element where the error occurred .
 * @ param sMessage
 * The main warning message . */
private void _warn ( @ Nonnull final IPSElement aSourceElement , @ Nonnull final String sMessage ) { } }

implementation: ValueEnforcer . notNull ( aSourceElement , "SourceElement" ) ; ValueEnforcer . notNull ( sMessage , "Message" ) ; m_aErrorHandler . warn ( m_aResource , aSourceElement , sMessage ) ;


signature:
public class PSReader { /** * Read an & lt ; active & gt ; element
 * @ param eActive
 * The source micro element . Never < code > null < / code > .
 * @ return The created domain object . May not be < code > null < / code > . */
@ Nonnull public PSActive readActiveFromXML ( @ Nonnull final IMicroElement eActive ) { } }

implementation:
final PSActive ret = new PSActive ( ) ; eActive . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; if ( sAttrName . equals ( CSchematronXML . ATTR_PATTERN ) ) ret . setPattern ( sAttrValue ) ; else ret . addForeignAttribute ( sAttrName , sAttrValue ) ; } ) ; eActive . forAllChildren ( aActiveChild -> { switch ( aActiveChild . getType ( ) ) { case TEXT : ret . addText ( ( ( IMicroText ) aActiveChild ) . getNodeValue ( ) ) ; break ; case ELEMENT : final IMicroElement eElement = ( IMicroElement ) aActiveChild ; if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( eElement . getNamespaceURI ( ) ) ) { final String sLocalName = eElement . getLocalName ( ) ; if ( sLocalName . equals ( CSchematronXML . ELEMENT_DIR ) ) ret . addDir ( readDirFromXML ( eElement ) ) ; else if ( sLocalName . equals ( CSchematronXML . ELEMENT_EMPH ) ) ret . addEmph ( readEmphFromXML ( eElement ) ) ; else if ( sLocalName . equals ( CSchematronXML . ELEMENT_SPAN ) ) ret . addSpan ( readSpanFromXML ( eElement ) ) ; else _warn ( ret , "Unsupported Schematron element '" + sLocalName + "'" ) ; } else ret . addForeignElement ( eElement . getClone ( ) ) ; break ; case COMMENT : // Ignore comments
break ; default : _warn ( ret , "Unsupported child node: " + aActiveChild ) ; } } ) ; return ret ;


signature:
public class PSReader { /** * Read an & lt ; assert & gt ; or a & lt ; report & gt ; element
 * @ param eAssertReport
 * The source micro element . Never < code > null < / code > .
 * @ return The created domain object . May not be < code > null < / code > . */
@ Nonnull public PSAssertReport readAssertReportFromXML ( @ Nonnull final IMicroElement eAssertReport ) { } }

implementation:
final PSAssertReport ret = new PSAssertReport ( eAssertReport . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_ASSERT ) ) ; final PSRichGroup aRichGroup = new PSRichGroup ( ) ; final PSLinkableGroup aLinkableGroup = new PSLinkableGroup ( ) ; eAssertReport . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; if ( sAttrName . equals ( CSchematronXML . ATTR_TEST ) ) ret . setTest ( sAttrValue ) ; else if ( sAttrName . equals ( CSchematronXML . ATTR_FLAG ) ) ret . setFlag ( sAttrValue ) ; else if ( sAttrName . equals ( CSchematronXML . ATTR_ID ) ) ret . setID ( sAttrValue ) ; else if ( sAttrName . equals ( CSchematronXML . ATTR_DIAGNOSTICS ) ) ret . setDiagnostics ( sAttrValue ) ; else if ( PSRichGroup . isRichAttribute ( sAttrName ) ) _handleRichGroup ( sAttrName , sAttrValue , aRichGroup ) ; else if ( PSLinkableGroup . isLinkableAttribute ( sAttrName ) ) _handleLinkableGroup ( sAttrName , sAttrValue , aLinkableGroup ) ; else ret . addForeignAttribute ( sAttrName , sAttrValue ) ; } ) ; ret . setRich ( aRichGroup ) ; ret . setLinkable ( aLinkableGroup ) ; eAssertReport . forAllChildren ( aAssertReportChild -> { switch ( aAssertReportChild . getType ( ) ) { case TEXT : ret . addText ( ( ( IMicroText ) aAssertReportChild ) . getNodeValue ( ) ) ; break ; case ELEMENT : final IMicroElement eElement = ( IMicroElement ) aAssertReportChild ; if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( eElement . getNamespaceURI ( ) ) ) { final String sLocalName = eElement . getLocalName ( ) ; if ( sLocalName . equals ( CSchematronXML . ELEMENT_NAME ) ) ret . addName ( readNameFromXML ( eElement ) ) ; else if ( sLocalName . equals ( CSchematronXML . ELEMENT_VALUE_OF ) ) ret . addValueOf ( readValueOfFromXML ( eElement ) ) ; else if ( sLocalName . equals ( CSchematronXML . ELEMENT_EMPH ) ) ret . addEmph ( readEmphFromXML ( eElement ) ) ; else if ( sLocalName . equals ( CSchematronXML . ELEMENT_DIR ) ) ret . addDir ( readDirFromXML ( eElement ) ) ; else if ( sLocalName . equals ( CSchematronXML . ELEMENT_SPAN ) ) ret . addSpan ( readSpanFromXML ( eElement ) ) ; else _warn ( ret , "Unsupported Schematron element '" + sLocalName + "'" ) ; } else ret . addForeignElement ( eElement . getClone ( ) ) ; break ; case COMMENT : // Ignore comments
break ; default : _warn ( ret , "Unsupported child node: " + aAssertReportChild ) ; } } ) ; return ret ;


signature:
public class PSReader { /** * Read a & lt ; diagnostic & gt ; element
 * @ param eDiagnostic
 * The source micro element . Never < code > null < / code > .
 * @ return The created domain object . May not be < code > null < / code > . */
@ Nonnull public PSDiagnostic readDiagnosticFromXML ( @ Nonnull final IMicroElement eDiagnostic ) { } }

implementation:
final PSDiagnostic ret = new PSDiagnostic ( ) ; final PSRichGroup aRichGroup = new PSRichGroup ( ) ; eDiagnostic . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; if ( sAttrName . equals ( CSchematronXML . ATTR_ID ) ) ret . setID ( sAttrValue ) ; else if ( PSRichGroup . isRichAttribute ( sAttrName ) ) _handleRichGroup ( sAttrName , sAttrValue , aRichGroup ) ; else ret . addForeignAttribute ( sAttrName , sAttrValue ) ; } ) ; ret . setRich ( aRichGroup ) ; eDiagnostic . forAllChildren ( aDiagnosticChild -> { switch ( aDiagnosticChild . getType ( ) ) { case TEXT : ret . addText ( ( ( IMicroText ) aDiagnosticChild ) . getNodeValue ( ) ) ; break ; case ELEMENT : final IMicroElement eElement = ( IMicroElement ) aDiagnosticChild ; if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( eElement . getNamespaceURI ( ) ) ) { final String sLocalName = eElement . getLocalName ( ) ; if ( sLocalName . equals ( CSchematronXML . ELEMENT_VALUE_OF ) ) ret . addValueOf ( readValueOfFromXML ( eElement ) ) ; else if ( sLocalName . equals ( CSchematronXML . ELEMENT_EMPH ) ) ret . addEmph ( readEmphFromXML ( eElement ) ) ; else if ( sLocalName . equals ( CSchematronXML . ELEMENT_DIR ) ) ret . addDir ( readDirFromXML ( eElement ) ) ; else if ( sLocalName . equals ( CSchematronXML . ELEMENT_SPAN ) ) ret . addSpan ( readSpanFromXML ( eElement ) ) ; else _warn ( ret , "Unsupported Schematron element '" + sLocalName + "'" ) ; } else ret . addForeignElement ( eElement . getClone ( ) ) ; break ; case COMMENT : // Ignore comments
break ; default : _warn ( ret , "Unsupported child node: " + aDiagnosticChild ) ; } } ) ; return ret ;


signature:
public class PSReader { /** * Read a & lt ; diagnostics & gt ; element
 * @ param eDiagnostics
 * The source micro element . Never < code > null < / code > .
 * @ return The created domain object . May not be < code > null < / code > . */
@ Nonnull public PSDiagnostics readDiagnosticsFromXML ( @ Nonnull final IMicroElement eDiagnostics ) { } }

implementation: final PSDiagnostics ret = new PSDiagnostics ( ) ; eDiagnostics . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; ret . addForeignAttribute ( sAttrName , sAttrValue ) ; } ) ; eDiagnostics . forAllChildElements ( eDiagnosticsChild -> { if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( eDiagnosticsChild . getNamespaceURI ( ) ) ) { if ( eDiagnosticsChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_INCLUDE ) ) ret . addInclude ( readIncludeFromXML ( eDiagnosticsChild ) ) ; else if ( eDiagnosticsChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_DIAGNOSTIC ) ) ret . addDiagnostic ( readDiagnosticFromXML ( eDiagnosticsChild ) ) ; else _warn ( ret , "Unsupported Schematron element '" + eDiagnosticsChild . getLocalName ( ) + "'" ) ; } else ret . addForeignElement ( eDiagnosticsChild . getClone ( ) ) ; } ) ; return ret ;


signature:
public class PSReader { /** * Read a & lt ; dir & gt ; element
 * @ param eDir
 * The source micro element . Never < code > null < / code > .
 * @ return The created domain object . May not be < code > null < / code > . */
@ Nonnull public PSDir readDirFromXML ( @ Nonnull final IMicroElement eDir ) { } }

implementation:
final PSDir ret = new PSDir ( ) ; eDir . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; if ( sAttrName . equals ( CSchematronXML . ATTR_VALUE ) ) ret . setValue ( EDirValue . getFromIDOrNull ( sAttrValue ) ) ; else ret . addForeignAttribute ( sAttrName , sAttrValue ) ; } ) ; eDir . forAllChildren ( aDirChild -> { switch ( aDirChild . getType ( ) ) { case TEXT : ret . addText ( ( ( IMicroText ) aDirChild ) . getNodeValue ( ) ) ; break ; case ELEMENT : final IMicroElement eElement = ( IMicroElement ) aDirChild ; if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( eElement . getNamespaceURI ( ) ) ) { _warn ( ret , "Unsupported Schematron element '" + eElement . getLocalName ( ) + "'" ) ; } else ret . addForeignElement ( eElement . getClone ( ) ) ; break ; case COMMENT : // Ignore comments
break ; default : _warn ( ret , "Unsupported child node: " + aDirChild ) ; } } ) ; return ret ;


signature:
public class PSReader { /** * Read an & lt ; emph & gt ; element
 * @ param eEmph
 * The source micro element . Never < code > null < / code > .
 * @ return The created domain object . May not be < code > null < / code > . */
@ Nonnull public PSEmph readEmphFromXML ( @ Nonnull final IMicroElement eEmph ) { } }

implementation:
final PSEmph ret = new PSEmph ( ) ; eEmph . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; _warn ( ret , "Unsupported attribute '" + sAttrName + "'='" + sAttrValue + "'" ) ; } ) ; eEmph . forAllChildren ( aEmphChild -> { switch ( aEmphChild . getType ( ) ) { case TEXT : ret . addText ( ( ( IMicroText ) aEmphChild ) . getNodeValue ( ) ) ; break ; case ELEMENT : final IMicroElement eElement = ( IMicroElement ) aEmphChild ; if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( eElement . getNamespaceURI ( ) ) ) { _warn ( ret , "Unsupported Schematron element '" + eElement . getLocalName ( ) + "'" ) ; } else _warn ( ret , "Unsupported namespace URI '" + eElement . getNamespaceURI ( ) + "'" ) ; break ; case COMMENT : // Ignore comments
break ; default : _warn ( ret , "Unsupported child node: " + aEmphChild ) ; } } ) ; return ret ;


signature:
public class PSReader { /** * Read an & lt ; extends & gt ; element
 * @ param eExtends
 * The source micro element . Never < code > null < / code > .
 * @ return The created domain object . May not be < code > null < / code > . */
@ Nonnull public PSExtends readExtendsFromXML ( @ Nonnull final IMicroElement eExtends ) { } }

implementation: final PSExtends ret = new PSExtends ( ) ; eExtends . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; if ( sAttrName . equals ( CSchematronXML . ATTR_RULE ) ) ret . setRule ( sAttrValue ) ; else ret . addForeignAttribute ( sAttrName , sAttrValue ) ; } ) ; eExtends . forAllChildElements ( eChild -> { if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( eChild . getNamespaceURI ( ) ) ) { _warn ( ret , "Unsupported Schematron element '" + eChild . getLocalName ( ) + "'" ) ; } else _warn ( ret , "Unsupported namespace URI '" + eChild . getNamespaceURI ( ) + "'" ) ; } ) ; return ret ;


signature:
public class PSReader { /** * Read an & lt ; include & gt ; element
 * @ param eInclude
 * The source micro element . Never < code > null < / code > .
 * @ return The created domain object . May not be < code > null < / code > . */
@ Nonnull public PSInclude readIncludeFromXML ( @ Nonnull final IMicroElement eInclude ) { } }

implementation: final PSInclude ret = new PSInclude ( ) ; eInclude . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; if ( sAttrName . equals ( CSchematronXML . ATTR_HREF ) ) ret . setHref ( sAttrValue ) ; else _warn ( ret , "Unsupported attribute '" + sAttrName + "'='" + sAttrValue + "'" ) ; } ) ; eInclude . forAllChildElements ( eValueOfChild -> { if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( eValueOfChild . getNamespaceURI ( ) ) ) { _warn ( ret , "Unsupported Schematron element '" + eValueOfChild . getLocalName ( ) + "'" ) ; } else _warn ( ret , "Unsupported namespace URI '" + eValueOfChild . getNamespaceURI ( ) + "'" ) ; } ) ; return ret ;


signature:
public class PSReader { /** * Read a & lt ; let & gt ; element
 * @ param eLet
 * The source micro element . Never < code > null < / code > .
 * @ return The created domain object . May not be < code > null < / code > . */
@ Nonnull public PSLet readLetFromXML ( @ Nonnull final IMicroElement eLet ) { } }

implementation: final PSLet ret = new PSLet ( ) ; eLet . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; if ( sAttrName . equals ( CSchematronXML . ATTR_NAME ) ) ret . setName ( sAttrValue ) ; else if ( sAttrName . equals ( CSchematronXML . ATTR_VALUE ) ) ret . setValue ( sAttrValue ) ; else _warn ( ret , "Unsupported attribute '" + sAttrName + "'='" + sAttrValue + "'" ) ; } ) ; eLet . forAllChildElements ( eLetChild -> { if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( eLetChild . getNamespaceURI ( ) ) ) { _warn ( ret , "Unsupported Schematron element '" + eLetChild . getLocalName ( ) + "'" ) ; } else _warn ( ret , "Unsupported namespace URI '" + eLetChild . getNamespaceURI ( ) + "'" ) ; } ) ; return ret ;


signature:
public class PSReader { /** * Read a & lt ; name & gt ; element
 * @ param eName
 * The source micro element . Never < code > null < / code > .
 * @ return The created domain object . May not be < code > null < / code > . */
@ Nonnull public PSName readNameFromXML ( @ Nonnull final IMicroElement eName ) { } }

implementation: final PSName ret = new PSName ( ) ; eName . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; if ( sAttrName . equals ( CSchematronXML . ATTR_PATH ) ) ret . setPath ( sAttrValue ) ; else ret . addForeignAttribute ( sAttrName , sAttrValue ) ; } ) ; eName . forAllChildElements ( eNameChild -> { if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( eNameChild . getNamespaceURI ( ) ) ) { _warn ( ret , "Unsupported Schematron element '" + eNameChild . getLocalName ( ) + "'" ) ; } else _warn ( ret , "Unsupported namespace URI '" + eNameChild . getNamespaceURI ( ) + "'" ) ; } ) ; return ret ;


signature:
public class PSReader { /** * Read a & lt ; ns & gt ; element
 * @ param eNS
 * The source micro element . Never < code > null < / code > .
 * @ return The created domain object . May not be < code > null < / code > . */
@ Nonnull public PSNS readNSFromXML ( @ Nonnull final IMicroElement eNS ) { } }

implementation: final PSNS ret = new PSNS ( ) ; eNS . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; if ( sAttrName . equals ( CSchematronXML . ATTR_URI ) ) ret . setUri ( sAttrValue ) ; else if ( sAttrName . equals ( CSchematronXML . ATTR_PREFIX ) ) ret . setPrefix ( sAttrValue ) ; else ret . addForeignAttribute ( sAttrName , sAttrValue ) ; } ) ; eNS . forAllChildElements ( eLetChild -> { if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( eLetChild . getNamespaceURI ( ) ) ) { _warn ( ret , "Unsupported Schematron element '" + eLetChild . getLocalName ( ) + "'" ) ; } else _warn ( ret , "Unsupported namespace URI '" + eLetChild . getNamespaceURI ( ) + "'" ) ; } ) ; return ret ;


signature:
public class PSReader { /** * Read a & lt ; p & gt ; element
 * @ param eP
 * The source micro element . Never < code > null < / code > .
 * @ return The created domain object . May not be < code > null < / code > . */
@ Nonnull public PSP readPFromXML ( @ Nonnull final IMicroElement eP ) { } }

implementation:
final PSP ret = new PSP ( ) ; eP . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; if ( sAttrName . equals ( CSchematronXML . ATTR_ID ) ) ret . setID ( sAttrValue ) ; else if ( sAttrName . equals ( CSchematronXML . ATTR_CLASS ) ) ret . setClazz ( sAttrValue ) ; else if ( sAttrName . equals ( CSchematronXML . ATTR_ICON ) ) ret . setIcon ( sAttrValue ) ; else ret . addForeignAttribute ( sAttrName , sAttrValue ) ; } ) ; eP . forAllChildren ( aChild -> { switch ( aChild . getType ( ) ) { case TEXT : ret . addText ( ( ( IMicroText ) aChild ) . getNodeValue ( ) ) ; break ; case ELEMENT : final IMicroElement eElement = ( IMicroElement ) aChild ; if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( eElement . getNamespaceURI ( ) ) ) { final String sLocalName = eElement . getLocalName ( ) ; if ( sLocalName . equals ( CSchematronXML . ELEMENT_DIR ) ) ret . addDir ( readDirFromXML ( eElement ) ) ; else if ( sLocalName . equals ( CSchematronXML . ELEMENT_EMPH ) ) ret . addEmph ( readEmphFromXML ( eElement ) ) ; else if ( sLocalName . equals ( CSchematronXML . ELEMENT_SPAN ) ) ret . addSpan ( readSpanFromXML ( eElement ) ) ; else _warn ( ret , "Unsupported Schematron element '" + sLocalName + "'" ) ; } else ret . addForeignElement ( eElement . getClone ( ) ) ; break ; case COMMENT : // Ignore comments
break ; default : _warn ( ret , "Unsupported child node: " + aChild ) ; } } ) ; return ret ;


signature:
public class PSReader { /** * Read a & lt ; param & gt ; element
 * @ param eParam
 * The source micro element . Never < code > null < / code > .
 * @ return The created domain object . May not be < code > null < / code > . */
@ Nonnull public PSParam readParamFromXML ( @ Nonnull final IMicroElement eParam ) { } }

implementation: final PSParam ret = new PSParam ( ) ; eParam . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; if ( sAttrName . equals ( CSchematronXML . ATTR_NAME ) ) ret . setName ( sAttrValue ) ; else if ( sAttrName . equals ( CSchematronXML . ATTR_VALUE ) ) ret . setValue ( sAttrValue ) ; else _warn ( ret , "Unsupported attribute '" + sAttrName + "'='" + sAttrValue + "'" ) ; } ) ; eParam . forAllChildElements ( eParamChild -> { if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( eParamChild . getNamespaceURI ( ) ) ) { _warn ( ret , "Unsupported Schematron element '" + eParamChild . getLocalName ( ) + "'" ) ; } else _warn ( ret , "Unsupported namespace URI '" + eParamChild . getNamespaceURI ( ) + "'" ) ; } ) ; return ret ;


signature:
public class PSReader { /** * Read a & lt ; pattern & gt ; element
 * @ param ePattern
 * The source micro element . Never < code > null < / code > .
 * @ return The created domain object . May not be < code > null < / code > . */
@ Nonnull public PSPattern readPatternFromXML ( @ Nonnull final IMicroElement ePattern ) { } }

implementation: final PSPattern ret = new PSPattern ( ) ; final PSRichGroup aRichGroup = new PSRichGroup ( ) ; ePattern . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; if ( sAttrName . equals ( CSchematronXML . ATTR_ABSTRACT ) ) ret . setAbstract ( StringParser . parseBool ( sAttrValue ) ) ; else if ( sAttrName . equals ( CSchematronXML . ATTR_ID ) ) ret . setID ( sAttrValue ) ; else if ( sAttrName . equals ( CSchematronXML . ATTR_IS_A ) ) ret . setIsA ( sAttrValue ) ; else if ( PSRichGroup . isRichAttribute ( sAttrName ) ) _handleRichGroup ( sAttrName , sAttrValue , aRichGroup ) ; else ret . addForeignAttribute ( sAttrName , sAttrValue ) ; } ) ; ret . setRich ( aRichGroup ) ; ePattern . forAllChildElements ( ePatternChild -> { if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( ePatternChild . getNamespaceURI ( ) ) ) { if ( ePatternChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_INCLUDE ) ) ret . addInclude ( readIncludeFromXML ( ePatternChild ) ) ; else if ( ePatternChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_TITLE ) ) ret . setTitle ( readTitleFromXML ( ePatternChild ) ) ; else if ( ePatternChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_P ) ) ret . addP ( readPFromXML ( ePatternChild ) ) ; else if ( ePatternChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_LET ) ) ret . addLet ( readLetFromXML ( ePatternChild ) ) ; else if ( ePatternChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_RULE ) ) ret . addRule ( readRuleFromXML ( ePatternChild ) ) ; else if ( ePatternChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_PARAM ) ) ret . addParam ( readParamFromXML ( ePatternChild ) ) ; else _warn ( ret , "Unsupported Schematron element '" + ePatternChild . getLocalName ( ) + "' in " + ret . toString ( ) ) ; } else ret . addForeignElement ( ePatternChild . getClone ( ) ) ; } ) ; return ret ;


signature:
public class PSReader { /** * Read a & lt ; phase & gt ; element
 * @ param ePhase
 * The source micro element . Never < code > null < / code > .
 * @ return The created domain object . May not be < code > null < / code > . */
@ Nonnull public PSPhase readPhaseFromXML ( @ Nonnull final IMicroElement ePhase ) { } }

implementation: final PSPhase ret = new PSPhase ( ) ; final PSRichGroup aRichGroup = new PSRichGroup ( ) ; ePhase . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; if ( sAttrName . equals ( CSchematronXML . ATTR_ID ) ) ret . setID ( sAttrValue ) ; else if ( PSRichGroup . isRichAttribute ( sAttrName ) ) _handleRichGroup ( sAttrName , sAttrValue , aRichGroup ) ; else ret . addForeignAttribute ( sAttrName , sAttrValue ) ; } ) ; ret . setRich ( aRichGroup ) ; ePhase . forAllChildElements ( ePhaseChild -> { if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( ePhaseChild . getNamespaceURI ( ) ) ) { if ( ePhaseChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_INCLUDE ) ) ret . addInclude ( readIncludeFromXML ( ePhaseChild ) ) ; else if ( ePhaseChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_P ) ) ret . addP ( readPFromXML ( ePhaseChild ) ) ; else if ( ePhaseChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_LET ) ) ret . addLet ( readLetFromXML ( ePhaseChild ) ) ; else if ( ePhaseChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_ACTIVE ) ) ret . addActive ( readActiveFromXML ( ePhaseChild ) ) ; else _warn ( ret , "Unsupported Schematron element '" + ePhaseChild . getLocalName ( ) + "'" ) ; } else ret . addForeignElement ( ePhaseChild . getClone ( ) ) ; } ) ; return ret ;


signature:
public class PSReader { /** * Read a & lt ; rule & gt ; element
 * @ param eRule
 * The source micro element . Never < code > null < / code > .
 * @ return The created domain object . May not be < code > null < / code > . */
@ Nonnull public PSRule readRuleFromXML ( @ Nonnull final IMicroElement eRule ) { } }

implementation: final PSRule ret = new PSRule ( ) ; final PSRichGroup aRichGroup = new PSRichGroup ( ) ; final PSLinkableGroup aLinkableGroup = new PSLinkableGroup ( ) ; eRule . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; if ( sAttrName . equals ( CSchematronXML . ATTR_FLAG ) ) ret . setFlag ( sAttrValue ) ; else if ( sAttrName . equals ( CSchematronXML . ATTR_ABSTRACT ) ) ret . setAbstract ( StringParser . parseBool ( sAttrValue ) ) ; else if ( sAttrName . equals ( CSchematronXML . ATTR_CONTEXT ) ) ret . setContext ( sAttrValue ) ; else if ( sAttrName . equals ( CSchematronXML . ATTR_ID ) ) ret . setID ( sAttrValue ) ; else if ( PSRichGroup . isRichAttribute ( sAttrName ) ) _handleRichGroup ( sAttrName , sAttrValue , aRichGroup ) ; else if ( PSLinkableGroup . isLinkableAttribute ( sAttrName ) ) _handleLinkableGroup ( sAttrName , sAttrValue , aLinkableGroup ) ; else ret . addForeignAttribute ( sAttrName , sAttrValue ) ; } ) ; ret . setRich ( aRichGroup ) ; ret . setLinkable ( aLinkableGroup ) ; eRule . forAllChildElements ( eRuleChild -> { if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( eRuleChild . getNamespaceURI ( ) ) ) { final String sLocalName = eRuleChild . getLocalName ( ) ; if ( sLocalName . equals ( CSchematronXML . ELEMENT_INCLUDE ) ) ret . addInclude ( readIncludeFromXML ( eRuleChild ) ) ; else if ( sLocalName . equals ( CSchematronXML . ELEMENT_LET ) ) ret . addLet ( readLetFromXML ( eRuleChild ) ) ; else if ( sLocalName . equals ( CSchematronXML . ELEMENT_ASSERT ) || sLocalName . equals ( CSchematronXML . ELEMENT_REPORT ) ) ret . addAssertReport ( readAssertReportFromXML ( eRuleChild ) ) ; else if ( sLocalName . equals ( CSchematronXML . ELEMENT_EXTENDS ) ) ret . addExtends ( readExtendsFromXML ( eRuleChild ) ) ; else _warn ( ret , "Unsupported Schematron element '" + sLocalName + "'" ) ; } else ret . addForeignElement ( eRuleChild . getClone ( ) ) ; } ) ; return ret ;


signature:
public class PSReader { /** * Parse the Schematron into a pure Java object . This method makes no
 * assumptions on the validity of the document !
 * @ param eSchema
 * The XML element to use . May not be < code > null < / code > .
 * @ return The created { @ link PSSchema } object or < code > null < / code > in case of
 * < code > null < / code > document or a fatal error .
 * @ throws SchematronReadException
 * If reading fails */
@ Nonnull public PSSchema readSchemaFromXML ( @ Nonnull final IMicroElement eSchema ) throws SchematronReadException { } }

implementation: ValueEnforcer . notNull ( eSchema , "Schema" ) ; if ( ! CSchematron . NAMESPACE_SCHEMATRON . equals ( eSchema . getNamespaceURI ( ) ) ) throw new SchematronReadException ( m_aResource , "The passed element is not an ISO Schematron element!" ) ; final PSSchema ret = new PSSchema ( m_aResource ) ; final PSRichGroup aRichGroup = new PSRichGroup ( ) ; eSchema . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; if ( sAttrName . equals ( CSchematronXML . ATTR_ID ) ) ret . setID ( sAttrValue ) ; else if ( sAttrName . equals ( CSchematronXML . ATTR_SCHEMA_VERSION ) ) ret . setSchemaVersion ( sAttrValue ) ; else if ( sAttrName . equals ( CSchematronXML . ATTR_DEFAULT_PHASE ) ) ret . setDefaultPhase ( sAttrValue ) ; else if ( sAttrName . equals ( CSchematronXML . ATTR_QUERY_BINDING ) ) ret . setQueryBinding ( sAttrValue ) ; else if ( PSRichGroup . isRichAttribute ( sAttrName ) ) _handleRichGroup ( sAttrName , sAttrValue , aRichGroup ) ; else ret . addForeignAttribute ( sAttrName , sAttrValue ) ; } ) ; ret . setRich ( aRichGroup ) ; eSchema . forAllChildElements ( eSchemaChild -> { if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( eSchemaChild . getNamespaceURI ( ) ) ) { if ( eSchemaChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_INCLUDE ) ) ret . addInclude ( readIncludeFromXML ( eSchemaChild ) ) ; else if ( eSchemaChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_TITLE ) ) ret . setTitle ( readTitleFromXML ( eSchemaChild ) ) ; else if ( eSchemaChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_NS ) ) ret . addNS ( readNSFromXML ( eSchemaChild ) ) ; else if ( eSchemaChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_P ) ) { final PSP aP = readPFromXML ( eSchemaChild ) ; if ( ret . hasNoPatterns ( ) ) ret . addStartP ( aP ) ; else ret . addEndP ( aP ) ; } else if ( eSchemaChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_LET ) ) ret . addLet ( readLetFromXML ( eSchemaChild ) ) ; else if ( eSchemaChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_PHASE ) ) ret . addPhase ( readPhaseFromXML ( eSchemaChild ) ) ; else if ( eSchemaChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_PATTERN ) ) ret . addPattern ( readPatternFromXML ( eSchemaChild ) ) ; else if ( eSchemaChild . getLocalName ( ) . equals ( CSchematronXML . ELEMENT_DIAGNOSTICS ) ) ret . setDiagnostics ( readDiagnosticsFromXML ( eSchemaChild ) ) ; else _warn ( ret , "Unsupported Schematron element '" + eSchemaChild . getLocalName ( ) + "'" ) ; } else ret . addForeignElement ( eSchemaChild . getClone ( ) ) ; } ) ; return ret ;


signature:
public class PSReader { /** * Read a & lt ; span & gt ; element
 * @ param eSpan
 * The source micro element . Never < code > null < / code > .
 * @ return The created domain object . May not be < code > null < / code > . */
@ Nonnull public PSSpan readSpanFromXML ( @ Nonnull final IMicroElement eSpan ) { } }

implementation:
final PSSpan ret = new PSSpan ( ) ; eSpan . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; if ( sAttrName . equals ( CSchematronXML . ATTR_CLASS ) ) ret . setClazz ( sAttrValue ) ; else ret . addForeignAttribute ( sAttrName , sAttrValue ) ; } ) ; eSpan . forAllChildren ( aSpanChild -> { switch ( aSpanChild . getType ( ) ) { case TEXT : ret . addText ( ( ( IMicroText ) aSpanChild ) . getNodeValue ( ) ) ; break ; case ELEMENT : final IMicroElement eElement = ( IMicroElement ) aSpanChild ; if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( eElement . getNamespaceURI ( ) ) ) { _warn ( ret , "Unsupported Schematron element '" + eElement . getLocalName ( ) + "'" ) ; } else ret . addForeignElement ( eElement . getClone ( ) ) ; break ; case COMMENT : // Ignore comments
break ; default : _warn ( ret , "Unsupported child node: " + aSpanChild ) ; } } ) ; return ret ;


signature:
public class PSReader { /** * Read a & lt ; title & gt ; element
 * @ param eTitle
 * The source micro element . Never < code > null < / code > .
 * @ return The created domain object . May not be < code > null < / code > . */
@ Nonnull public PSTitle readTitleFromXML ( @ Nonnull final IMicroElement eTitle ) { } }

implementation:
final PSTitle ret = new PSTitle ( ) ; eTitle . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; _warn ( ret , "Unsupported attribute '" + sAttrName + "'='" + sAttrValue + "'" ) ; } ) ; eTitle . forAllChildren ( aTitleChild -> { switch ( aTitleChild . getType ( ) ) { case TEXT : ret . addText ( ( ( IMicroText ) aTitleChild ) . getNodeValue ( ) ) ; break ; case ELEMENT : final IMicroElement eElement = ( IMicroElement ) aTitleChild ; if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( eElement . getNamespaceURI ( ) ) ) { final String sLocalName = eElement . getLocalName ( ) ; if ( sLocalName . equals ( CSchematronXML . ELEMENT_DIR ) ) ret . addDir ( readDirFromXML ( eElement ) ) ; else _warn ( ret , "Unsupported Schematron element '" + sLocalName + "'" ) ; } else _warn ( ret , "Unsupported namespace URI '" + eElement . getNamespaceURI ( ) + "'" ) ; break ; case COMMENT : // Ignore comments
break ; default : _warn ( ret , "Unsupported child node: " + aTitleChild ) ; } } ) ; return ret ;


signature:
public class PSReader { /** * Read a & lt ; value - of & gt ; element
 * @ param eValueOf
 * The source micro element . Never < code > null < / code > .
 * @ return The created domain object . May not be < code > null < / code > . */
@ Nonnull public PSValueOf readValueOfFromXML ( @ Nonnull final IMicroElement eValueOf ) { } }

implementation: final PSValueOf ret = new PSValueOf ( ) ; eValueOf . forAllAttributes ( ( sNS , sAttrName , sVal ) -> { final String sAttrValue = _getAttributeValue ( sVal ) ; if ( sAttrName . equals ( CSchematronXML . ATTR_SELECT ) ) ret . setSelect ( sAttrValue ) ; else ret . addForeignAttribute ( sAttrName , sAttrValue ) ; } ) ; eValueOf . forAllChildElements ( eValueOfChild -> { if ( CSchematron . NAMESPACE_SCHEMATRON . equals ( eValueOfChild . getNamespaceURI ( ) ) ) { _warn ( ret , "Unsupported Schematron element '" + eValueOfChild . getLocalName ( ) + "'" ) ; } else _warn ( ret , "Unsupported namespace URI '" + eValueOfChild . getNamespaceURI ( ) + "'" ) ; } ) ; return ret ;


signature:
public class PSReader { /** * Read the schema from the resource supplied in the constructor . First all
 * includes are resolved and than { @ link # readSchemaFromXML ( IMicroElement ) } is
 * called .
 * @ return The read { @ link PSSchema } .
 * @ throws SchematronReadException
 * If reading fails */
@ Nonnull public PSSchema readSchema ( ) throws SchematronReadException { } }

implementation:
// Resolve all includes as the first action
final SAXReaderSettings aSettings = new SAXReaderSettings ( ) . setEntityResolver ( m_aEntityResolver ) ; final IMicroDocument aDoc = SchematronHelper . getWithResolvedSchematronIncludes ( m_aResource , aSettings , m_aErrorHandler ) ; if ( aDoc == null || aDoc . getDocumentElement ( ) == null ) throw new SchematronReadException ( m_aResource , "Failed to resolve includes in Schematron resource " + m_aResource ) ; if ( SchematronDebug . isShowResolvedSourceSchematron ( ) ) LOGGER . info ( "Resolved source Schematron:\n" + MicroWriter . getNodeAsString ( aDoc ) ) ; return readSchemaFromXML ( aDoc . getDocumentElement ( ) ) ;


signature:
public class SchematronTransformerFactory { /** * Create a new { @ link TransformerFactory } trying to invoke the Saxon
 * implementation first using the class
 * { @ value # SAXON _ TRANSFORMER _ FACTORY _ CLASS } .
 * @ param aClassLoader
 * The optional class loader to be used . May be < code > null < / code > .
 * @ param aErrorListener
 * An optional XSLT error listener to be used . May be
 * < code > null < / code > .
 * @ param aURIResolver
 * An optional XSLT URI resolver to be used . May be < code > null < / code > .
 * @ return A new { @ link TransformerFactory } and not < code > null < / code > .
 * @ throws InitializationException
 * In case initialization fails . */
@ Nonnull public static TransformerFactory createTransformerFactorySaxonFirst ( @ Nullable final ClassLoader aClassLoader , @ Nullable final ErrorListener aErrorListener , @ Nullable final URIResolver aURIResolver ) { } }

implementation:
TransformerFactory aFactory ; try { // Try Saxon first
final ClassLoader aEffectiveClassLoader = aClassLoader != null ? aClassLoader : ClassLoaderHelper . getContextClassLoader ( ) ; aFactory = TransformerFactory . newInstance ( SAXON_TRANSFORMER_FACTORY_CLASS , aEffectiveClassLoader ) ; // Debug / testing only
if ( false ) aFactory . setFeature ( FeatureKeys . TRACE_OPTIMIZER_DECISIONS , true ) ; if ( false ) aFactory . setFeature ( FeatureKeys . COMPILE_WITH_TRACING , true ) ; if ( false ) aFactory . setAttribute ( FeatureKeys . XSLT_VERSION , "2.0" ) ; } catch ( final TransformerFactoryConfigurationError | TransformerConfigurationException ex ) { try { // Try default afterwards
aFactory = TransformerFactory . newInstance ( ) ; } catch ( final TransformerFactoryConfigurationError ex2 ) { throw new InitializationException ( "Failed to create XML TransformerFactory" , ex2 ) ; } } if ( aErrorListener != null ) aFactory . setErrorListener ( aErrorListener ) ; if ( aURIResolver != null ) aFactory . setURIResolver ( aURIResolver ) ; return aFactory ;


signature:
public class PSWriterSettings { /** * Helper method to extract the namespace mapping from the provided
 * Schematron .
 * @ param aSchema
 * The schema to extract the namespace context from . May not be
 * < code > null < / code > .
 * @ return A non - < code > null < / code > but maybe empty namespace context */
@ Nonnull @ ReturnsMutableCopy public static MapBasedNamespaceContext createNamespaceMapping ( @ Nonnull final PSSchema aSchema ) { } }

implementation: final MapBasedNamespaceContext ret = new MapBasedNamespaceContext ( ) ; ret . addDefaultNamespaceURI ( CSchematron . NAMESPACE_SCHEMATRON ) ; for ( final PSNS aItem : aSchema . getAllNSs ( ) ) ret . addMapping ( aItem . getPrefix ( ) , aItem . getUri ( ) ) ; return ret ;


signature:
public class ConstraintLogic { /** * Checks access to the resource based on the regex
 * @ param requestHeader the HTTP request header
 * @ param deadboltHandler the Deadbolt handler
 * @ param invert if true , invert the application of the constraint
 * @ return the necessary result */
private < T > CompletionStage < T > regex ( final Http . RequestHeader requestHeader , final DeadboltHandler deadboltHandler , final Optional < String > content , final String [ ] values , final int valueIndex , final ConstraintMode mode , final boolean invert , final Function < Http . RequestHeader , CompletionStage < T > > pass , final TriFunction < Http . RequestHeader , DeadboltHandler , Optional < String > , CompletionStage < T > > fail , final ConstraintPoint constraintPoint ) { } }

implementation:
return CompletableFuture . completedFuture ( patternCache . apply ( values [ valueIndex ] ) ) . thenCombine ( getSubject ( requestHeader , deadboltHandler ) , ( patternValue , subject ) -> F . Tuple ( subject . _1 . isPresent ( ) ? analyzer . checkRegexPattern ( subject . _1 , Optional . ofNullable ( patternValue ) ) : invert , subject . _2 ) ) // this is a little clumsy - it means no subject + invert is still denied
. thenCompose ( hasPassed -> ( invert ? ! hasPassed . _1 : hasPassed . _1 ) ? ( successCallAgain ( mode , values , valueIndex ) ? regex ( hasPassed . _2 , deadboltHandler , content , values , valueIndex + 1 , mode , invert , pass , fail , constraintPoint ) : pass ( hasPassed . _2 , deadboltHandler , pass , constraintPoint , "pattern - regex" ) ) : ( failCallAgain ( mode , values , valueIndex ) ? regex ( hasPassed . _2 , deadboltHandler , content , values , valueIndex + 1 , mode , invert , pass , fail , constraintPoint ) : fail . apply ( hasPassed . _2 , deadboltHandler , content ) ) ) ;


signature:
public class AbstractDeadboltAction { /** * Gets the current { @ link DeadboltHandler } . This can come from one of two places :
 * - a handler key is provided in the annotation . A cached instance of that class will be used . This has the highest priority .
 * - the global handler defined in the application . conf by deadbolt . handler . This has the lowest priority .
 * @ param handlerKey the DeadboltHandler key , if any , coming from the annotation .
 * @ param < C > the actual class of the DeadboltHandler
 * @ return an option for the DeadboltHandler . */
protected < C extends DeadboltHandler > DeadboltHandler getDeadboltHandler ( final String handlerKey ) { } }

implementation: LOGGER . debug ( "Getting Deadbolt handler with key [{}]" , handlerKey ) ; return handlerKey == null || Constants . DEFAULT_HANDLER_KEY . equals ( handlerKey ) ? handlerCache . get ( ) : handlerCache . apply ( handlerKey ) ;


signature:
public class AbstractDeadboltAction { /** * Wrapper for { @ link DeadboltHandler # onAuthFailure } to ensure the access failure is logged .
 * @ param deadboltHandler the Deadbolt handler
 * @ param content the content type hint
 * @ param request the request
 * @ return the result of { @ link DeadboltHandler # onAuthFailure } */
protected CompletionStage < Result > onAuthFailure ( final DeadboltHandler deadboltHandler , final Optional < String > content , final Http . RequestHeader request ) { } }

implementation: LOGGER . info ( "Deadbolt: Access failure on [{}]" , request . uri ( ) ) ; CompletionStage < Result > result ; try { result = deadboltHandler . onAuthFailure ( request , content ) ; } catch ( Exception e ) { LOGGER . warn ( "Deadbolt: Exception when invoking onAuthFailure" , e ) ; result = CompletableFuture . completedFuture ( Results . internalServerError ( ) ) ; } return result ;


signature:
public class AbstractDeadboltAction { /** * Marks the current action as authorised . This allows method - level annotations to override controller - level annotations .
 * @ param request the request */
private Http . RequestHeader markAsAuthorised ( final Http . RequestHeader request ) { } }

implementation: this . authorised = true ; return request . addAttr ( ACTION_AUTHORISED , true ) ;


signature:
public class AbstractDeadboltAction { /** * Checks if an action is authorised . This allows controller - level annotations to cede control to method - level annotations .
 * @ param request the request
 * @ return true if a more - specific annotation has authorised access , otherwise false */
protected static boolean isAuthorised ( final Http . RequestHeader request ) { } }

implementation: return request . attrs ( ) . getOptional ( ACTION_AUTHORISED ) . orElse ( false ) ;


signature:
public class AbstractDeadboltAction { /** * Defer execution until a later point .
 * @ param request the request
 * @ param action the action to defer */
protected Http . RequestHeader defer ( final Http . RequestHeader request , final AbstractDeadboltAction < T > action ) { } }

implementation: if ( action != null ) { LOGGER . info ( "Deferring action [{}]" , this . getClass ( ) . getName ( ) ) ; return request . addAttr ( ACTION_DEFERRED , action ) ; } return request ;


signature:
public class AbstractDeadboltAction { /** * Get the deferred action from the request .
 * @ param request the request
 * @ return a tuple containing the deferred action ( or null if it doesn ' t exist ) and the cleaned up request you should pass on */
@ SuppressWarnings ( "unchecked" ) public F . Tuple < AbstractDeadboltAction < ? > , Http . RequestHeader > getDeferredAction ( final Http . RequestHeader request ) { } }

implementation: return request . attrs ( ) . getOptional ( ACTION_DEFERRED ) . map ( action -> { action . delegate = this ; return F . < AbstractDeadboltAction < ? > , Http . RequestHeader > Tuple ( action , request . removeAttr ( ACTION_DEFERRED ) . addAttr ( IGNORE_DEFERRED_FLAG , true ) ) ; } ) . orElseGet ( ( ) -> F . Tuple ( null , request ) ) ;


signature:
public class AbstractDeadboltAction { /** * Add a flag to the request to indicate the action has passed the constraint
 * and call the delegate .
 * @ param request the request
 * @ return the result */
protected CompletionStage < Result > authorizeAndExecute ( final Http . RequestHeader request ) { } }

implementation:
if ( constraintAnnotationMode != ConstraintAnnotationMode . AND ) { // In AND mode we don ' t mark an action as authorised because we want ALL ( remaining ) constraints to be evaluated as well !
return delegate . call ( ( Http . Request ) markAsAuthorised ( request ) ) ; } return delegate . call ( ( Http . Request ) request ) ;


signature:
public class AbstractDeadboltAction { /** * Add a flag to the request to indicate the action has been blocked by the
 * constraint and call { @ link DeadboltHandler # onAuthFailure ( Http . RequestHeader , Optional < String > ) } .
 * @ param request the request
 * @ param handler the relevant handler
 * @ param content the content type
 * @ return the result */
protected CompletionStage < Result > unauthorizeAndFail ( final Http . RequestHeader request , final DeadboltHandler handler , final Optional < String > content ) { } }

implementation:
if ( constraintAnnotationMode == ConstraintAnnotationMode . OR && deadboltActionLeftInActionChain ( this ) ) { // In OR mode we don ' t fail immediately but also check remaining constraints ( it there is any left ) . Maybe one of these next ones authorizes . . .
return delegate . call ( ( Http . Request ) request ) ; } return onAuthFailure ( handler , content , request ) ;


signature:
public class AbstractDeadboltAction { /** * Recursive method to determine if there is another deadbolt action further down the action chain */
private static boolean deadboltActionLeftInActionChain ( final Action < ? > action ) { } }

implementation:
if ( action != null ) { if ( action . delegate instanceof AbstractDeadboltAction ) { return true ; // yes , there is at least one deadbolt action remaining
} // action . delegate wasn ' t a deadbolt action , let ' s check the next one in the chain
return deadboltActionLeftInActionChain ( action . delegate ) ; } return false ;


signature:
public class AbstractDeadboltAction { /** * Be aware : Not every deadbolt - annotation is a constraint , but every constraint is a deadbolt - annotation ; )
 * @ BeforeAccess and @ DeferredDeadboltAction do NOT count as constraint , because they just pass trough ( = they do NOT call markAsAuthorised ( ) in success case ) */
private static boolean isConstraintInActionChain ( final Action < ? > action , final Function < Action < ? > , Action < ? > > nextAction ) { } }

implementation:
if ( action != null ) { if ( action instanceof AbstractDeadboltAction && ! ( action instanceof BeforeAccessAction ) && ! ( action instanceof DeferredDeadboltAction ) ) { return true ; } // that wasn ' t a deadbolt constraint , let ' s go and check the next action in the chain
return isConstraintInActionChain ( nextAction . apply ( action ) , nextAction ) ; } return false ;


signature:
public class DeadboltRoutePathFilter { /** * If a constraint is defined for a given route , test that constraint before allowing the request to proceed .
 * @ param next the next step in the filter chain
 * @ param requestHeader the request header
 * @ return a future for the result */
@ Override public CompletionStage < Result > apply ( final Function < Http . RequestHeader , CompletionStage < Result > > next , final Http . RequestHeader requestHeader ) { } }

implementation: final Optional < AuthorizedRoute > maybeAuthRoute = authorizedRoutes . apply ( requestHeader . method ( ) , requestHeader . attrs ( ) . get ( Router . Attrs . HANDLER_DEF ) . path ( ) ) ; return maybeAuthRoute . map ( authRoute -> authRoute . constraint ( ) . apply ( requestHeader , authRoute . handler ( ) . orElse ( handler ) , next ) ) . orElseGet ( ( ) -> next . apply ( requestHeader ) ) ;


signature:
public class DeadboltAnalyzer { /** * Gets the role name of each role held .
 * @ param subjectOption an option for the subject
 * @ return a non - null list containing all role names */
public List < String > getRoleNames ( final Optional < ? extends Subject > subjectOption ) { } }

implementation: final List < String > roleNames = new ArrayList < > ( ) ; subjectOption . ifPresent ( subject -> { final List < ? extends Role > roles = subject . getRoles ( ) ; if ( roles != null ) { roleNames . addAll ( roles . stream ( ) . filter ( Objects :: nonNull ) . map ( Role :: getName ) . collect ( Collectors . toList ( ) ) ) ; } } ) ; return roleNames ;


signature:
public class DeadboltAnalyzer { /** * Check if the subject has the given role .
 * @ param subjectOption an option for the subject
 * @ param roleName the name of the role
 * @ return true iff the subject has the role represented by the role name */
public boolean hasRole ( final Optional < ? extends Subject > subjectOption , final String roleName ) { } }

implementation: return getRoleNames ( subjectOption ) . contains ( roleName ) ;


signature:
public class DeadboltAnalyzer { /** * Check if the { @ link Subject } has all the roles given in the roleNames array . Note that while a Subject must
 * have all the roles , it may also have other roles .
 * @ param subjectOption an option for the subject
 * @ param roleNames the names of the required roles
 * @ return true iff the subject has all the roles */
public boolean hasAllRoles ( final Optional < ? extends Subject > subjectOption , final String [ ] roleNames ) { } }

implementation: final List < String > heldRoles = getRoleNames ( subjectOption ) ; boolean roleCheckResult = roleNames != null && roleNames . length > 0 ; for ( int i = 0 ; roleCheckResult && i < roleNames . length ; i ++ ) { boolean invert = false ; String roleName = roleNames [ i ] ; if ( roleName . startsWith ( "!" ) ) { invert = true ; roleName = roleName . substring ( 1 ) ; } roleCheckResult = heldRoles . contains ( roleName ) ; if ( invert ) { roleCheckResult = ! roleCheckResult ; } } return roleCheckResult ;


signature:
public class DeadboltRouteModifierTagsFilter { /** * If a constraint is defined for a given route , test that constraint before allowing the request to proceed .
 * @ param next the next step in the filter chain
 * @ param requestHeader the request header
 * @ return a future for the result */
@ Override public CompletionStage < Result > apply ( final Function < Http . RequestHeader , CompletionStage < Result > > next , final Http . RequestHeader requestHeader ) { } }

implementation: final HandlerDef handlerDef = requestHeader . attrs ( ) . get ( Router . Attrs . HANDLER_DEF ) ; final List < String > deadboltModifierTags = handlerDef . getModifiers ( ) . stream ( ) . filter ( mt -> mt != null && mt . startsWith ( "deadbolt:" ) ) . collect ( Collectors . toList ( ) ) ; return processModifierTags ( deadboltModifierTags , 0 , requestHeader , next ) ;


signature:
public class FilterConstraints { /** * A constraint that requires a subject to be present .
 * @ param content is passed to { @ link DeadboltHandler # onAuthFailure ( Http . RequestHeader , Optional ) } if the authorization fails
 * @ return a function that wraps the constraint
 * @ see ConstraintLogic # subjectPresent ( Http . RequestHeader , DeadboltHandler , Optional , TriFunction , TriFunction , ConstraintPoint ) */
public FilterFunction subjectPresent ( final Optional < String > content ) { } }

implementation: return ( Http . RequestHeader requestHeader , DeadboltHandler handler , Function < Http . RequestHeader , CompletionStage < Result > > next ) -> beforeAuthCheckCache . apply ( handler , requestHeader , content ) . thenCompose ( maybePreAuth -> maybePreAuth . _1 . map ( preAuthResult -> ( CompletionStage < Result > ) CompletableFuture . completedFuture ( preAuthResult ) ) . orElseGet ( ( ) -> constraintLogic . subjectPresent ( maybePreAuth . _2 , handler , content , ( rh , hdlr , cntent ) -> next . apply ( rh ) , ( rh , hdlr , cntent ) -> hdlr . onAuthFailure ( rh , cntent ) , ConstraintPoint . FILTER ) ) ) ;


signature:
public class FilterConstraints { /** * A constraint that checks the permissions of a subject ( if using { @ link PatternType # EQUALITY } or { @ link PatternType # REGEX } ) or
 * { @ link be . objectify . deadbolt . java . DynamicResourceHandler # checkPermission ( String , Optional , DeadboltHandler , Http . RequestHeader ) } ( if
 * using { @ link PatternType # CUSTOM } ) .
 * @ param value the constraint value
 * @ param patternType the type of pattern matching
 * @ return a function that wraps the constraint
 * @ see ConstraintLogic # pattern ( Http . RequestHeader , DeadboltHandler , Optional , String , PatternType , Optional , boolean , Function , TriFunction , ConstraintPoint ) */
public FilterFunction pattern ( final String value , final PatternType patternType ) { } }

implementation: return pattern ( value , patternType , Optional . empty ( ) ) ;


signature:
public class FilterConstraints { /** * A constraint that checks the permissions of a subject ( if using { @ link PatternType # EQUALITY } or { @ link PatternType # REGEX } ) or
 * { @ link be . objectify . deadbolt . java . DynamicResourceHandler # checkPermission ( String , Optional , DeadboltHandler , Http . RequestHeader ) } ( if
 * using { @ link PatternType # CUSTOM } ) .
 * @ param value the constraint value
 * @ param patternType the type of pattern matching
 * @ param meta additional information passed to { @ link be . objectify . deadbolt . java . DynamicResourceHandler # checkPermission ( String , Optional , DeadboltHandler , Http . RequestHeader ) }
 * @ return a function that wraps the constraint
 * @ see ConstraintLogic # pattern ( Http . RequestHeader , DeadboltHandler , Optional , String , PatternType , Optional , boolean , Function , TriFunction , ConstraintPoint ) */
public FilterFunction pattern ( final String value , final PatternType patternType , final Optional < String > meta ) { } }

implementation: return pattern ( value , patternType , meta , false , Optional . empty ( ) ) ;


signature:
public class FilterConstraints { /** * An arbitrary constraint that uses { @ link be . objectify . deadbolt . java . DynamicResourceHandler # isAllowed ( String , Optional , DeadboltHandler , Http . RequestHeader ) }
 * to determine access .
 * @ param name the name of the constraint
 * @ param meta additional information passed to { @ link be . objectify . deadbolt . java . DynamicResourceHandler # isAllowed ( String , Optional , DeadboltHandler , Http . RequestHeader ) }
 * @ return a function that wraps the constraint
 * @ see ConstraintLogic # dynamic ( Http . RequestHeader , DeadboltHandler , Optional , String , Optional , Function , TriFunction , ConstraintPoint ) */
public FilterFunction dynamic ( final String name , final Optional < String > meta ) { } }

implementation: return dynamic ( name , meta , Optional . empty ( ) ) ;


signature:
public class FilterConstraints { /** * A constraint that uses a { @ link Constraint } to determine access . This may be an arbitrarily complex
 * tree of constraints .
 * @ param name the name of the composite constraint defined in { @ link CompositeCache } .
 * @ param content is passed to { @ link DeadboltHandler # onAuthFailure ( Http . RequestHeader , Optional ) } if the authorization fails
 * @ return a function that wraps the constraint
 * @ throws IllegalStateException if no constraint with the given name is present in the composite cache */
public FilterFunction composite ( final String name , final Optional < String > content ) { } }

implementation: return compositeCache . apply ( name ) . map ( constraint -> composite ( constraint , content ) ) . orElseThrow ( ( ) -> new IllegalStateException ( String . format ( "No constraint with name [%s] found" , name ) ) ) ;


signature:
public class FilterConstraints { /** * A constraint that uses a { @ link Constraint } to determine access . This may be an arbitrarily complex
 * tree of constraints .
 * @ param constraint the composite constraint
 * @ param content is passed to { @ link DeadboltHandler # onAuthFailure ( Http . RequestHeader , Optional ) } if the authorization fails
 * @ return a function that wraps the constraint */
public FilterFunction composite ( final Constraint constraint , final Optional < String > content ) { } }

implementation: return ( Http . RequestHeader requestHeader , DeadboltHandler handler , Function < Http . RequestHeader , CompletionStage < Result > > next ) -> beforeAuthCheckCache . apply ( handler , requestHeader , content ) . thenCompose ( maybePreAuth -> maybePreAuth . _1 . map ( preAuthResult -> ( CompletionStage < Result > ) CompletableFuture . completedFuture ( preAuthResult ) ) . orElseGet ( ( ) -> constraint . test ( maybePreAuth . _2 , handler ) . thenCompose ( allowed -> allowed . _1 ? ( ( Supplier < CompletionStage < Result > > ) ( ) -> { handler . onAuthSuccess ( allowed . _2 , "composite" , ConstraintPoint . FILTER ) ; return next . apply ( allowed . _2 ) ; } ) . get ( ) : handler . onAuthFailure ( maybePreAuth . _2 , content ) ) ) ) ;


signature:
public class TemplateUtils { /** * Converts the roles into a String array .
 * @ param roles the roles
 * @ return the roles as an array of strings */
public static String [ ] roles ( final Role ... roles ) { } }

implementation: final List < String > names = new ArrayList < > ( roles . length ) ; for ( Role role : roles ) { names . add ( role . getName ( ) ) ; } return names . toArray ( new String [ names . size ( ) ] ) ;


signature:
public class TemplateUtils { /** * Converts the permissions into a String array .
 * @ param permissions the permissions
 * @ return the permissions as an array of strings */
public static String [ ] permissions ( final Permission ... permissions ) { } }

implementation: final List < String > values = new ArrayList < > ( permissions . length ) ; for ( Permission permission : permissions ) { values . add ( permission . getValue ( ) ) ; } return values . toArray ( new String [ values . size ( ) ] ) ;


signature:
public class TemplateUtils { /** * Converts the arguments into a String array wrapped in a list .
 * @ param args the arguments
 * @ return the arguments as an array within a list */
public static List < String [ ] > allOfGroup ( final String ... args ) { } }

implementation: return Collections . singletonList ( args == null ? new String [ 0 ] : args ) ;


signature:
public class ViewSupport { /** * Used for restrict tags in the template .
 * @ param roles a list of String arrays . Within an array , the roles are ANDed . The arrays in the list are OR ' d .
 * @ return true if the view can be accessed , otherwise false */
public boolean viewRestrict ( final List < String [ ] > roles , final DeadboltHandler handler , final Optional < String > content , final long timeoutInMillis , final Http . RequestHeader requestHeader ) throws Throwable { } }

implementation: boolean allowed ; try { allowed = constraintLogic . restrict ( requestHeader , handler ( handler ) , content , ( ) -> roles , rh -> CompletableFuture . completedFuture ( Boolean . TRUE ) , ( rh , dh , cnt ) -> CompletableFuture . completedFuture ( Boolean . FALSE ) , ConstraintPoint . TEMPLATE ) . toCompletableFuture ( ) . get ( timeoutInMillis , TimeUnit . MILLISECONDS ) ; } catch ( TimeoutException e ) { allowed = timeoutHandler . apply ( timeoutInMillis , e ) ; } return allowed ;


signature:
public class Encoder { /** * < p > This is the kernel of encoding . Currently only CharBuffers
 * backed by arrays ( i . e . { @ link java . nio . CharBuffer # hasArray ( ) }
 * returns { @ code true } ) are supported . < strong > Using a
 * direct - mapped CharBuffer will result in an
 * UnsupportedOperationException < / strong > , though this behavior
 * may change in future releases . < / p >
 * < p > This method should be called repeatedly while { @ code
 * endOfInput } set to { @ code false } while there is more input .
 * Once there is no more input , this method should be called
 * { @ code endOfInput } set to { @ code false } until { @ link
 * java . nio . charset . CoderResult # UNDERFLOW } is returned . < / p >
 * < p > After any call to this method , except when { @ code
 * endOfInput } is { @ code true } and the method returns { @ code
 * UNDERFLOW } , there may be characters left to encode in the
 * { @ code input } buffer ( i . e . { @ code input . hasRemaining ( ) = =
 * true } ) . This will happen when the encoder needs to see more
 * input before determining what to do - - for example when encoding
 * for CDATA , if the input ends with { @ code " foo ] ] " } , the encoder
 * will need to see the next character to determine if it is a " & gt ; "
 * or not . < / p >
 * < p > Example usage : < / p >
 * < pre >
 * CharBuffer input = CharBuffer . allocate ( 1024 ) ;
 * CharBuffer output = CharBuffer . allocate ( 1024 ) ;
 * CoderResult cr ;
 * / / assuming doRead fills in the input buffer or
 * / / returns - 1 at end of input
 * while ( doRead ( input ) ! = - 1 ) {
 * input . flip ( ) ;
 * for ( ; ; ) {
 * cr = encoder . encode ( input , output , false ) ;
 * if ( cr . isUnderflow ( ) ) {
 * break ;
 * if ( cr . isOverflow ( ) ) {
 * / / assuming doWrite flushes the encoded
 * / / characters somewhere .
 * output . flip ( ) ;
 * doWrite ( output ) ;
 * output . compact ( ) ;
 * input . compact ( ) ;
 * / / at end of input
 * input . flip ( ) ;
 * do {
 * cr = encoder . encode ( input , output , true ) ;
 * output . flip ( ) ;
 * doWrite ( output ) ;
 * output . compact ( ) ;
 * } while ( cr . isOverflow ( ) ) ;
 * < / pre >
 * @ param input the input buffer to encode
 * @ param output the output buffer to receive the encoded results
 * @ param endOfInput set to { @ code true } if there is no more input , and any
 * remaining characters at the end of input will either be encoded or
 * replaced as invalid .
 * @ return Either { @ link java . nio . charset . CoderResult # UNDERFLOW }
 * or { @ link java . nio . charset . CoderResult # OVERFLOW } . No other
 * CoderResult value will be returned . Characters or sequences
 * that might conceivably return and invalid or unmappable
 * character result ( as part of the nio Charset API ) are
 * automatically replaced to avoid security implications . */
public CoderResult encode ( CharBuffer input , CharBuffer output , boolean endOfInput ) { } }

implementation: if ( input . hasRemaining ( ) ) { if ( input . hasArray ( ) && output . hasArray ( ) ) { return encodeArrays ( input , output , endOfInput ) ; } else { return encodeBuffers ( input , output , endOfInput ) ; } } else { return CoderResult . UNDERFLOW ; }


signature:
public class Encoder { /** * Internal helper method to properly position buffers after encoding up
 * until an overflow .
 * @ param input the input buffer
 * @ param i the array offset in the input buffer ( translated to position )
 * @ param output the output buffer
 * @ param j the array offset in the output buffer ( translated to position )
 * @ return CoderResult . OVERFLOW */
static CoderResult overflow ( CharBuffer input , int i , CharBuffer output , int j ) { } }

implementation: input . position ( i - input . arrayOffset ( ) ) ; output . position ( j - output . arrayOffset ( ) ) ; return CoderResult . OVERFLOW ;


signature:
public class Encoder { /** * Internal helper method to properly position buffers after encoding up
 * until an underflow .
 * @ param input the input buffer
 * @ param i the array offset in the input buffer ( translated to position )
 * @ param output the output buffer
 * @ param j the array offset in the output buffer ( translated to position )
 * @ return CoderResult . UNDERFLOW */
static CoderResult underflow ( CharBuffer input , int i , CharBuffer output , int j ) { } }

implementation: input . position ( i - input . arrayOffset ( ) ) ; output . position ( j - output . arrayOffset ( ) ) ; return CoderResult . UNDERFLOW ;


signature:
public class ASCIIBits { /** * Clears the bit ( sets to 0 ) for each character in the argument string .
 * @ param chars the characters to clear .
 * @ return { @ code this } */
ASCIIBits clear ( String chars ) { } }

implementation: for ( int i = 0 , n = chars . length ( ) ; i < n ; ++ i ) { char ch = chars . charAt ( i ) ; if ( ch < 64 ) { _lowerMask &= ~ ( 1L << ch ) ; } else { _upperMask &= ~ ( 1L << ch ) ; } } return this ;


signature:
public class ASCIIBits { /** * Sets a range of characters to 1s in the masks .
 * @ param min the minimum ( inclusive ) .
 * @ param max the maximum ( inclusive ) .
 * @ return { @ code this } */
ASCIIBits set ( int min , int max ) { } }

implementation:
// There are faster bit - twiddling tricks to accomplish the same
// thing as below . Minor optimization for later .
int i = min ; for ( int n = Math . min ( max , 63 ) ; i <= n ; ++ i ) { _lowerMask |= ( 1L << i ) ; } for ( ; i <= max ; ++ i ) { _upperMask |= ( 1L << i ) ; } return this ;