signature:
public class PhaseAction { /** * Create an { @ link Operation } that invokes
 * { @ link Submission # submit ( org . ocpsoft . rewrite . event . Rewrite , EvaluationContext , Object ) } , and uses the result of
 * the given { @ link Retrieval # retrieve ( org . ocpsoft . rewrite . event . Rewrite , EvaluationContext ) } as the value for this
 * submission . Process { @ link InvocationResultHandler } instances on the result value ( if any ) .
 * By default , this action is invoked after { @ link PhaseId # RESTORE _ VIEW } */
public static PhaseAction submitTo ( final Submission to , final Retrieval from ) { } }

implementation: return new PhaseAction ( to , from ) { @ Override public String toString ( ) { return "PhaseAction.submitTo(" + to + ", " + from + ")" ; } } . after ( PhaseId . RESTORE_VIEW ) ;


signature:
public class FacesRewriteLifecycleListener { /** * Determines the { @ link DispatcherType } of the current request using the { @ link DispatcherTypeProvider } SPI . */
private DispatcherType getDispatcherType ( final HttpServletRewrite event ) { } }

implementation: for ( DispatcherTypeProvider provider : getDispatcherTypeProviders ( ) ) { DispatcherType dispatcherType = provider . getDispatcherType ( event . getRequest ( ) , event . getServletContext ( ) ) ; if ( dispatcherType != null ) { return dispatcherType ; } } throw new IllegalStateException ( "Unable to determine dispatcher type of current request" ) ;


signature:
public class FacesRewriteLifecycleListener { /** * Returns the list of { @ link DispatcherTypeProvider } implementations . */
private List < DispatcherTypeProvider > getDispatcherTypeProviders ( ) { } }

implementation: List < DispatcherTypeProvider > result = dispatcherTypeProviders ; if ( result == null ) { synchronized ( this ) { result = dispatcherTypeProviders ; if ( result == null ) { result = Iterators . asList ( ServiceLoader . loadTypesafe ( DispatcherTypeProvider . class ) . iterator ( ) ) ; Collections . sort ( result , new WeightedComparator ( ) ) ; dispatcherTypeProviders = result ; } } } return result ;


signature:
public class ParseTools { /** * Return the index of the terminating character in the group , excluding markers . */
public static CapturingGroup balancedCapture ( final char [ ] chars , final int startPos , final int endPos , final CaptureType type ) { } }

implementation: Assert . notNull ( chars , "Character input array must not be null." ) ; Assert . assertTrue ( startPos >= 0 , "Start position must be greater than zero." ) ; Assert . assertTrue ( startPos < ( chars . length - 1 ) , "Start position must be at least one character before the array upper bound." ) ; Assert . assertTrue ( endPos > 0 , "End position must be greater than zero." ) ; Assert . assertTrue ( endPos < chars . length , "End position must be less than or equal to the array upper bound." ) ; Assert . assertTrue ( startPos < endPos , "Start position must be less than end position." ) ; Assert . assertTrue ( chars [ startPos ] == type . getBegin ( ) , "Character at starting position was [" + chars [ startPos ] + "] but expected [" + type . getBegin ( ) + "]" ) ; if ( isEscaped ( chars , startPos ) ) { throw new IllegalArgumentException ( "Character at starting position is escaped, and cannot be used in capturing a group." ) ; } char begin = type . getBegin ( ) ; char end = type . getEnd ( ) ; int cursor = startPos + 1 ; Stack < Integer > beginPositions = new Stack < Integer > ( ) ; beginPositions . push ( cursor ) ; while ( ( cursor <= endPos ) && ( beginPositions . size ( ) > 0 ) ) { char character = chars [ cursor ] ; if ( character == end ) { if ( ! isEscaped ( chars , cursor ) ) { beginPositions . pop ( ) ; } } else if ( character == begin ) { if ( ! isEscaped ( chars , cursor ) ) { beginPositions . push ( cursor ) ; } } if ( beginPositions . size ( ) == 0 ) { break ; } cursor ++ ; } if ( beginPositions . size ( ) > 0 ) { throw new IllegalArgumentException ( "Unclosed capturing group at index [" + beginPositions . peek ( ) + "] of [" + new String ( chars ) + "]" ) ; } return new CapturingGroup ( chars , startPos , cursor ) ;


signature:
public class ParseTools { /** * Return true if the character at the given cursor is escaped ; otherwise , return false . */
public static boolean isEscaped ( final char [ ] chars , final int cursor ) { } }

implementation: Assert . notNull ( chars , "Character input array must not be null." ) ; Assert . assertTrue ( cursor >= 0 , "Start position must be greater than zero." ) ; Assert . assertTrue ( cursor < ( chars . length ) , "Start position must be within the array upper bound." ) ; if ( ( cursor > 0 ) && ( chars [ cursor - 1 ] == ESCAPE_CHAR ) ) { if ( ( cursor == 1 ) || ( ( cursor > 1 ) && ( chars [ cursor - 2 ] != ESCAPE_CHAR ) ) ) { return true ; } } return false ;


signature:
public class And { /** * Creates a new { @ link And } condition . If all provided { @ link Condition } instances return < code > true < / code > , this
 * condition returns < code > true < / code > . If any provided conditions return < code > false < / code > , this condition returns
 * < code > false < / code > .
 * @ param conditions the array of conditions to be evaluated */
public static And all ( final Condition ... conditions ) { } }

implementation: Assert . notNull ( conditions , "At least one condition is required." ) ; Assert . assertTrue ( conditions . length > 0 , "At least one condition is required." ) ; return new And ( flattenConditions ( Arrays . asList ( conditions ) ) . toArray ( new Condition [ ] { } ) ) ;


signature:
public class Metadata { /** * Return a copy of this Metadata */
public Metadata copy ( ) { } }

implementation: Metadata result = new Metadata ( ) ; result . setEncoding ( encoding ) ; result . setTrailingSlash ( trailingSlash ) ; result . setLeadingSlash ( leadingSlash ) ; return result ;


signature:
public class Request { /** * Creates an { @ link HttpOperation } that calls { @ link HttpServletRequest # setCharacterEncoding ( String ) } on the current
 * request .
 * @ param encoding The encoding to apply */
public static Request setCharacterEncoding ( final String encoding ) { } }

implementation: return new Request ( ) { @ Override public void performHttp ( HttpServletRewrite event , EvaluationContext context ) { try { event . getRequest ( ) . setCharacterEncoding ( encoding ) ; } catch ( UnsupportedEncodingException e ) { throw new IllegalArgumentException ( "Failed to set encoding " + encoding , e ) ; } } @ Override public String toString ( ) { return "Request.setCharacterEncoding(\"" + encoding + "\")" ; } } ;


signature:
public class Request { /** * Creates an { @ link HttpOperation } that calls { @ link HttpServletRequest # setAttribute ( String , Object ) } on the current
 * request .
 * @ param name The name of the request attribute
 * @ param value The value to set */
public static Request setAttribute ( final String name , final Object value ) { } }

implementation: return new Request ( ) { @ Override public void performHttp ( HttpServletRewrite event , EvaluationContext context ) { event . getRequest ( ) . setAttribute ( name , value ) ; } @ Override public String toString ( ) { return "Request.setAttribute(\"" + name + "\", \"" + value + "\")" ; } } ;


signature:
public class PhaseBinding { /** * Create a { @ link Binding } to process the given { @ link Submission } during the Faces life - cycle . */
public static PhaseBinding to ( final Submission submission ) { } }

implementation: return new PhaseBinding ( submission ) { @ Override public String toString ( ) { return "PhaseBinding.to(" + submission + ")" ; } } ;


signature:
public class PhaseBinding { /** * Perform this { @ link PhaseBinding } before the given phases ( Except { @ link PhaseId # RESTORE _ VIEW } ) . The deferred
 * { @ link Submission } will be performed once for each { @ link PhaseId } provided . */
public PhaseBinding before ( final PhaseId ... phases ) { } }

implementation: if ( phases != null ) this . beforePhases . addAll ( Arrays . asList ( phases ) ) ; return this ;


signature:
public class PhaseBinding { /** * Perform this { @ link PhaseBinding } after the given phases ( Except { @ link PhaseId # RENDER _ RESPONSE } ) . The deferred
 * { @ link Submission } will be performed once for each { @ link PhaseId } provided . */
public PhaseBinding after ( final PhaseId ... phases ) { } }

implementation: if ( phases != null ) this . afterPhases . addAll ( Arrays . asList ( phases ) ) ; return this ;


signature:
public class AbstractClassFinder { /** * Strip everything up to and including a given prefix from a string .
 * @ param str The string to process
 * @ param prefix The prefix
 * @ return the stripped string or < code > null < / code > if the prefix has not been found */
protected String stripKnownPrefix ( String str , String prefix ) { } }

implementation: int startIndex = str . lastIndexOf ( prefix ) ; if ( startIndex != - 1 ) { return str . substring ( startIndex + prefix . length ( ) ) ; } return null ;


signature:
public class AbstractClassFinder { /** * Creates a FQCN from an { @ link URL } representing a < code > . class < / code > file .
 * @ param url The path of the class file
 * @ return the FQCN of the class */
protected static String getClassName ( String filename ) { } }

implementation:
// end index is just before " . class "
int endIndex = filename . length ( ) - ".class" . length ( ) ; // extract relevant part of the path
String relativePath = filename . substring ( 0 , endIndex ) ; // replace / by . to create FQCN
return relativePath . replace ( '/' , '.' ) ;


signature:
public class AbstractClassFinder { /** * Checks if a supplied class has to be processed by checking the package name against the { @ link PackageFilter } .
 * @ param className FQCN of the class
 * @ return < code > true < / code > for classes to process , < code > false < / code > for classes to ignore */
protected boolean mustProcessClass ( String className ) { } }

implementation:
// skip versioned classes in Java 9 Multi - release JAR files
if ( className . startsWith ( "META-INF.versions" ) ) { return false ; } // the default package
String packageName = "" ; // find last dot in class name to determine the package name
int packageEndIndex = className . lastIndexOf ( "." ) ; if ( packageEndIndex != - 1 ) { packageName = className . substring ( 0 , packageEndIndex ) ; } // check filter
return packageFilter . isAllowedPackage ( packageName ) ;


signature:
public class AbstractClassFinder { /** * Handle a single class to process . This method should only be called if the class name is accepted by the
 * { @ link PackageFilter } .
 * If < code > classFileStream < / code > is not < code > null < / code > the method will first try to check whether the class
 * files may contain annotations by scanning it with the { @ link ByteCodeFilter } . If no { @ link InputStream } is
 * supplied , this check will be skipped . After that the method will create an instance of the class and then call
 * { @ link ClassVisitor # visit ( Class , org . ocpsoft . prettyfaces . annotation . PrettyConfig ) } .
 * Please not the the called of this method is responsible to close the supplied { @ link InputStream } !
 * @ param className The FQCN of the class
 * @ param classFileStream The Java class file of the class ( may be < code > null < / code > )
 * @ param visitor the visitor */
protected void processClass ( String className , InputStream classFileStream , ClassVisitor visitor ) { } }

implementation:
// skip Java 9 module metadata class files
if ( className . equals ( "module-info" ) ) return ; // bytecode check is only performed if the InputStream is available
if ( classFileStream != null ) { // we must take care of IOExceptions thrown by ByteCodeAnnotationFilter
try { // call bytecode filter
boolean shouldScanClass = byteCodeFilter . accept ( classFileStream ) ; // No annotations - > abort
if ( ! shouldScanClass ) { return ; } // filter says we should scan the class
if ( log . isDebugEnabled ( ) ) { log . debug ( "Bytecode filter recommends to scan class: " + className ) ; } } catch ( IOException e ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Failed to parse class file: " + className , e ) ; } } } try { // request this class from the ClassLoader
Class < ? > clazz = Class . forName ( className , false , classLoader ) ; // call handler
visitor . visit ( clazz ) ; } catch ( NoClassDefFoundError e ) { // reference to another class unknown to the classloader
log . debug ( "Could not load class '" + className + "': " + e . toString ( ) ) ; } catch ( ClassNotFoundException e ) { // should no happen , because we found the class on the classpath
throw new IllegalStateException ( "Unable to load class: " + className , e ) ; }


signature:
public class JodaTime { /** * Create a new { @ link JodaTime } condition that , for each { @ link org . ocpsoft . rewrite . event . Rewrite } , evaluates the
 * given { @ link TimeCondition } again the system ' s current { @ link DateTime } */
public static JodaTime matches ( final TimeCondition condition ) { } }

implementation: return new JodaTime ( condition ) { @ Override public String toString ( ) { return "JodaTime.matches(" + condition + ")" ; } } ;


signature:
public class JodaTime { /** * Create a new { @ link JodaTime } condition that , for each { @ link org . ocpsoft . rewrite . event . Rewrite } , evaluates the
 * given { @ link TimeCondition } again the system ' s current { @ link DateTime } using the provided { @ link DateTimeZone } */
public static JodaTime matches ( final TimeCondition condition , final DateTimeZone zone ) { } }

implementation: return new JodaTime ( condition , zone ) { @ Override public String toString ( ) { return "JodaTime.matches(" + condition + ", " + zone + ")" ; } } ;


signature:
public class JodaTime { /** * Evaluator */
@ Override public boolean evaluate ( final Rewrite event , final EvaluationContext context ) { } }

implementation: if ( zone != null ) return condition . matches ( new DateTime ( zone ) ) ; else return condition . matches ( new DateTime ( ) ) ;


signature:
public class AddressBuilderQuery { /** * Set a query - parameter to a value or multiple values . The given name and values will be stored without additional
 * encoding or decoding . */
public AddressBuilderQuery query ( CharSequence name , Object value ) { } }

implementation: return parent . query ( name , value ) ;


signature:
public class AddressBuilderQuery { /** * Set a query - parameter value or multiple values . The given name and values be decoded before they are stored . */
public AddressBuilderQuery queryDecoded ( CharSequence name , Object ... values ) { } }

implementation: return parent . queryDecoded ( name , values ) ;


signature:
public class AddressBuilderQuery { /** * Set a query - parameter to a value or multiple values . The given name and values be encoded before they are stored . */
public AddressBuilderQuery queryEncoded ( CharSequence name , Object value ) { } }

implementation: return parent . queryEncoded ( name , value ) ;


signature:
public class PrettyConfig { /** * Search through all currently configured { @ link UrlMapping } objects for the first one that matches the given URL .
 * @ return the first appropriate { @ link UrlMapping } for a given URL . */
public UrlMapping getMappingForUrl ( final URL url ) { } }

implementation: final String mappingKey = url . toURL ( ) ; if ( cachedMappings . containsKey ( mappingKey ) ) { return cachedMappings . get ( mappingKey ) ; } for ( UrlMapping mapping : getMappings ( ) ) { if ( mapping . matches ( url ) ) { if ( ! mapping . getPatternParser ( ) . isElPattern ( ) ) { cachedMappings . put ( mappingKey , mapping ) ; } return mapping ; } } return null ;


signature:
public class PrettyConfig { /** * Discover if the given ViewId is mapped by any { @ link UrlMapping } specified in the current configuration .
 * < b > Note : < / b > This will not match if a # { dynamicView . id } method is configured .
 * @ return True if the ViewId is mapped , false if not . */
public boolean isViewMapped ( String viewId ) { } }

implementation: if ( viewId != null ) { viewId = viewId . trim ( ) ; for ( UrlMapping mapping : mappings ) { if ( viewId . equals ( mapping . getViewId ( ) ) || ( viewId . startsWith ( "/" ) && viewId . substring ( 1 ) . equals ( mapping . getViewId ( ) ) ) ) { return true ; } } } return false ;


signature:
public class PrettyConfig { /** * Get the { @ link UrlMapping } corresponding with the given mapping id .
 * @ param id Mapping id
 * @ return PrettyUrlMapping Corresponding mapping */
public UrlMapping getMappingById ( String id ) { } }

implementation: if ( id != null ) { if ( id . startsWith ( PrettyContext . PRETTY_PREFIX ) ) { id = id . substring ( PrettyContext . PRETTY_PREFIX . length ( ) ) ; } for ( UrlMapping mapping : getMappings ( ) ) { if ( mapping . getId ( ) . equals ( id ) ) { return mapping ; } } } return null ;


signature:
public class Parameters { /** * Retrieve a single parameter value from the { @ link ParameterValueStore } . */
public static String retrieve ( EvaluationContext context , String string ) { } }

implementation: return ( ( ParameterValueStore ) context . get ( ParameterValueStore . class ) ) . retrieve ( ( ( ParameterStore ) context . get ( ParameterStore . class ) ) . get ( string ) ) ;


signature:
public class FacesNavigationURLCanonicalizer { /** * This method reads all required values from the { @ link FacesContext } and
 * then delegates the call to
 * { @ link # normalizeRequestURI ( String , String , String ) } .
 * @ param context
 * The { @ link FacesContext }
 * @ param viewId
 * the view id
 * @ return the URI without additional FacesServlet mappings */
public static String normalizeRequestURI ( final FacesContext context , final String viewId ) { } }

implementation: ExternalContext externalContext = context . getExternalContext ( ) ; return normalizeRequestURI ( externalContext . getRequestServletPath ( ) , externalContext . getRequestPathInfo ( ) , viewId ) ;


signature:
public class FacesNavigationURLCanonicalizer { /** * Prune the url - pattern from the < code > viewId < / code > if prefix mapped
 * FacesServlet , otherwise return the original URI .
 * @ param servletPath
 * the servlet path
 * @ param requestPathInfo
 * the path info
 * @ param viewId
 * the view id
 * @ return the URI without additional FacesServlet mappings
 * @ see javax . servlet . http . HttpServletRequest # getServletPath ( )
 * @ see javax . servlet . http . HttpServletRequest # getPathInfo ( ) */
public static String normalizeRequestURI ( final String servletPath , final String requestPathInfo , final String viewId ) { } }

implementation:
// We must not process empty viewIds
if ( viewId == null ) { return null ; } /* * code from com . sun . faces . util . Util # getMappingForRequest ( String servletPath , String pathInfo )
 * and com . sun . faces . application . view . MultiViewHandler # normalizeRequestURI ( String uri , String mapping ) */
if ( servletPath != null ) { if ( ( requestPathInfo != null || servletPath . indexOf ( '.' ) < 0 ) && viewId . startsWith ( servletPath + '/' ) ) { return viewId . substring ( servletPath . length ( ) ) ; } } return viewId ;


signature:
public class Scheme { /** * Create a { @ link Condition } to inspect the current request scheme , comparing against the given pattern .
 * The given pattern may be parameterized using the following format :
 * < code >
 * https < br / >
 * mailto < br / >
 * { scheme } < / br >
 * { scheme } - custom < br >
 * < / code >
 * @ param pattern { @ link ParameterizedPattern } specifying the { @ link Scheme } of the current { @ link Address } .
 * @ see { @ link ConfigurationRuleParameterBuilder # where ( String ) } */
public static Scheme matches ( final String pattern ) { } }

implementation: return new Scheme ( pattern ) { @ Override public String toString ( ) { return "Scheme.matches(\"" + pattern + "\")" ; } } ;


signature:
public class DigesterPrettyConfigParser { /** * Configure the digester . Assume that the builder object will be pushed
 * after this method is called . */
private Digester configureDigester ( final Digester digester ) { } }

implementation:
/* * We use the context class loader to resolve classes . This fixes
 * ClassNotFoundExceptions on Geronimo . */
digester . setUseContextClassLoader ( true ) ; /* * Parse RewriteRules */
digester . addObjectCreate ( "pretty-config/rewrite" , RewriteRule . class ) ; digester . addSetProperties ( "pretty-config/rewrite" ) ; digester . addSetNext ( "pretty-config/rewrite" , "addRewriteRule" ) ; /* * Create Mapping Object */
digester . addObjectCreate ( "pretty-config/url-mapping" , UrlMapping . class ) ; digester . addSetProperties ( "pretty-config/url-mapping" ) ; digester . addCallMethod ( "pretty-config/url-mapping/pattern" , "setPattern" , 1 ) ; digester . addCallParam ( "pretty-config/url-mapping/pattern" , 0 , "value" ) ; digester . addCallMethod ( "pretty-config/url-mapping/pattern" , "setPattern" , 0 ) ; /* * Parse View Id */
digester . addCallMethod ( "pretty-config/url-mapping/view-id" , "setViewId" , 1 ) ; digester . addCallParam ( "pretty-config/url-mapping/view-id" , 0 , "value" ) ; digester . addCallMethod ( "pretty-config/url-mapping/view-id" , "setViewId" , 0 ) ; /* * Parse Path Validators */
digester . addObjectCreate ( "pretty-config/url-mapping/pattern/validate" , PathValidator . class ) ; digester . addSetProperties ( "pretty-config/url-mapping/pattern/validate" ) ; digester . addSetNext ( "pretty-config/url-mapping/pattern/validate" , "addPathValidator" ) ; /* * Parse Query Params */
digester . addObjectCreate ( "pretty-config/url-mapping/query-param" , QueryParameter . class ) ; digester . addSetProperties ( "pretty-config/url-mapping/query-param" ) ; digester . addCallMethod ( "pretty-config/url-mapping/query-param" , "setExpression" , 0 ) ; digester . addSetNext ( "pretty-config/url-mapping/query-param" , "addQueryParam" ) ; /* * Parse Action Methods */
digester . addObjectCreate ( "pretty-config/url-mapping/action" , UrlAction . class ) ; digester . addSetProperties ( "pretty-config/url-mapping/action" ) ; digester . addCallMethod ( "pretty-config/url-mapping/action" , "setAction" , 0 ) ; digester . addSetNext ( "pretty-config/url-mapping/action" , "addAction" ) ; /* * Add Mapping to Builder */
digester . addSetNext ( "pretty-config/url-mapping" , "addMapping" ) ; return digester ;


signature:
public class Substitute { /** * Substitute the current { @ link Address } with the given location .
 * The given location may be parameterized :
 * INBOUND : < br / >
 * < code >
 * / example / { param } . html < br >
 * / css / { value } . css < br >
 * < / code >
 * OUTBOUND : < br / >
 * < code >
 * www . example . com / path / file . html < br >
 * www . example . com / path / { resource } . html < br >
 * < / code >
 * @ param location { @ link ParameterizedPattern } specifying the new { @ link Address } .
 * @ see { @ link ConfigurationRuleParameterBuilder # where ( String ) } */
public static Substitute with ( final String location ) { } }

implementation: return new Substitute ( location ) { @ Override public String toString ( ) { return "Substitute.with(\"" + location + "\")" ; } } ;


signature:
public class WebLibFinder { /** * Process a single JAR file in the < code > / WEB - INF / lib / < / code > directory .
 * @ param jarUrl The URL of the JAR file
 * @ param visitor The visitor to call on classes */
private void processJarFile ( URL jarUrl , ClassVisitor visitor ) { } }

implementation:
// log file name on debug lvel
if ( log . isDebugEnabled ( ) ) { log . debug ( "Processing JAR file: " + jarUrl . toString ( ) ) ; } // Use a JarInputStream to read the archive
JarInputStream jarStream = null ; // catch any type of IOException
try { // open the JAR stream
jarStream = new JarInputStream ( jarUrl . openStream ( ) ) ; // Loop over all entries of the archive
JarEntry jarEntry = null ; while ( ( jarEntry = jarStream . getNextJarEntry ( ) ) != null ) { // We are only interested in java class files
if ( jarEntry . getName ( ) . endsWith ( ".class" ) ) { // generate FQCN from entry
String className = getClassName ( jarEntry . getName ( ) ) ; // check name against PackageFilter
if ( mustProcessClass ( className ) ) { // analyze this class
processClass ( className , jarStream , visitor ) ; } } } } catch ( IOException e ) { log . error ( "Failed to read JAR file: " + jarUrl . toString ( ) , e ) ; } finally { // Close the stream if it has been opened
if ( jarStream != null ) { try { jarStream . close ( ) ; } catch ( IOException e ) { // ignore IO failures on close
} } }


signature:
public class PrettyAnnotationHandler { /** * This method scans the supplied class for PrettyFaces annotations . The method must be called for every class that
 * should be scanner before finally calling { @ link # build ( PrettyConfigBuilder ) } .
 * @ param clazz The class to scan */
@ Override public void visit ( Class < ? > clazz ) { } }

implementation:
// log class name on trace level
if ( log . isTraceEnabled ( ) ) { log . trace ( "Analyzing class: " + clazz . getName ( ) ) ; } try { // scan for PrettyAnnotation class
// returns the mapping ID , if an annotation was found
String [ ] classMappingIds = processClassMappingAnnotations ( clazz ) ; // scan for PrettyBean annotation
processPrettyBeanAnnotation ( clazz ) ; // process annotations on public methods
for ( Method method : clazz . getMethods ( ) ) { processMethodAnnotations ( method , classMappingIds ) ; } // loop over fields to find URLQueryParameter annotations
for ( Field field : clazz . getDeclaredFields ( ) ) { processFieldAnnotations ( field , classMappingIds ) ; } } catch ( NoClassDefFoundError e ) { // reference to another class unknown to the classloader
log . debug ( "Unable to process class '" + clazz . getName ( ) + "': " + e . toString ( ) ) ; }


signature:
public class PrettyAnnotationHandler { /** * Checks for PrettyFaces mapping annotations on a single class
 * @ param clazz Class to scan
 * @ return The IDs of the mappings found on the class */
public String [ ] processClassMappingAnnotations ( Class < ? > clazz ) { } }

implementation:
// list of all mapping IDs found on the class
List < String > classMappingIds = new ArrayList < String > ( ) ; // get reference to @ URLMapping annotation
URLMapping mappingAnnotation = ( URLMapping ) clazz . getAnnotation ( URLMapping . class ) ; // process annotation if it exists
if ( mappingAnnotation != null ) { String mappingId = processPrettyMappingAnnotation ( clazz , mappingAnnotation ) ; classMappingIds . add ( mappingId ) ; } // container annotation
URLMappings mappingsAnnotation = ( URLMappings ) clazz . getAnnotation ( URLMappings . class ) ; if ( mappingsAnnotation != null ) { // process all contained @ URLMapping annotations
for ( URLMapping child : mappingsAnnotation . mappings ( ) ) { String mappingId = processPrettyMappingAnnotation ( clazz , child ) ; classMappingIds . add ( mappingId ) ; } } // return list of mappings found
return classMappingIds . toArray ( new String [ classMappingIds . size ( ) ] ) ;


signature:
public class PrettyAnnotationHandler { /** * Process a single { @ link URLMapping } annotation .
 * @ param clazz The class that the annotation was found on
 * @ param mappingAnnotation The annotation to process
 * @ return The mapping ID of the mapping found */
private String processPrettyMappingAnnotation ( Class < ? > clazz , URLMapping mappingAnnotation ) { } }

implementation:
// log class name
if ( log . isTraceEnabled ( ) ) { log . trace ( "Found @URLMapping annotation on class: " + clazz . getName ( ) ) ; } // create UrlMapping from annotation
UrlMapping mapping = new UrlMapping ( ) ; mapping . setId ( mappingAnnotation . id ( ) ) ; mapping . setParentId ( mappingAnnotation . parentId ( ) ) ; mapping . setPattern ( mappingAnnotation . pattern ( ) ) ; mapping . setViewId ( mappingAnnotation . viewId ( ) ) ; mapping . setOutbound ( mappingAnnotation . outbound ( ) ) ; mapping . setOnPostback ( mappingAnnotation . onPostback ( ) ) ; // register mapping
Object existingMapping = urlMappings . put ( mapping . getId ( ) , mapping ) ; // fail if a mapping with this ID already existed
if ( existingMapping != null ) { throw new IllegalArgumentException ( "Duplicated mapping id: " + mapping . getId ( ) ) ; } // At bean name to lookup map if it has been specified
if ( ( mappingAnnotation . beanName ( ) != null ) && ( mappingAnnotation . beanName ( ) . length ( ) > 0 ) ) { beanNameMap . put ( clazz , mappingAnnotation . beanName ( ) ) ; } // process validations
for ( URLValidator validationAnnotation : mappingAnnotation . validation ( ) ) { // index attribute is required in this case
if ( validationAnnotation . index ( ) < 0 ) { throw new IllegalArgumentException ( "Please set the index of the path parameter you want to validate with the @URLValidator specified on mapping: " + mapping . getId ( ) ) ; } // prepare PathValidator
PathValidator pathValidator = new PathValidator ( ) ; pathValidator . setIndex ( validationAnnotation . index ( ) ) ; pathValidator . setOnError ( validationAnnotation . onError ( ) ) ; pathValidator . setValidatorIds ( join ( validationAnnotation . validatorIds ( ) , " " ) ) ; // optional validator method
if ( ! isBlank ( validationAnnotation . validator ( ) ) ) { pathValidator . setValidatorExpression ( new ConstantExpression ( validationAnnotation . validator ( ) ) ) ; } // add PathValidator to the mapping
mapping . getPathValidators ( ) . add ( pathValidator ) ; } // return mapping id
return mapping . getId ( ) . trim ( ) ;


signature:
public class PrettyAnnotationHandler { /** * Checks the class for a { @ link URLBeanName } annotation .
 * @ param clazz Class to scan */
private void processPrettyBeanAnnotation ( Class < ? > clazz ) { } }

implementation:
// get reference to @ URLMapping annotation
URLBeanName prettyBean = ( URLBeanName ) clazz . getAnnotation ( URLBeanName . class ) ; // process annotation if it exists
if ( prettyBean != null ) { // log class name
if ( log . isTraceEnabled ( ) ) { log . trace ( "Found @URLBeanName annotation on class: " + clazz . getName ( ) ) ; } // add bean to map
beanNameMap . put ( clazz , prettyBean . value ( ) ) ; }


signature:
public class PrettyAnnotationHandler { /** * Searches for { @ link URLAction } or { @ link URLActions } annotations on a method .
 * @ param method Method to scan
 * @ param classMappingIds The mapping IDs of the class this method belongs to */
private void processMethodAnnotations ( Method method , String [ ] classMappingIds ) { } }

implementation:
// is there a @ URLAction annotation on the class ?
URLAction actionAnnotation = method . getAnnotation ( URLAction . class ) ; if ( actionAnnotation != null ) { processPrettyActionAnnotation ( actionAnnotation , method , classMappingIds ) ; } // is there a @ URLAction container annotation on the class ?
URLActions actionsAnnotation = method . getAnnotation ( URLActions . class ) ; if ( actionsAnnotation != null ) { // process all @ URLAction annotations
for ( URLAction child : actionsAnnotation . actions ( ) ) { processPrettyActionAnnotation ( child , method , classMappingIds ) ; } }


signature:
public class PrettyAnnotationHandler { /** * Searches for { @ link URLQueryParameter } annotations on a single field .
 * @ param field Field to scan
 * @ param classMappingIds The mapping IDs of the class this method belongs to */
private void processFieldAnnotations ( Field field , String [ ] classMappingIds ) { } }

implementation:
// Is there a @ URLQueryParameter annotation ?
URLQueryParameter queryParamAnnotation = field . getAnnotation ( URLQueryParameter . class ) ; if ( queryParamAnnotation != null ) { // create a QueryParamSpec from the annotation
QueryParamSpec queryParam = new QueryParamSpec ( ) ; queryParam . setFieldName ( field . getName ( ) ) ; queryParam . setOwnerClass ( field . getDeclaringClass ( ) ) ; queryParam . setName ( queryParamAnnotation . value ( ) ) ; queryParam . setOnPostback ( queryParamAnnotation . onPostback ( ) ) ; // check which mapping the action belongs to
if ( ! isBlank ( queryParamAnnotation . mappingId ( ) ) ) { // action belongs to the mapping mentioned with mappingId attribute
queryParam . setMappingIds ( new String [ ] { queryParamAnnotation . mappingId ( ) . trim ( ) } ) ; } else if ( classMappingIds != null && classMappingIds . length > 0 ) { // use the mappings found on the class
queryParam . setMappingIds ( classMappingIds ) ; } else { throw new IllegalArgumentException ( "Unable to find a suitable mapping " + "for the query-parameter definied on field '" + field . getName ( ) + "' in class '" + field . getDeclaringClass ( ) . getName ( ) + "'. Either place a @URLMapping annotation on the " + "class or reference a foreign mapping using the 'mappingId' attribute." ) ; } // check if there is also a validation annotation placed on the field
URLValidator validationAnnotation = field . getAnnotation ( URLValidator . class ) ; // check if annotation has been found
if ( validationAnnotation != null ) { // set validation options on the QueryParamSpec object
queryParam . setValidatorIds ( validationAnnotation . validatorIds ( ) ) ; queryParam . setOnError ( validationAnnotation . onError ( ) ) ; queryParam . setValidator ( validationAnnotation . validator ( ) ) ; } // add the new spec object to the list of specs
queryParamList . add ( queryParam ) ; }


signature:
public class PrettyAnnotationHandler { /** * Creates a { @ link UrlAction } object from the supplied { @ link URLAction } annotation
 * @ param actionAnnotation The annotation
 * @ param method The method that was annotated
 * @ param classMappingIds the mapping IDs of the current class */
private void processPrettyActionAnnotation ( URLAction actionAnnotation , Method method , String [ ] classMappingIds ) { } }

implementation:
// Create ActionSpec
ActionSpec actionSpec = new ActionSpec ( ) ; actionSpec . setMethod ( method ) ; actionSpec . setOnPostback ( actionAnnotation . onPostback ( ) ) ; actionSpec . setInheritable ( actionAnnotation . inheritable ( ) ) ; actionSpec . setPhaseId ( actionAnnotation . phaseId ( ) ) ; // check which mapping the action belongs to
if ( ! isBlank ( actionAnnotation . mappingId ( ) ) ) { // action belongs to the mapping mentioned with mappingId attribute
actionSpec . setMappingIds ( new String [ ] { actionAnnotation . mappingId ( ) . trim ( ) } ) ; } else if ( classMappingIds != null && classMappingIds . length > 0 ) { // use the mapping found on the class
actionSpec . setMappingIds ( classMappingIds ) ; } else { // No mapping found . . . throw an exception . .
throw new IllegalArgumentException ( "Unable to find a suitable mapping " + "for the action definied on method '" + method . getName ( ) + "' in class '" + method . getDeclaringClass ( ) . getName ( ) + "'. Either place a @URLMapping annotation on the " + "class or reference a foreign mapping using the 'mappingId' attribute." ) ; } // add action to list of actions
urlActions . add ( actionSpec ) ;


signature:
public class PrettyAnnotationHandler { /** * This methods adds all mappings found to the supplied { @ link PrettyConfigBuilder } . It should be called after all
 * classes has been scanned via { @ link # processClass ( Class ) } .
 * @ param builder The builder to add the mappings to */
public void build ( PrettyConfigBuilder builder ) { } }

implementation:
// process all actions found
for ( ActionSpec actionSpec : urlActions ) { // create an action for each referenced mapping
for ( String mappingId : actionSpec . getMappingIds ( ) ) { // Get the mapping references by the action
UrlMapping mapping = urlMappings . get ( mappingId ) ; /* * Fail for unresolved mappings . This may happen when the user places
 * invalid mapping IDs in the mappingId attribute of
 * @ URLAction or @ URLQueryParameter */
if ( mapping == null ) { throw new IllegalArgumentException ( "Unable to find the mapping '" + mappingId + "' referenced at method '" + actionSpec . getMethod ( ) . getName ( ) + "' in class '" + actionSpec . getMethod ( ) . getDeclaringClass ( ) . getName ( ) + "'." ) ; } // build UrlMapping
UrlAction urlAction = new UrlAction ( ) ; urlAction . setPhaseId ( actionSpec . getPhaseId ( ) ) ; urlAction . setOnPostback ( actionSpec . isOnPostback ( ) ) ; urlAction . setInheritable ( actionSpec . isInheritable ( ) ) ; // try to get bean name
Class < ? > clazz = actionSpec . getMethod ( ) . getDeclaringClass ( ) ; // build expression
PrettyExpression expression = buildPrettyExpression ( clazz , actionSpec . getMethod ( ) . getName ( ) ) ; urlAction . setAction ( expression ) ; // trace
if ( log . isTraceEnabled ( ) ) { log . trace ( "Adding action expression '" + urlAction . getAction ( ) + "' to mapping: " + mapping . getId ( ) ) ; } // register this action
mapping . addAction ( urlAction ) ; } } for ( QueryParamSpec queryParamSpec : queryParamList ) { // create a query param for each referenced mapping
for ( String mappingId : queryParamSpec . getMappingIds ( ) ) { // Get the mapping references by the query param
UrlMapping mapping = urlMappings . get ( mappingId ) ; // fail for unresolved mappings
if ( mapping == null ) { throw new IllegalArgumentException ( "Unable to find the mapping '" + mappingId + "' referenced at field '" + queryParamSpec . getFieldName ( ) + "' in class '" + queryParamSpec . getOwnerClass ( ) . getName ( ) + "'." ) ; } // build UrlMapping
QueryParameter queryParam = new QueryParameter ( ) ; queryParam . setName ( queryParamSpec . getName ( ) ) ; queryParam . setOnError ( queryParamSpec . getOnError ( ) ) ; queryParam . setValidatorIds ( join ( queryParamSpec . getValidatorIds ( ) , " " ) ) ; queryParam . setOnPostback ( queryParamSpec . isOnPostback ( ) ) ; // optional validator method
if ( ! isBlank ( queryParamSpec . getValidator ( ) ) ) { queryParam . setValidatorExpression ( new ConstantExpression ( queryParamSpec . getValidator ( ) ) ) ; } // try to get bean name
Class < ? > clazz = queryParamSpec . getOwnerClass ( ) ; // build expression
PrettyExpression expression = buildPrettyExpression ( clazz , queryParamSpec . getFieldName ( ) ) ; queryParam . setExpression ( expression ) ; // trace
if ( log . isTraceEnabled ( ) ) { log . trace ( "Registered query-param '" + queryParam . getName ( ) + "' to '" + expression + "' in mapping: " + mapping . getId ( ) ) ; } // register this action
mapping . addQueryParam ( queryParam ) ; } } // finally register all mappings
for ( UrlMapping mapping : urlMappings . values ( ) ) { builder . addMapping ( mapping ) ; }


signature:
public class PrettyAnnotationHandler { /** * Creates a { @ link PrettyExpression } for a class and component . This method may return a { @ link ConstantExpression }
 * or a { @ link LazyExpression } .
 * @ param clazz The class of the bean
 * @ param component the component ( property or method name )
 * @ return The expression */
private PrettyExpression buildPrettyExpression ( Class < ? > clazz , String component ) { } }

implementation:
if ( log . isTraceEnabled ( ) ) { log . trace ( "Searching name of bean: " + clazz . getName ( ) ) ; } // get name from internal map build from @ URLBeanName annotations and
// previously resolved names
String beanName = beanNameMap . get ( clazz ) ; // return a constant expression
if ( beanName != null ) { if ( log . isTraceEnabled ( ) ) { log . trace ( "Got bean name from @URLBeanName annotation: " + beanName ) ; } return new ConstantExpression ( "#{" + beanName + "." + component + "}" ) ; } // build a lazy expression
else { if ( log . isTraceEnabled ( ) ) { log . trace ( "Name of bean not found. Building lazy expression for: " + clazz . getName ( ) ) ; } return new LazyExpression ( beanNameFinder , clazz , component ) ; }


signature:
public class PrettyAnnotationHandler { /** * Joins the list of values .
 * @ param values values to join
 * @ param separator the separator to use
 * @ return joined list of values */
private static String join ( String [ ] values , String separator ) { } }

implementation: StringBuilder result = new StringBuilder ( ) ; if ( values != null ) { for ( int i = 0 ; i < values . length ; i ++ ) { if ( i > 0 ) { result . append ( separator ) ; } result . append ( values [ i ] ) ; } } return result . toString ( ) ;


signature:
public class AddressBuilderPath { /** * Set a query - parameter to a value or multiple values . The given name and values will be stored without additional
 * encoding or decoding . */
public AddressBuilderQuery query ( CharSequence name , Object ... values ) { } }

implementation: return parent . query ( name , values ) ;


signature:
public class AddressBuilderPath { /** * Set a query - parameter to a value or multiple values . The given name and values be encoded before they are stored . */
public AddressBuilderQuery queryEncoded ( CharSequence name , Object ... values ) { } }

implementation: return parent . queryEncoded ( name , values ) ;


signature:
public class AddressBuilderPath { /** * Set a parameter name and value or values . The supplied values will be stored without additional encoding . */
public AddressBuilderPath set ( CharSequence name , Object ... values ) { } }

implementation: parent . set ( name , values ) ; return this ;


signature:
public class AddressBuilderPath { /** * Set a parameter name and value or values . The values will be decoded before they are stored . */
public AddressBuilderPath setDecoded ( CharSequence name , Object ... values ) { } }

implementation: parent . setDecoded ( name , values ) ; return this ;


signature:
public class AddressBuilderPath { /** * Set a parameter name and value or values . The values will be encoded before they are stored . */
public AddressBuilderPath setEncoded ( CharSequence name , Object ... values ) { } }

implementation: parent . setEncoded ( name , values ) ; return this ;


signature:
public class ServletMapping { /** * Create a { @ link Condition } that returns < code > true < / code > if the given resource is mapped by any { @ link Servlet }
 * instances registered within the current application , and returns < code > false < / code > if no { @ link Servlet } will
 * handle the specified resource pattern .
 * The given resource path may be parameterized :
 * < code >
 * / example / { param } . html < br >
 * / css / { value } . css < br >
 * < / code >
 * @ param location { @ link ParameterizedPattern } specifying the { @ link Address } of the internal resource .
 * @ see { @ link ConfigurationRuleParameterBuilder # where ( String ) } */
public static ServletMapping includes ( final String resource ) { } }

implementation: return new ServletMapping ( resource ) { @ Override public String toString ( ) { return "ServletMapping.includes(\"" + resource + "\")" ; } } ;


signature:
public class ServletMapping { /** * Obtains the list of registered { @ link Servlet } instances using the { @ link ServletRegistrationProvider } SPI . */
private List < ServletRegistration > getServletRegistration ( ServletContext context ) { } }

implementation: for ( ServletRegistrationProvider provider : getServletRegistrationProviders ( ) ) { List < ServletRegistration > registrations = provider . getServletRegistrations ( context ) ; if ( registrations != null ) { return registrations ; } } throw new IllegalStateException ( "Unable to find the Servlet registrations of the application" ) ;


signature:
public class ServletMapping { /** * Returns the list of { @ link ServletRegistrationProvider } implementations . */
private List < ServletRegistrationProvider > getServletRegistrationProviders ( ) { } }

implementation: if ( servletRegistrationProviders == null ) { servletRegistrationProviders = Iterators . asList ( ServiceLoader . loadTypesafe ( ServletRegistrationProvider . class ) . iterator ( ) ) ; Collections . sort ( servletRegistrationProviders , new WeightedComparator ( ) ) ; } return servletRegistrationProviders ;


signature:
public class UserAgentUtil { /** * Initialize Key Stored Values . */
public void initDeviceScan ( ) { } }

implementation:
// Save these properties to speed processing
this . isWebkit = detectWebkit ( ) ; this . isIphone = detectIphone ( ) ; this . isAndroid = detectAndroid ( ) ; this . isAndroidPhone = detectAndroidPhone ( ) ; // Generally , these tiers are the most useful for web development
this . isMobilePhone = detectMobileQuick ( ) ; this . isTierTablet = detectTierTablet ( ) ; this . isTierIphone = detectTierIphone ( ) ; // Optional : Comment these out if you NEVER use them
this . isTierRichCss = detectTierRichCss ( ) ; this . isTierGenericMobile = detectTierOtherPhones ( ) ; this . initCompleted = true ;


signature:
public class UserAgentUtil { /** * Detects if the current device is an iPhone .
 * @ return detection of an iPhone */
public boolean detectIphone ( ) { } }

implementation:
if ( ( this . initCompleted == true ) || ( this . isIphone == true ) ) return this . isIphone ; // The iPad and iPod touch say they ' re an iPhone ! So let ' s disambiguate .
if ( userAgent . indexOf ( deviceIphone ) != - 1 && ! detectIpad ( ) && ! detectIpod ( ) ) { return true ; } return false ;


signature:
public class UserAgentUtil { /** * Detects * any * Android OS - based device : phone , tablet , and multi - media player . Also detects Google TV .
 * @ return detection of an Android device */
public boolean detectAndroid ( ) { } }

implementation:
if ( ( this . initCompleted == true ) || ( this . isAndroid == true ) ) return this . isAndroid ; if ( ( userAgent . indexOf ( deviceAndroid ) != - 1 ) || detectGoogleTV ( ) ) return true ; // Special check for the HTC Flyer 7 " tablet . It should report here .
if ( userAgent . indexOf ( deviceHtcFlyer ) != - 1 ) return true ; return false ;


signature:
public class UserAgentUtil { /** * Detects if the current device is a ( small - ish ) Android OS - based device used for calling and / or multi - media ( like a
 * Samsung Galaxy Player ) . Google says these devices will have ' Android ' AND ' mobile ' in user agent . Ignores tablets
 * ( Honeycomb and later ) .
 * @ return detection of an Android phone */
public boolean detectAndroidPhone ( ) { } }

implementation:
if ( ( this . initCompleted == true ) || ( this . isAndroidPhone == true ) ) return this . isAndroidPhone ; if ( detectAndroid ( ) && ( userAgent . indexOf ( mobile ) != - 1 ) ) return true ; // Special check for Android phones with Opera Mobile . They should report here .
if ( detectOperaAndroidPhone ( ) ) return true ; // Special check for the HTC Flyer 7 " tablet . It should report here .
if ( userAgent . indexOf ( deviceHtcFlyer ) != - 1 ) return true ; return false ;


signature:
public class UserAgentUtil { /** * Detects if the current browser is based on WebKit .
 * @ return detection of a WebKit browser */
public boolean detectWebkit ( ) { } }

implementation: if ( ( this . initCompleted == true ) || ( this . isWebkit == true ) ) return this . isWebkit ; if ( userAgent . indexOf ( engineWebKit ) != - 1 ) { return true ; } return false ;


signature:
public class UserAgentUtil { /** * Detects if the current browser is a Windows Mobile device . Excludes Windows Phone 7 . x and 8 devices . Focuses on
 * Windows Mobile 6 . xx and earlier .
 * @ return detection of Windows Mobile */
public boolean detectWindowsMobile ( ) { } }

implementation:
if ( detectWindowsPhone ( ) ) { return false ; } // Most devices use ' Windows CE ' , but some report ' iemobile '
// and some older ones report as ' PIE ' for Pocket IE .
// We also look for instances of HTC and Windows for many of their WinMo devices .
if ( userAgent . indexOf ( deviceWinMob ) != - 1 || userAgent . indexOf ( deviceWinMob ) != - 1 || userAgent . indexOf ( deviceIeMob ) != - 1 || userAgent . indexOf ( enginePie ) != - 1 || ( userAgent . indexOf ( manuHtc ) != - 1 && userAgent . indexOf ( deviceWindows ) != - 1 ) || ( detectWapWml ( ) && userAgent . indexOf ( deviceWindows ) != - 1 ) ) { return true ; } // Test for Windows Mobile PPC but not old Macintosh PowerPC .
if ( userAgent . indexOf ( devicePpc ) != - 1 && ! ( userAgent . indexOf ( deviceMacPpc ) != - 1 ) ) return true ; return false ;


signature:
public class UserAgentUtil { /** * Detects if the current browser is any BlackBerry . Includes BB10 OS , but excludes the PlayBook .
 * @ return detection of Blackberry */
public boolean detectBlackBerry ( ) { } }

implementation: if ( userAgent . indexOf ( deviceBB ) != - 1 || httpAccept . indexOf ( vndRIM ) != - 1 ) return true ; if ( detectBlackBerry10Phone ( ) ) return true ; return false ;


signature:
public class UserAgentUtil { /** * Detects if the current browser is the Symbian S60 Open Source Browser .
 * @ return detection of Symbian S60 Browser */
public boolean detectS60OssBrowser ( ) { } }

implementation:
// First , test for WebKit , then make sure it ' s either Symbian or S60.
if ( detectWebkit ( ) && ( userAgent . indexOf ( deviceSymbian ) != - 1 || userAgent . indexOf ( deviceS60 ) != - 1 ) ) { return true ; } return false ;


signature:
public class UserAgentUtil { /** * Detects if the current browser is on a PalmOS device .
 * @ return detection of a PalmOS device */
public boolean detectPalmOS ( ) { } }

implementation:
// Make sure it ' s not WebOS first
if ( detectPalmWebOS ( ) ) return false ; // Most devices nowadays report as ' Palm ' , but some older ones reported as Blazer or Xiino .
if ( userAgent . indexOf ( devicePalm ) != - 1 || userAgent . indexOf ( engineBlazer ) != - 1 || userAgent . indexOf ( engineXiino ) != - 1 ) { return true ; } return false ;


signature:
public class UserAgentUtil { /** * Detects Opera Mobile on an Android phone .
 * @ return detection of an Opera browser on an Android phone */
public boolean detectOperaAndroidPhone ( ) { } }

implementation: if ( userAgent . indexOf ( engineOpera ) != - 1 && ( userAgent . indexOf ( deviceAndroid ) != - 1 && userAgent . indexOf ( mobi ) != - 1 ) ) { return true ; } return false ;


signature:
public class UserAgentUtil { /** * Detects Opera Mobile on an Android tablet .
 * @ return detection of an Opera browser on an Android tablet */
public boolean detectOperaAndroidTablet ( ) { } }

implementation: if ( userAgent . indexOf ( engineOpera ) != - 1 && ( userAgent . indexOf ( deviceAndroid ) != - 1 && userAgent . indexOf ( deviceTablet ) != - 1 ) ) { return true ; } return false ;


signature:
public class UserAgentUtil { /** * Detects if the current device is on one of the Maemo - based Nokia Internet Tablets .
 * @ return detection of a Maemo OS tablet */
public boolean detectMaemoTablet ( ) { } }

implementation: if ( userAgent . indexOf ( maemo ) != - 1 ) { return true ; } else if ( userAgent . indexOf ( linux ) != - 1 && userAgent . indexOf ( deviceTablet ) != - 1 && ! detectWebOSTablet ( ) && ! detectAndroid ( ) ) { return true ; } return false ;


signature:
public class UserAgentUtil { /** * Detects if the current device is a mobile device . This method catches most of the popular modern devices . Excludes
 * Apple iPads and other modern tablets .
 * @ return detection of any mobile device using the quicker method */
public boolean detectMobileQuick ( ) { } }

implementation:
// Let ' s exclude tablets
if ( detectTierTablet ( ) ) return false ; if ( ( initCompleted == true ) || ( isMobilePhone == true ) ) return isMobilePhone ; // Most mobile browsing is done on smartphones
if ( detectSmartphone ( ) ) return true ; if ( detectWapWml ( ) || detectBrewDevice ( ) || detectOperaMobile ( ) ) return true ; if ( ( userAgent . indexOf ( engineObigo ) != - 1 ) || ( userAgent . indexOf ( engineNetfront ) != - 1 ) || ( userAgent . indexOf ( engineUpBrowser ) != - 1 ) || ( userAgent . indexOf ( engineOpenWeb ) != - 1 ) ) return true ; if ( detectDangerHiptop ( ) || detectMidpCapable ( ) || detectMaemoTablet ( ) || detectArchos ( ) ) return true ; if ( ( userAgent . indexOf ( devicePda ) != - 1 ) && ( userAgent . indexOf ( disUpdate ) < 0 ) ) // no index found
return true ; if ( userAgent . indexOf ( mobile ) != - 1 ) return true ; // We also look for Kindle devices
if ( detectKindle ( ) || detectAmazonSilk ( ) ) return true ; return false ;


signature:
public class UserAgentUtil { /** * The longer and more thorough way to detect for a mobile device . Will probably detect most feature phones ,
 * smartphone - class devices , Internet Tablets , Internet - enabled game consoles , etc . This ought to catch a lot of the
 * more obscure and older devices , also - - but no promises on thoroughness !
 * @ return detection of any mobile device using the more thorough method */
public boolean detectMobileLong ( ) { } }

implementation:
if ( detectMobileQuick ( ) || detectGameConsole ( ) || detectSonyMylo ( ) ) { return true ; } // detect older phones from certain manufacturers and operators .
if ( userAgent . indexOf ( uplink ) != - 1 ) return true ; if ( userAgent . indexOf ( manuSonyEricsson ) != - 1 ) return true ; if ( userAgent . indexOf ( manuericsson ) != - 1 ) return true ; if ( userAgent . indexOf ( manuSamsung1 ) != - 1 ) return true ; if ( userAgent . indexOf ( svcDocomo ) != - 1 ) return true ; if ( userAgent . indexOf ( svcKddi ) != - 1 ) return true ; if ( userAgent . indexOf ( svcVodafone ) != - 1 ) return true ; return false ;


signature:
public class UserAgentUtil { /** * The quick way to detect for a tier of devices . This method detects for the new generation of HTML 5 capable ,
 * larger screen tablets . Includes iPad , Android ( e . g . , Xoom ) , BB Playbook , WebOS , etc .
 * @ return detection of any device in the Tablet Tier */
public boolean detectTierTablet ( ) { } }

implementation: if ( ( this . initCompleted == true ) || ( this . isTierTablet == true ) ) return this . isTierTablet ; if ( detectIpad ( ) || detectAndroidTablet ( ) || detectBlackBerryTablet ( ) || detectWebOSTablet ( ) ) { return true ; } return false ;


signature:
public class UserAgentUtil { /** * The quick way to detect for a tier of devices . This method detects for devices which can display iPhone - optimized
 * web content . Includes iPhone , iPod Touch , Android , Windows Phone 7 and 8 , BB10 , WebOS , Playstation Vita , etc .
 * @ return detection of any device in the iPhone / Android / Windows Phone / BlackBerry / WebOS Tier */
public boolean detectTierIphone ( ) { } }

implementation: if ( ( this . initCompleted == true ) || ( this . isTierIphone == true ) ) return this . isTierIphone ; if ( detectIphoneOrIpod ( ) || detectAndroidPhone ( ) || detectWindowsPhone ( ) || detectBlackBerry10Phone ( ) || ( detectBlackBerryWebKit ( ) && detectBlackBerryTouch ( ) ) || detectPalmWebOS ( ) || detectBada ( ) || detectTizen ( ) || detectGamingHandheld ( ) ) { return true ; } return false ;


signature:
public class UserAgentUtil { /** * The quick way to detect for a tier of devices . This method detects for all other types of phones , but excludes the
 * iPhone and RichCSS Tier devices .
 * @ return detection of a mobile device in the less capable tier */
public boolean detectTierOtherPhones ( ) { } }

implementation:
if ( ( this . initCompleted == true ) || ( this . isTierGenericMobile == true ) ) return this . isTierGenericMobile ; // Exclude devices in the other 2 categories
if ( detectMobileLong ( ) && ! detectTierIphone ( ) && ! detectTierRichCss ( ) ) return true ; return false ;


signature:
public class PrettyURLBuilder { /** * Extract any { @ link UIParameter } objects from a given component . These
 * parameters are what PrettyFaces uses to communicate with the JSF component
 * tree
 * @ param component
 * @ return A list of { @ link UIParameter } objects , or an empty list if no
 * { @ link UIParameter } s were contained within the component children . */
public List < UIParameter > extractParameters ( final UIComponent component ) { } }

implementation: List < UIParameter > results = new ArrayList < UIParameter > ( ) ; for ( UIComponent child : component . getChildren ( ) ) { if ( child instanceof UIParameter ) { final UIParameter param = ( UIParameter ) child ; if ( ! param . isDisable ( ) ) { results . add ( param ) ; } } } return results ;


signature:
public class PrettyURLBuilder { /** * Build a Pretty URL for the given UrlMapping and parameters .
 * @ deprecated Use { @ link # build ( UrlMapping , boolean , Map ) } instead . */
@ Deprecated public String build ( final UrlMapping mapping , final Map < String , String [ ] > parameters ) { } }

implementation: return build ( mapping , false , parameters ) ;


signature:
public class PrettyURLBuilder { /** * Build a Pretty URL for the given UrlMapping and parameters .
 * @ since 3.2.0 */
public String build ( final UrlMapping mapping , final boolean encodeUrl , final Map < String , String [ ] > parameters ) { } }

implementation: List < UIParameter > list = new ArrayList < UIParameter > ( ) ; if ( parameters != null ) { for ( Entry < String , String [ ] > e : parameters . entrySet ( ) ) { UIParameter p = new UIParameter ( ) ; p . setName ( e . getKey ( ) ) ; p . setValue ( e . getValue ( ) ) ; list . add ( p ) ; } } return build ( mapping , false , list ) ;


signature:
public class PrettyURLBuilder { /** * Build a Pretty URL for the given UrlMapping and parameters .
 * @ deprecated Use { @ link # build ( UrlMapping , boolean , Object . . . ) } instead . */
@ Deprecated public String build ( final UrlMapping mapping , final Object ... parameters ) { } }


signature:
public class PrettyURLBuilder { /** * Build a Pretty URL for the given UrlMapping and parameters .
 * @ since 3.2.0 */
public String build ( final UrlMapping mapping , final boolean encodeUrl , final Object ... parameters ) { } }

implementation: List < UIParameter > list = new ArrayList < UIParameter > ( ) ; if ( parameters != null ) { for ( Object e : parameters ) { UIParameter p = new UIParameter ( ) ; if ( e != null ) { p . setValue ( e . toString ( ) ) ; } list . add ( p ) ; } } return build ( mapping , encodeUrl , list ) ;


signature:
public class PrettyURLBuilder { /** * Build a Pretty URL for the given UrlMapping and parameters .
 * @ deprecated Use { @ link # build ( UrlMapping , boolean , RequestParameter . . . ) } instead . */
@ Deprecated public String build ( final UrlMapping mapping , final RequestParameter ... parameters ) { } }


signature:
public class PrettyURLBuilder { /** * Build a Pretty URL for the given UrlMapping and parameters .
 * @ since 3.2.0 */
public String build ( final UrlMapping mapping , final boolean encodeUrl , final RequestParameter ... parameters ) { } }

implementation: List < UIParameter > list = new ArrayList < UIParameter > ( ) ; if ( parameters != null ) { for ( RequestParameter param : parameters ) { UIParameter p = new UIParameter ( ) ; if ( param != null ) { p . setValue ( param . getName ( ) ) ; p . setValue ( param . getValue ( ) ) ; } list . add ( p ) ; } } return build ( mapping , false , list ) ;


signature:
public class PrettyURLBuilder { /** * Build a Pretty URL for the given Mapping ID and parameters .
 * @ deprecated Use { @ link # build ( UrlMapping , boolean , List ) } instead . */
@ Deprecated public String build ( final UrlMapping urlMapping , final List < UIParameter > parameters ) { } }

implementation: return build ( urlMapping , false , parameters ) ;


signature:
public class PrettyURLBuilder { /** * Build a Pretty URL for the given Mapping ID and parameters .
 * @ since 3.2.0 */
public String build ( final UrlMapping urlMapping , final boolean encodeUrl , final List < UIParameter > parameters ) { } }

implementation:
String result = "" ; if ( urlMapping != null ) { URLPatternParser parser = urlMapping . getPatternParser ( ) ; List < String > pathParams = new ArrayList < String > ( ) ; List < QueryParameter > queryParams = new ArrayList < QueryParameter > ( ) ; if ( parameters != null ) { // TODO this logic should be in the components , not in the builder
if ( parameters . size ( ) == 1 ) { UIParameter firstParam = parameters . get ( 0 ) ; if ( ( ( firstParam . getValue ( ) != null ) ) && ( firstParam . getName ( ) == null ) ) { if ( firstParam . getValue ( ) instanceof List < ? > ) { URL url = parser . getMappedURL ( firstParam . getValue ( ) ) ; return url . toURL ( ) ; } else if ( firstParam . getValue ( ) . getClass ( ) . isArray ( ) ) { // The Object [ ] cast here is required , otherwise Java treats
// getValue ( ) as a single Object .
List < Object > list = Arrays . asList ( ( Object [ ] ) firstParam . getValue ( ) ) ; URL url = parser . getMappedURL ( list ) ; return url . toURL ( ) ; } } } for ( UIParameter parameter : parameters ) { String name = parameter . getName ( ) ; Object value = parameter . getValue ( ) ; if ( ( name == null ) && ( value != null ) ) { pathParams . add ( value . toString ( ) ) ; } else { List < ? > values = null ; if ( ( value != null ) && value . getClass ( ) . isArray ( ) ) { values = Arrays . asList ( ( Object [ ] ) value ) ; } else if ( value instanceof List < ? > ) { values = ( List < ? > ) value ; } else if ( value != null ) { values = Arrays . asList ( value ) ; } if ( values != null ) { for ( Object object : values ) { String tempValue = null ; if ( object != null ) { tempValue = object . toString ( ) ; } queryParams . add ( new QueryParameter ( name , tempValue ) ) ; } } else { queryParams . add ( new QueryParameter ( name , null ) ) ; } } } } // build URL object for given path parameter set
URL mappedURL = parser . getMappedURL ( pathParams . toArray ( ) ) ; // create encoded / unicode URL
String url = encodeUrl ? mappedURL . encode ( ) . toURL ( ) : mappedURL . toURL ( ) ; // append query string
result = url + QueryString . build ( queryParams ) . toQueryString ( ) ; } return result ;


signature:
public class Expressions { /** * Return true if the value is an EL expression . */
public static boolean isEL ( final String value ) { } }

implementation: if ( value == null ) { return false ; } return elPattern . matcher ( value ) . matches ( ) ;


signature:
public class Expressions { /** * Return true if the value contains an EL expression . */
public static boolean containsEL ( final String value ) { } }

implementation: if ( value == null ) { return false ; } return elPattern . matcher ( value ) . find ( ) ;


signature:
public class RewriteWrappedRequest { /** * Get the current { @ link RewriteWrappedRequest } */
public static RewriteWrappedRequest getCurrentInstance ( ServletRequest request ) { } }

implementation: RewriteWrappedRequest wrapper = ( RewriteWrappedRequest ) request . getAttribute ( RewriteWrappedRequest . class . getName ( ) ) ; return wrapper ;


signature:
public class Instances { /** * Lookup an instance of the given { @ link Class } type . */
@ SuppressWarnings ( "unchecked" ) public static < T > T lookup ( Class < T > type ) { } }

implementation: if ( instanceProviders == null ) { instanceProviders = Iterators . asList ( ServiceLoader . load ( InstanceProvider . class ) ) ; Collections . sort ( instanceProviders , new WeightedComparator ( ) ) ; ServiceLogger . logLoadedServices ( log , InstanceProvider . class , instanceProviders ) ; } T result = null ; for ( InstanceProvider p : instanceProviders ) { result = ( T ) p . getInstance ( type ) ; if ( result != null ) { break ; } } return result ;


signature:
public class LocationBehavior { /** * Creates the required script for the supplied URL
 * @ param url The URL
 * @ return The script */
private String buildScriptInternal ( final String url ) { } }

implementation: StringBuilder builder = new StringBuilder ( ) ; builder . append ( "window.location.href = '" ) ; builder . append ( url ) ; builder . append ( "'; return false;" ) ; return builder . toString ( ) ;


signature:
public class RegexParameterizedPatternBuilder { /** * Extract bound values from configured { @ link Binding } instances . Return a { @ link Map } of the extracted key - value
 * pairs . Before storing the values in the map , this method applies the supplied { @ link Transposition } instance . */
private Map < String , Object > extractBoundValues ( final Rewrite event , final EvaluationContext context , Transposition < String > transposition ) { } }

implementation:
Map < String , Object > result = new LinkedHashMap < String , Object > ( ) ; for ( RegexGroup group : groups ) { Parameter < ? > parameter = store . get ( group . getName ( ) ) ; Object value = null ; // TODO TEST ME ! ! !
if ( context . getState ( ) . isEvaluating ( ) ) value = ( ( ParameterValueStore ) context . get ( ParameterValueStore . class ) ) . retrieve ( parameter ) ; if ( value == null || context . getState ( ) . isPerforming ( ) ) { Object retrieved = ParameterUtils . performRetrieval ( event , context , parameter ) ; if ( retrieved != null ) value = retrieved ; } if ( value == null ) throw new ParameterizationException ( "The value of required parameter [" + group . getName ( ) + "] was null." ) ; if ( transposition != null ) value = transposition . transpose ( event , context , value . toString ( ) ) ; result . put ( group . getName ( ) , value ) ; } return result ;


signature:
public class RuleBuilder { /** * Set the { @ link Condition } of this { @ link Rule } instance . */
public RuleBuilder when ( final Condition condition ) { } }

implementation: if ( this . condition == null ) this . condition = condition ; else if ( condition instanceof ConditionBuilder ) this . condition = ( ( ConditionBuilder ) this . condition ) . and ( condition ) ; else this . condition = Conditions . wrap ( this . condition ) . and ( condition ) ; return this ;


signature:
public class RuleBuilder { /** * Perform the given { @ link Operation } when the conditions set in this { @ link Rule } are met . */
public RuleBuilder perform ( final Operation operation ) { } }

implementation: if ( this . operation == null ) this . operation = operation ; else if ( operation instanceof OperationBuilder ) this . operation = ( ( OperationBuilder ) this . operation ) . and ( operation ) ; else this . operation = Operations . wrap ( this . operation ) . and ( operation ) ; return this ;


signature:
public class RuleBuilder { /** * Return the underlying { @ link ConditionBuilder } */
public DefaultConditionBuilder getConditionBuilder ( ) { } }

implementation: if ( condition == null ) condition = Conditions . create ( ) ; else if ( ! ( condition instanceof DefaultConditionBuilder ) ) condition = Conditions . wrap ( condition ) ; return ( DefaultConditionBuilder ) condition ;


signature:
public class RuleBuilder { /** * Return the underlying { @ link OperationBuilder } */
public DefaultOperationBuilder getOperationBuilder ( ) { } }

implementation: if ( operation == null ) operation = Operations . create ( ) ; else if ( ! ( operation instanceof DefaultOperationBuilder ) ) operation = Operations . wrap ( operation ) ; return ( DefaultOperationBuilder ) operation ;


signature:
public class ParseTools { /** * Return the index of the terminating character in the group , excluding markers . */
public static CapturingGroup balancedCapture ( final CharSequence path , final int startPos , final int endPos , final CaptureType type ) { } }

implementation: Assert . notNull ( path , "Character input array must not be null." ) ; Assert . assertTrue ( startPos >= 0 , "Start position must be greater than zero." ) ; Assert . assertTrue ( startPos < ( path . length ( ) - 1 ) , "Start position must be at least one character before the array upper bound." ) ; Assert . assertTrue ( endPos > 0 , "End position must be greater than zero." ) ; Assert . assertTrue ( endPos < path . length ( ) , "End position must be less than or equal to the array upper bound." ) ; Assert . assertTrue ( startPos < endPos , "Start position must be less than end position." ) ; Assert . assertTrue ( path . charAt ( startPos ) == type . getBegin ( ) , "Character at starting position was [" + path . charAt ( startPos ) + "] but expected [" + type . getBegin ( ) + "]" ) ; if ( ( startPos > 0 ) && ( path . charAt ( startPos - 1 ) == ESCAPE_CHAR ) ) { if ( ( startPos == 1 ) || ( ( startPos > 1 ) && ( path . charAt ( startPos - 2 ) != ESCAPE_CHAR ) ) ) { throw new IllegalArgumentException ( "Character at starting position is escaped, and cannot be used in capturing a group." ) ; } } int depth = 1 ; char begin = type . getBegin ( ) ; char term = type . getEnd ( ) ; int cursor = startPos + 1 ; while ( ( cursor < endPos ) && ( depth > 0 ) ) { if ( path . charAt ( cursor ) == term ) { if ( ! isEscaped ( path , cursor ) ) depth -- ; } else if ( path . charAt ( cursor ) == begin ) { if ( ! isEscaped ( path , cursor ) ) depth ++ ; } if ( depth == 0 ) { break ; } cursor ++ ; } return new CapturingGroup ( path , startPos , cursor ) ;


signature:
public class ParseTools { /** * Return true if the character at the given cursor is escaped ; otherwise , return false . */
public static boolean isEscaped ( final CharSequence path , final int cursor ) { } }

implementation: Assert . notNull ( path , "Character input array must not be null." ) ; Assert . assertTrue ( cursor >= 0 , "Start position must be greater than zero." ) ; Assert . assertTrue ( cursor < ( path . length ( ) ) , "Start position must be within the array upper bound." ) ; if ( ( cursor > 0 ) && ( path . charAt ( cursor - 1 ) == ESCAPE_CHAR ) ) { if ( ( cursor == 1 ) || ( ( cursor > 1 ) && ( path . charAt ( cursor - 2 ) != ESCAPE_CHAR ) ) ) { return true ; } } return false ;


signature:
public class Response { /** * Create an { @ link Operation } that adds the given { @ link ResponseContentInterceptor } instances to the current
 * { @ link ServletResponse } . This will activate response buffering on the current { @ link ServletRequest } - meaning
 * that generated output will not be sent to the client until the entire request has completed and all registered
 * { @ link ResponseContentInterceptor } instances have been executed on the outbound response content .
 * < b > WARNING : < / b > This will cause the < b > ENTIRE < / b > response to be buffered in memory , which may cause performance
 * issues on larger responses . Make sure you you really need to buffer the entire response ! Favor using a
 * { @ link ResponseStreamWrapper } if desired behavior may be performed as a stream operation ; this will result in far
 * less memory overhead .
 * @ throws IllegalStateException When output has already been written to the client . */
public static OperationBuilder withOutputInterceptedBy ( final ResponseContentInterceptor ... buffers ) throws IllegalStateException { } }

implementation: return new Response ( ) { @ Override public void performHttp ( HttpServletRewrite event , EvaluationContext context ) { for ( ResponseContentInterceptor buffer : buffers ) { RewriteWrappedResponse . getCurrentInstance ( event . getRequest ( ) ) . addContentInterceptor ( buffer ) ; } } @ Override public String toString ( ) { return "Response.withOutputInterceptedBy(" + Strings . join ( Arrays . asList ( buffers ) , ", " ) + ")" ; } } ;


signature:
public class Response { /** * Create an { @ link Operation } that adds the given { @ link ResponseStreamWrapper } instances to the current
 * { @ link ServletResponse } . This will activate response stream wrapping on the current { @ link ServletRequest } -
 * meaning response content will be piped through all registered { @ link ResponseStreamWrapper } instances as it is
 * written to the client { @ link ServletOutputStream } .
 * @ throws IllegalStateException When output has already been written to the client . */
public static OperationBuilder withOutputStreamWrappedBy ( final ResponseStreamWrapper ... wrappers ) throws IllegalStateException { } }

implementation: return new Response ( ) { @ Override public void performHttp ( HttpServletRewrite event , EvaluationContext context ) { for ( ResponseStreamWrapper wrapper : wrappers ) { RewriteWrappedResponse . getCurrentInstance ( event . getRequest ( ) ) . addStreamWrapper ( wrapper ) ; } } @ Override public String toString ( ) { return "Response.withOutputStreamWrappedBy(" + Strings . join ( Arrays . asList ( wrappers ) , ", " ) + ")" ; } } ;


signature:
public class Response { /** * Create an { @ link Operation } that adds a header to the { @ link HttpServletResponse } */
public static OperationBuilder addHeader ( final String name , final String value ) { } }

implementation: return new Response ( ) { @ Override public void performHttp ( final HttpServletRewrite event , final EvaluationContext context ) { event . getResponse ( ) . addHeader ( name , value ) ; } @ Override public String toString ( ) { return "Response.addHeader(\"" + name + "\", " + value + ")" ; } } ;


signature:
public class Response { /** * Create an { @ link Operation } that sets the content type for the { @ link HttpServletResponse } */
public static OperationBuilder setContentType ( final String contentType ) { } }

implementation: return new Response ( ) { @ Override public void performHttp ( final HttpServletRewrite event , final EvaluationContext context ) { event . getResponse ( ) . setContentType ( contentType ) ; } @ Override public String toString ( ) { return "Response.setContentType(\"" + contentType + "\")" ; } } ;


signature:
public class Response { /** * Create an { @ link Operation } that adds a { @ link Cookie } to the { @ link HttpServletResponse } */
public static OperationBuilder addCookie ( final Cookie cookie ) { } }

implementation: return new Response ( ) { @ Override public void performHttp ( final HttpServletRewrite event , final EvaluationContext context ) { event . getResponse ( ) . addCookie ( cookie ) ; } @ Override public String toString ( ) { return "Response.addCookie(" + cookie + ")" ; } } ;


signature:
public class Response { /** * Compress the { @ link ServletOutputStream } contents written to the client .
 * < b > WARNING < / b > : This causes response content to be buffered in memory in order to properly count the response
 * ' Content - Length ' . */
public static OperationBuilder gzipCompression ( ) { } }

implementation: return new Response ( ) { @ Override public void performHttp ( HttpServletRewrite event , EvaluationContext context ) { withOutputInterceptedBy ( new GZipResponseContentInterceptor ( ) ) . perform ( event , context ) ; } @ Override public String toString ( ) { return "Response.gzipCompression()" ; } } ;


signature:
public class Response { /** * Compress the { @ link ServletOutputStream } contents written to the client .
 * < b > WARNING < / b > : This means that the HTTP response will not contain a ' Content - Length ' header . */
public static OperationBuilder gzipStreamCompression ( ) { } }

implementation: return new Response ( ) { @ Override public void performHttp ( HttpServletRewrite event , EvaluationContext context ) { withOutputStreamWrappedBy ( new GZipResponseStreamWrapper ( ) ) . perform ( event , context ) ; } @ Override public String toString ( ) { return "Response.gzipCompression()" ; } } ;


signature:
public class Response { /** * Create an { @ link Operation } that writes the { @ link String } value of the given { @ link Object } to the current
 * { @ link HttpServletResponse } upon execution . The value to be written is obtained using { @ link Object # toString ( ) } . */
public static OperationBuilder write ( final Object value ) { } }

implementation: return new Response ( ) { @ Override public void performHttp ( final HttpServletRewrite event , final EvaluationContext context ) { try { if ( value != null ) event . getResponse ( ) . getWriter ( ) . write ( value . toString ( ) ) ; } catch ( IOException e ) { throw new RewriteException ( "Could not write value [" + value + "] to response stream." , e ) ; } } @ Override public String toString ( ) { return "Response.write(\"" + value + "\")" ; } } ;


signature:
public class Response { /** * Create an { @ link Operation } that writes the contents of the given { @ link InputStream } current
 * { @ link HttpServletResponse } upon execution . */
public static OperationBuilder write ( final InputStream stream ) { } }

implementation: return new HttpOperation ( ) { @ Override public void performHttp ( final HttpServletRewrite event , final EvaluationContext context ) { try { Streams . copy ( stream , event . getResponse ( ) . getOutputStream ( ) ) ; } catch ( IOException e ) { throw new RewriteException ( "Could not write stream [" + stream + "] to response stream." , e ) ; } } @ Override public String toString ( ) { return "Response.write(" + stream + ")" ; } } ;


signature:
public class Response { /** * Create an { @ link Operation } that sets the given status code via { @ link HttpServletResponse # setStatus ( int ) } . This
 * does not call { @ link HttpServletResponse # flushBuffer ( ) } */
public static OperationBuilder setStatus ( final int status ) { } }

implementation: return new HttpOperation ( ) { @ Override public void performHttp ( final HttpServletRewrite event , final EvaluationContext context ) { event . getResponse ( ) . setStatus ( status ) ; } @ Override public String toString ( ) { return "Response.setStatus(" + status + ")" ; } } ;


signature:
public class Response { /** * Create a { @ link Condition } that evaluates the status of { @ link HttpServletResponse # isCommitted ( ) } . */
public static ConditionBuilder isCommitted ( ) { } }

implementation: return new HttpCondition ( ) { @ Override public boolean evaluateHttp ( HttpServletRewrite event , EvaluationContext context ) { return event . getResponse ( ) . isCommitted ( ) ; } @ Override public String toString ( ) { return "Response.isCommitted()" ; } } ;


signature:
public class Stream { /** * Create an { @ link Operation } that streams the given { @ link File } to the
 * { @ link HttpServletResponse # getOutputStream ( ) } .
 * The given { @ link File } path may be parameterized :
 * < code >
 * new File ( " / tmp / file . txt " ) < br >
 * new File ( " c : \ tmp \ { param } . txt " ) < br >
 * < / code >
 * @ param location { @ link ParameterizedPattern } specifying the location of the { @ link File } .
 * @ see { @ link ConfigurationRuleParameterBuilder # where ( String ) } */
public static Stream from ( File file ) { } }

implementation: return new Stream ( file ) { @ Override public void performHttp ( HttpServletRewrite event , EvaluationContext context ) { InputStream stream = null ; try { File file = new File ( target . build ( event , context , Transpositions . encodePath ( ) ) ) ; stream = new BufferedInputStream ( new FileInputStream ( file ) ) ; log . debug ( "Streaming from file [" + file + "] to response." ) ; Response . write ( stream ) . perform ( event , context ) ; } catch ( Exception e ) { throw new RewriteException ( "Error streaming file." , e ) ; } finally { if ( stream != null ) try { stream . close ( ) ; } catch ( IOException e ) { throw new RewriteException ( "Error closing stream." , e ) ; } } } @ Override public String toString ( ) { return "Stream.from(\"" + target . getPattern ( ) + "\")" ; } } ;


signature:
public class Stream { /** * Create an { @ link Operation } that duplicates content written to { @ link HttpServletResponse # getOutputStream ( ) } and
 * writes it to the given { @ link File } . */
public static Operation to ( File file ) { } }

implementation: return new Stream ( file ) { @ Override public void performHttp ( HttpServletRewrite event , EvaluationContext context ) { final File file = new File ( target . build ( event , context , Transpositions . encodePath ( ) ) ) ; if ( ! file . exists ( ) ) { file . mkdirs ( ) ; file . delete ( ) ; try { file . createNewFile ( ) ; } catch ( IOException e ) { throw new RewriteException ( "Could not create file for Stream operation" , e ) ; } } Response . withOutputStreamWrappedBy ( new ResponseStreamWrapper ( ) { @ Override public OutputStream wrap ( HttpServletRewrite rewrite , OutputStream outputStream ) { try { BufferedOutputStream stream = new BufferedOutputStream ( new FileOutputStream ( file ) ) ; rewrite . getRequest ( ) . setAttribute ( STREAM_KEY , stream ) ; log . debug ( "Cloning response OutputStream to file [" + file + "]" ) ; return new MultiOutputStream ( stream , outputStream ) ; } catch ( FileNotFoundException e ) { throw new RewriteException ( "Could not wrap stream" , e ) ; } } @ Override public void finish ( HttpServletRewrite rewrite ) { try { OutputStream stream = ( OutputStream ) rewrite . getRequest ( ) . getAttribute ( STREAM_KEY ) ; if ( stream != null ) { log . debug ( "Closing cloned file [" + file + "] OutputStream" ) ; stream . flush ( ) ; stream . close ( ) ; } } catch ( Exception e ) { throw new RewriteException ( "Could not close stream" , e ) ; } } } ) . perform ( event , context ) ; } @ Override public String toString ( ) { return "Stream.to(\"" + target . getPattern ( ) + "\")" ; } } ;


signature:
public class El { /** * Create a new EL Method binding using distinct expressions to submit and retrieve values . The method intended for
 * use in submission must accept a single parameter of the expected type . */
public static El method ( final String retrieve , final String submit ) { } }

implementation: return new ElMethod ( new ConstantExpression ( retrieve ) , new ConstantExpression ( submit ) ) ;


signature:
public class El { /** * Create a new EL Method binding to retrieve values . This method allows the caller to supply the { @ link Class }
 * representing the type of the target object and the method name to refer to the method that should be invoked . */
public static El retrievalMethod ( final Class < ? > clazz , final String methodName ) { } }

implementation: return new ElMethod ( new TypeBasedExpression ( clazz , methodName ) , null ) ;


signature:
public class El { /** * Create a new EL Value binding using a single expression to submit and retrieve values . The specified property must
 * either be public , or have a publicly defined getter / setter . Instead of an EL expression this method expects the
 * { @ link Class } representing the type of the target object and the field name . The EL expression will be
 * automatically created at runtime . */
public static El property ( final Class < ? > clazz , final String fieldName ) { } }

implementation: return new ElProperty ( new TypeBasedExpression ( clazz , fieldName ) ) ;


signature:
public class El { /** * Create a new EL Value binding using a single expression to submit and retrieve values . The specified property must
 * either be public , or have a publicly defined getter / setter . */
public static El properties ( final String submit , final String retrieve ) { } }

implementation: return new ElProperties ( new ConstantExpression ( submit ) , new ConstantExpression ( retrieve ) ) ;


signature:
public class El { /** * Create a new EL Value binding using a single expression to submit and retrieve values . The specified property must
 * either be public , or have a publicly defined getter / setter . Instead of an EL expression this method expects a
 * { @ link Field } argument . The EL expression will be automatically created at runtime . */
public static El properties ( final Field submit , final Field retrieve ) { } }

implementation: return new ElProperties ( new TypeBasedExpression ( submit . getDeclaringClass ( ) , submit . getName ( ) ) , new TypeBasedExpression ( retrieve . getDeclaringClass ( ) , retrieve . getName ( ) ) ) ;


signature:
public class Query { /** * Create a { @ link Condition } matching the current { @ link Address # getQuery ( ) } .
 * The given pattern may be parameterized :
 * < code >
 * ? param = value < br >
 * ? param = { param } < br >
 * ? param = { param } & foo = bar < br >
 * < / code >
 * @ param pattern { @ link ParameterizedPattern } matching the query string of the current { @ link Address } .
 * @ see ConfigurationRuleParameterBuilder # where ( String ) */
public static Query matches ( final String query ) { } }

implementation: Assert . notNull ( query , "URL pattern must not be null." ) ; return new Query ( ) { private ParameterStore store ; final ParameterizedPatternParser pattern = new RegexParameterizedPatternParser ( query ) ; @ Override public boolean evaluateHttp ( final HttpServletRewrite event , final EvaluationContext context ) { String queryString = null ; if ( event instanceof InboundRewrite ) { queryString = event . getInboundAddress ( ) . getQuery ( ) ; } else if ( event instanceof HttpOutboundServletRewrite ) { queryString = ( ( HttpOutboundServletRewrite ) event ) . getOutboundAddress ( ) . getQuery ( ) ; } if ( pattern . parse ( queryString == null ? "" : queryString ) . submit ( event , context ) ) { ParameterValueStore values = ( ParameterValueStore ) context . get ( ParameterValueStore . class ) ; for ( Entry < Parameter < ? > , String > entry : pattern . parse ( query ) . getParameters ( context ) . entrySet ( ) ) { values . submit ( event , context , store . get ( entry . getKey ( ) . getName ( ) ) , entry . getValue ( ) ) ; } return true ; } return false ; } @ Override public String toString ( ) { return "Query.matches(\"" + query + "\")" ; } @ Override public Set < String > getRequiredParameterNames ( ) { return pattern . getRequiredParameterNames ( ) ; } @ Override public void setParameterStore ( ParameterStore store ) { pattern . setParameterStore ( store ) ; this . store = store ; } } ;


signature:
public class Query { /** * Create a { @ link Condition } asserting the existence of specific parameter names within the current
 * { @ link Address # getQuery ( ) }
 * The given parameter name is automatically parameterized :
 * < code >
 * Query . paramterExists ( " param " ) < br >
 * . . . < br / >
 * Forward . to ( " / { param } / page . jsp " )
 * < / code >
 * @ param pattern name of the { @ link Parameter } matching query parameter names within the current
 * { @ link Address # getQuery ( ) } .
 * @ see ConfigurationRuleParameterBuilder # where ( String ) */
public static Query parameterExists ( final String name ) { } }

implementation: Assert . notNull ( name , "Parameter name pattern must not be null." ) ; return new Query ( ) { final ParameterizedPatternParser pattern = new RegexParameterizedPatternParser ( "{" + name + "}" ) ; final String parameterName = name ; @ Override public boolean evaluateHttp ( final HttpServletRewrite event , final EvaluationContext context ) { QueryStringBuilder queryString = QueryStringBuilder . createFromEncoded ( event . getAddress ( ) . getQuery ( ) ) . decode ( ) ; for ( String name : queryString . getParameterNames ( ) ) { String [ ] parameterValues = queryString . getParameterValues ( name ) ; if ( parameterName . equals ( name ) ) { if ( parameterValues == null || ( parameterValues . length == 0 ) ) { return pattern . parse ( "" ) . matches ( ) ; } else { for ( String value : parameterValues ) { ParameterizedPatternResult parseResult = pattern . parse ( value ) ; if ( parseResult . matches ( ) ) { return parseResult . submit ( event , context ) ; } } } } } return false ; } @ Override public String toString ( ) { return "Query.parameterExists(\"" + name + "\")" ; } @ Override public Set < String > getRequiredParameterNames ( ) { return pattern . getRequiredParameterNames ( ) ; } @ Override public void setParameterStore ( ParameterStore store ) { pattern . setParameterStore ( store ) ; } } ;


signature:
public class Query { /** * Create a { @ link Condition } asserting the existence of specific parameter values within the current
 * { @ link Address # getQuery ( ) } .
 * @ param pattern { @ link ParameterizedPattern } matching query parameter values of the current
 * { @ link Address # getQuery ( ) } .
 * @ see ConfigurationRuleParameterBuilder # where ( String ) */
public static Query valueExists ( final String valuePattern ) { } }

implementation: Assert . notNull ( valuePattern , "Parameter value pattern must not be null." ) ; return new Query ( ) { final ParameterizedPatternParser pattern = new RegexParameterizedPatternParser ( valuePattern ) ; @ Override public boolean evaluateHttp ( final HttpServletRewrite event , final EvaluationContext context ) { QueryStringBuilder queryString = QueryStringBuilder . createFromEncoded ( event . getAddress ( ) . getQuery ( ) ) . decode ( ) ; for ( String name : queryString . getParameterNames ( ) ) { for ( String value : queryString . getParameterValues ( name ) ) { if ( value != null && pattern . parse ( value ) . submit ( event , context ) ) { return true ; } } } return false ; } @ Override public String toString ( ) { return "Query.valueExists(\"" + valuePattern + "\")" ; } @ Override public Set < String > getRequiredParameterNames ( ) { return pattern . getRequiredParameterNames ( ) ; } @ Override public void setParameterStore ( ParameterStore store ) { pattern . setParameterStore ( store ) ; } } ;


signature:
public class LazyBeanNameFinder { /** * Find the bean name of the supplied class . This method will try to resolve the bean name by calling all registered
 * implementations of { @ link ELBeanNameResolver } . This method will either return the resolved name or throw an
 * { @ link IllegalStateException } , if no resolver knows the name of the bean .
 * @ param clazz The class of the bean
 * @ return The resolved bean name
 * @ throws IllegalStateException If the name of the bean cannot be resolved */
public String findBeanName ( Class < ? > clazz ) throws IllegalStateException { } }

implementation:
// process all resolvers
for ( BeanNameResolver resolver : resolvers ) { // try to resolve bean name with current resolver
String name = resolver . getBeanName ( clazz ) ; // return the bean name , if the resolver was successful
if ( name != null ) { return name ; } } // No resolver knows the name of the bean
throw new IllegalStateException ( "Cannot find name of bean '" + clazz . getName ( ) + "'! You should place a @URLBeanName annotation on this class to let PrettyFaces know its name." ) ;


signature:
public class Filesystem { /** * Create a { @ link Condition } that returns < code > true < / code > if the given { @ link File } exists in the file - system of
 * the host environment , and is a normal file .
 * The given file path may be parameterized :
 * < code >
 * new File ( " / tmp / file . txt " ) < br >
 * new File ( " c : \ tmp \ { param } . txt " ) < br >
 * < / code >
 * @ param location { @ link ParameterizedPattern } specifying the location of the { @ link File } .
 * @ see { @ link ConfigurationRuleParameterBuilder # where ( String ) } */
public static Filesystem fileExists ( final File resource ) { } }

implementation: return new Filesystem ( resource , new FileFilter ( ) { @ Override public boolean accept ( File file ) { return file . exists ( ) && file . isFile ( ) ; } @ Override public String toString ( ) { return "Filesystem.fileExists(" + resource . getAbsolutePath ( ) + ")" ; } } ) ;


signature:
public class Filesystem { /** * Create a { @ link Condition } that returns < code > true < / code > if the given { @ link File } exists in the file - system of
 * the host environment , and is a directory .
 * The given file path may be parameterized :
 * < code >
 * new File ( " / tmp / directory / " ) < br >
 * new File ( " c : \ tmp \ { param } " ) < br >
 * < / code >
 * @ param location { @ link ParameterizedPattern } specifying the location of the directory .
 * @ see { @ link ConfigurationRuleParameterBuilder # where ( String ) } */
public static Filesystem directoryExists ( final File resource ) { } }

implementation: return new Filesystem ( resource , new FileFilter ( ) { @ Override public boolean accept ( File file ) { return file . exists ( ) && file . isDirectory ( ) ; } @ Override public String toString ( ) { return "Filesystem.directoryExists(" + resource . getAbsolutePath ( ) + ")" ; } } ) ;


signature:
public class URL { /** * Get a list of all decoded segments ( separated by ' / ' ) in this URL . */
public List < String > getDecodedSegments ( ) { } }

implementation: String encoding = metadata . getEncoding ( ) ; if ( ! decodedSegments . containsKey ( encoding ) ) { List < String > result = new ArrayList < String > ( ) ; for ( String segment : segments ) { result . add ( Decoder . path ( segment ) ) ; } decodedSegments . put ( encoding , Collections . unmodifiableList ( result ) ) ; } return decodedSegments . get ( encoding ) ;


signature:
public class URL { /** * Get a list of all encoded segments ( separated by ' / ' ) in this URL . */
public List < String > getEncodedSegments ( ) { } }

implementation: List < String > resultSegments = new ArrayList < String > ( ) ; for ( String segment : segments ) { resultSegments . add ( Encoder . path ( segment ) ) ; } return resultSegments ;


signature:
public class FacesExpressionLanguageProvider { /** * Creates an { @ link ValueExpression } for the supplied EL expression */
private ValueExpression getValueExpression ( FacesContext facesContext , String expression ) { } }

implementation: String el = toELExpression ( expression ) ; ExpressionFactory expressionFactory = facesContext . getApplication ( ) . getExpressionFactory ( ) ; return expressionFactory . createValueExpression ( facesContext . getELContext ( ) , el , Object . class ) ;


signature:
public class FacesExpressionLanguageProvider { /** * Obtains the { @ link FacesContext } using { @ link FacesContext # getCurrentInstance ( ) } . This method will throw an
 * { @ link IllegalArgumentException } if the { @ link FacesContext } is not available . */
private FacesContext getFacesContext ( ) { } }

implementation: FacesContext facesContext = FacesContext . getCurrentInstance ( ) ; if ( facesContext == null ) { throw new IllegalArgumentException ( "FacesContext.getCurrentInstance() returned null. EL expressions can only be evaluated in the JSF lifecycle. " + "You should use PhaseAction and PhaseBinding to perform a deferred operation instead." ) ; } return facesContext ;


signature:
public class FacesExpressionLanguageProvider { /** * Adds # { . . } to the expression if required */
private String toELExpression ( String s ) { } }

implementation: if ( s != null && ! s . startsWith ( "#{" ) ) { return "#{" + s + "}" ; } return s ;


signature:
public class RewriteEngine { /** * Rewrite the given URL using the provided { @ link RewriteRule } object as a set of rules .
 * @ return The rewritten URL , or the unchanged URL if no action was taken . */
public String processInbound ( final HttpServletRequest request , final HttpServletResponse response , final RewriteRule rule , final String url ) { } }

implementation: String result = url ; if ( ( rule != null ) && rule . isInbound ( ) && rule . matches ( url ) ) { for ( Processor p : processors ) { result = p . processInbound ( request , response , rule , result ) ; } } return result ;


signature:
public class RewriteEngine { /** * Rewrite the given URL using the provided { @ link RewriteRule } object . Process the URL only if the rule is set to
 * outbound = " true "
 * @ return The rewritten URL , or the unchanged URL if no action was taken . */
public String processOutbound ( final HttpServletRequest request , final HttpServletResponse response , final RewriteRule rule , final String url ) { } }

implementation: String result = url ; if ( ( rule != null ) && rule . isOutbound ( ) && rule . matches ( url ) ) { for ( Processor p : processors ) { result = p . processOutbound ( request , response , rule , result ) ; } } return result ;


signature:
public class SubflowTask { /** * Perform the given { @ link SubflowTask } using the given { @ link ServletRewrite } event . If modified , the original
 * { @ link ServletRewriteFlow } will be restored after task completion .
 * @ param event the { @ link ServletRewrite } event used in the given { @ link SubflowTask }
 * @ return the resultant { @ link ServletRewriteFlow } from the { @ link SubflowTask } execution . */
public static Flow perform ( ServletRewrite < ? , ? > rewrite , EvaluationContext context , SubflowTask subflowTask ) { } }

implementation: return perform ( rewrite , context , rewrite . getFlow ( ) , subflowTask ) ;


signature:
public class SubflowTask { /** * Perform the given { @ link SubflowTask } using the given { @ link ServletRewrite } event initialized with a new
 * { @ link ServletRewriteFlow } . The original { @ link ServletRewriteFlow } will be restored after task completion .
 * @ param event the { @ link ServletRewrite } event used in the given { @ link SubflowTask }
 * @ param subflow the { @ link ServletRewriteFlow } to be us as the initial state for the given { @ link SubflowTask }
 * @ return the resultant { @ link ServletRewriteFlow } from the { @ link SubflowTask } execution . */
public static Flow perform ( ServletRewrite < ? , ? > event , EvaluationContext context , Flow subflow , SubflowTask subflowTask ) { } }

implementation: Flow flow = event . getFlow ( ) ; try { event . setFlow ( subflow ) ; subflowTask . performInSubflow ( event , context ) ; return event . getFlow ( ) ; } finally { event . setFlow ( flow ) ; }


signature:
public class SpringExpressionLanguageProvider { /** * Lazily creates a StandardEvaluationContext . The code has been inspired by
 * { @ link StandardBeanExpressionResolver # evaluate ( String , BeanExpressionContext ) } */
public EvaluationContext getEvaluationContext ( ) { } }

implementation:
if ( _evaluationContext == null ) { // we need a ConfigurableBeanFactory to build the BeanExpressionContext
ConfigurableBeanFactory beanFactory = null ; // the WebApplicationContext MAY implement ConfigurableBeanFactory
if ( applicationContext instanceof ConfigurableBeanFactory ) { beanFactory = ( ConfigurableBeanFactory ) applicationContext ; } // the AutowireCapableBeanFactory usually implements ConfigurableListableBeanFactory
if ( beanFactory == null && applicationContext != null && applicationContext . getAutowireCapableBeanFactory ( ) instanceof ConfigurableBeanFactory ) { beanFactory = ( ConfigurableBeanFactory ) applicationContext . getAutowireCapableBeanFactory ( ) ; } // we cannot continue without a ConfigurableBeanFactory
if ( beanFactory == null ) { throw new IllegalStateException ( "Unable to find a ConfigurableBeanFactory" ) ; } BeanExpressionContext beanEvaluationContext = new BeanExpressionContext ( beanFactory , null ) ; StandardEvaluationContext sec = new StandardEvaluationContext ( ) ; sec . setRootObject ( beanEvaluationContext ) ; sec . addPropertyAccessor ( new BeanExpressionContextAccessor ( ) ) ; sec . addPropertyAccessor ( new BeanFactoryAccessor ( ) ) ; sec . addPropertyAccessor ( new MapAccessor ( ) ) ; sec . setBeanResolver ( new BeanFactoryResolver ( beanEvaluationContext . getBeanFactory ( ) ) ) ; sec . setTypeLocator ( new StandardTypeLocator ( beanEvaluationContext . getBeanFactory ( ) . getBeanClassLoader ( ) ) ) ; ConversionService conversionService = beanEvaluationContext . getBeanFactory ( ) . getConversionService ( ) ; if ( conversionService != null ) { sec . setTypeConverter ( new StandardTypeConverter ( conversionService ) ) ; } _evaluationContext = sec ; } return _evaluationContext ;