Input: Resolves and initializes bean definition . May be called multiple times . [CODESPLIT] protected void initBeanDefinition ( final BeanDefinition def ) { // init methods if ( def . initMethods == null ) { def . initMethods = petiteResolvers . resolveInitMethodPoint ( def . type ) ; } // destroy methods if ( def . destroyMethods == null ) { def . destroyMethods = petiteResolvers . resolveDestroyMethodPoint ( def . type ) ; } // properties if ( def . properties == null ) { def . properties = petiteResolvers . resolvePropertyInjectionPoint ( def . type , def . wiringMode == WiringMode . AUTOWIRE ) ; } // methods if ( def . methods == null ) { def . methods = petiteResolvers . resolveMethodInjectionPoint ( def . type ) ; } // ctors if ( def . ctor == null ) { def . ctor = petiteResolvers . resolveCtorInjectionPoint ( def . type ) ; } // values if ( def . values == null ) { def . values = paramManager . resolveParamInjectionPoints ( def . type ) ; } // sets if ( def . sets == null ) { def . sets = petiteResolvers . resolveSetInjectionPoint ( def . type , def . wiringMode == WiringMode . AUTOWIRE ) ; } // params if ( def . params == null ) { def . params = paramManager . filterParametersForBeanName ( def . name , petiteConfig . getResolveReferenceParameters ( ) ) ; } }


Input: Wires bean injects parameters and invokes init methods . Such a loooong name : ) [CODESPLIT] protected void registerBeanAndWireAndInjectParamsAndInvokeInitMethods ( final BeanData beanData ) { initBeanDefinition ( beanData . definition ( ) ) ; beanData . scopeRegister ( ) ; beanData . invokeInitMethods ( InitMethodInvocationStrategy . POST_CONSTRUCT ) ; beanData . wireBean ( ) ; beanData . invokeInitMethods ( InitMethodInvocationStrategy . POST_DEFINE ) ; beanData . injectParams ( paramManager , petiteConfig . isImplicitParamInjection ( ) ) ; beanData . invokeInitMethods ( InitMethodInvocationStrategy . POST_INITIALIZE ) ; beanData . invokeConsumerIfRegistered ( ) ; }


Input: Wires provided bean with the container and optionally invokes init methods . Bean is <b > not< / b > registered withing container . [CODESPLIT] public void wire ( final Object bean , final WiringMode wiringMode ) { final WiringMode finalWiringMode = petiteConfig . resolveWiringMode ( wiringMode ) ; final BeanDefinition def = externalsCache . get ( bean . getClass ( ) , ( ) -> { final BeanDefinition beanDefinition = createBeandDefinitionForExternalBeans ( bean . getClass ( ) , finalWiringMode ) ; initBeanDefinition ( beanDefinition ) ; return beanDefinition ; } ) ; registerBeanAndWireAndInjectParamsAndInvokeInitMethods ( new BeanData ( this , def , bean ) ) ; }


Input: Invokes the method of some bean with the container when its parameters requires to be injected into . The bean is <b > not< / b > registered within container . [CODESPLIT] public < T > T invokeMethod ( final Object bean , final Method method ) { final WiringMode wiringMode = petiteConfig . resolveWiringMode ( null ) ; final BeanDefinition def = externalsCache . get ( bean . getClass ( ) , ( ) -> { final BeanDefinition beanDefinition = createBeandDefinitionForExternalBeans ( bean . getClass ( ) , wiringMode ) ; initBeanDefinition ( beanDefinition ) ; return beanDefinition ; } ) ; final BeanData beanData = new BeanData ( this , def , bean ) ; for ( MethodInjectionPoint methodInjectionPoint : def . methods ) { if ( methodInjectionPoint . method . equals ( method ) ) { return ( T ) beanData . invokeMethodInjectionPoint ( methodInjectionPoint ) ; } } try { return ( T ) method . invoke ( bean ) ; } catch ( Exception e ) { throw new PetiteException ( e ) ; } }


Input: Creates and wires a bean within the container and optionally invokes init methods . However bean is <b > not< / b > registered . [CODESPLIT] @ SuppressWarnings ( { "unchecked" } ) public < E > E createBean ( final Class < E > type , final WiringMode wiringMode ) { final WiringMode finalWiringMode = petiteConfig . resolveWiringMode ( wiringMode ) ; final BeanDefinition def = externalsCache . get ( type , ( ) -> { final BeanDefinition beanDefinition = createBeandDefinitionForExternalBeans ( type , finalWiringMode ) ; initBeanDefinition ( beanDefinition ) ; return beanDefinition ; } ) ; final BeanData < E > beanData = new BeanData ( this , def ) ; registerBeanAndWireAndInjectParamsAndInvokeInitMethods ( beanData ) ; return beanData . bean ( ) ; }


Input: Invokes provider to get a bean . [CODESPLIT] protected Object invokeProvider ( final ProviderDefinition provider ) { if ( provider . method != null ) { final Object bean ; if ( provider . beanName != null ) { // instance factory method bean = getBean ( provider . beanName ) ; } else { // static factory method bean = null ; } try { return provider . method . invoke ( bean ) ; } catch ( Exception ex ) { throw new PetiteException ( "Invalid provider method: " + provider . method . getName ( ) , ex ) ; } } throw new PetiteException ( "Invalid provider" ) ; }


Input: Adds object instance to the container as singleton bean . [CODESPLIT] public void addBean ( final String name , final Object bean , WiringMode wiringMode ) { wiringMode = petiteConfig . resolveWiringMode ( wiringMode ) ; registerPetiteBean ( bean . getClass ( ) , name , SingletonScope . class , wiringMode , false , null ) ; BeanDefinition def = lookupExistingBeanDefinition ( name ) ; registerBeanAndWireAndInjectParamsAndInvokeInitMethods ( new BeanData ( this , def , bean ) ) ; }


Input: Sets petite bean property . [CODESPLIT] public void setBeanProperty ( final String name , final Object value ) { Object bean = null ; int ndx = name . length ( ) ; while ( true ) { ndx = name . lastIndexOf ( ' ' , ndx ) ; if ( ndx == - 1 ) { break ; } String beanName = name . substring ( 0 , ndx ) ; bean = getBean ( beanName ) ; if ( bean != null ) { break ; } ndx -- ; } if ( bean == null ) { throw new PetiteException ( "Invalid bean property: " + name ) ; } try { BeanUtil . declared . setProperty ( bean , name . substring ( ndx + 1 ) , value ) ; } catch ( Exception ex ) { throw new PetiteException ( "Invalid bean property: " + name , ex ) ; } }


Input: Returns petite bean property value . [CODESPLIT] public Object getBeanProperty ( final String name ) { int ndx = name . indexOf ( ' ' ) ; if ( ndx == - 1 ) { throw new PetiteException ( "Only bean name is specified, missing property name: " + name ) ; } String beanName = name . substring ( 0 , ndx ) ; Object bean = getBean ( beanName ) ; if ( bean == null ) { throw new PetiteException ( "Bean doesn't exist: " + name ) ; } try { return BeanUtil . declared . getProperty ( bean , name . substring ( ndx + 1 ) ) ; } catch ( Exception ex ) { throw new PetiteException ( "Invalid bean property: " + name , ex ) ; } }


Input: Shutdowns container . After container is down it can t be used anymore . [CODESPLIT] public void shutdown ( ) { scopes . forEachValue ( Scope :: shutdown ) ; externalsCache . clear ( ) ; beans . clear ( ) ; beansAlt . clear ( ) ; scopes . clear ( ) ; providers . clear ( ) ; beanCollections . clear ( ) ; }


Input: ---------------------------------------------------------------- properties [CODESPLIT] @ Override protected Properties createSessionProperties ( ) { final Properties props = super . createSessionProperties ( ) ; props . setProperty ( MAIL_TRANSPORT_PROTOCOL , PROTOCOL_SMTP ) ; props . setProperty ( MAIL_HOST , host ) ; props . setProperty ( MAIL_SMTP_HOST , host ) ; props . setProperty ( MAIL_SMTP_PORT , String . valueOf ( port ) ) ; if ( authenticator != null ) { props . setProperty ( MAIL_SMTP_AUTH , TRUE ) ; } if ( timeout > 0 ) { final String timeoutValue = String . valueOf ( timeout ) ; props . put ( MAIL_SMTP_CONNECTIONTIMEOUT , timeoutValue ) ; props . put ( MAIL_SMTP_TIMEOUT , timeoutValue ) ; props . put ( MAIL_SMTP_WRITETIMEOUT , timeoutValue ) ; } return props ; }


Input: { @inheritDoc } [CODESPLIT] @ Override public SendMailSession createSession ( ) { final Session session = Session . getInstance ( createSessionProperties ( ) , authenticator ) ; final Transport mailTransport ; try { mailTransport = getTransport ( session ) ; } catch ( final NoSuchProviderException nspex ) { throw new MailException ( nspex ) ; } return new SendMailSession ( session , mailTransport ) ; }


Input: ---------------------------------------------------------------- lifecycle [CODESPLIT] @ Override public void start ( ) { initLogger ( ) ; final String resourceName = StringUtil . replaceChar ( JoyPaths . class . getName ( ) , ' ' , ' ' ) + ".class" ; URL url = ClassLoaderUtil . getResourceUrl ( resourceName ) ; if ( url == null ) { throw new JoyException ( "Failed to resolve app dir, missing: " + resourceName ) ; } final String protocol = url . getProtocol ( ) ; if ( ! protocol . equals ( "file" ) ) { try { url = new URL ( url . getFile ( ) ) ; } catch ( MalformedURLException ignore ) { } } appDir = url . getFile ( ) ; final int ndx = appDir . indexOf ( "WEB-INF" ) ; appDir = ( ndx > 0 ) ? appDir . substring ( 0 , ndx ) : SystemUtil . info ( ) . getWorkingDir ( ) ; System . setProperty ( APP_DIR , appDir ) ; log . info ( "Application folder: " + appDir ) ; }


Input: Converts Jodd logging level to JDK . [CODESPLIT] private java . util . logging . Level jodd2jdk ( final Level level ) { switch ( level ) { case TRACE : return java . util . logging . Level . FINER ; case DEBUG : return java . util . logging . Level . FINE ; case INFO : return java . util . logging . Level . INFO ; case WARN : return java . util . logging . Level . WARNING ; case ERROR : return java . util . logging . Level . SEVERE ; default : throw new IllegalArgumentException ( ) ; } }


Input: { [CODESPLIT] @ Override public Double get ( final ResultSet rs , final int index , final int dbSqlType ) throws SQLException { return Double . valueOf ( rs . getDouble ( index ) ) ; }


Input: { [CODESPLIT] @ Override public void set ( final PreparedStatement st , final int index , final Double value , final int dbSqlType ) throws SQLException { st . setDouble ( index , value . doubleValue ( ) ) ; }


Input: Resolves method parameters from a method or constructor . Returns an empty array when target does not contain any parameter . No caching is involved in this process i . e . class bytecode is examined every time this method is called . [CODESPLIT] public static MethodParameter [ ] resolveParameters ( final AccessibleObject methodOrCtor ) { Class [ ] paramTypes ; Class declaringClass ; String name ; if ( methodOrCtor instanceof Method ) { Method method = ( Method ) methodOrCtor ; paramTypes = method . getParameterTypes ( ) ; name = method . getName ( ) ; declaringClass = method . getDeclaringClass ( ) ; } else { Constructor constructor = ( Constructor ) methodOrCtor ; paramTypes = constructor . getParameterTypes ( ) ; declaringClass = constructor . getDeclaringClass ( ) ; name = CTOR_METHOD ; } if ( paramTypes . length == 0 ) { return MethodParameter . EMPTY_ARRAY ; } InputStream stream ; try { stream = ClassLoaderUtil . getClassAsStream ( declaringClass ) ; } catch ( IOException ioex ) { throw new ParamoException ( "Failed to read class bytes: " + declaringClass . getName ( ) , ioex ) ; } if ( stream == null ) { throw new ParamoException ( "Class not found: " + declaringClass ) ; } try { ClassReader reader = new ClassReader ( stream ) ; MethodFinder visitor = new MethodFinder ( declaringClass , name , paramTypes ) ; reader . accept ( visitor , 0 ) ; return visitor . getResolvedParameters ( ) ; } catch ( IOException ioex ) { throw new ParamoException ( ioex ) ; } finally { StreamUtil . close ( stream ) ; } }


Input: Performs smart form population . [CODESPLIT] @ Override public int doAfterBody ( ) throws JspException { BodyContent body = getBodyContent ( ) ; JspWriter out = body . getEnclosingWriter ( ) ; String bodytext = populateForm ( body . getString ( ) , name -> value ( name , pageContext ) ) ; try { out . print ( bodytext ) ; } catch ( IOException ioex ) { throw new JspException ( ioex ) ; } return SKIP_BODY ; }


Input: Returns the property value with replaced macros . [CODESPLIT] public String getValue ( final String ... profiles ) { if ( hasMacro ) { return propsData . resolveMacros ( value , profiles ) ; } return value ; }


Input: Starts with DOM building . Creates root { [CODESPLIT] @ Override public void start ( ) { log . debug ( "DomTree builder started" ) ; if ( rootNode == null ) { rootNode = new Document ( domBuilder . config ) ; } parentNode = rootNode ; enabled = true ; if ( domBuilder . config . isEnabledVoidTags ( ) ) { htmlVoidRules = new HtmlVoidRules ( ) ; } }


Input: Finishes the tree building . Closes unclosed tags . [CODESPLIT] @ Override public void end ( ) { if ( parentNode != rootNode ) { Node thisNode = parentNode ; while ( thisNode != rootNode ) { if ( domBuilder . config . isImpliedEndTags ( ) ) { if ( implRules . implicitlyCloseTagOnEOF ( thisNode . getNodeName ( ) ) ) { thisNode = thisNode . getParentNode ( ) ; continue ; } } error ( "Unclosed tag closed: <" + thisNode . getNodeName ( ) + ">" ) ; thisNode = thisNode . getParentNode ( ) ; } } // remove whitespaces if ( domBuilder . config . isIgnoreWhitespacesBetweenTags ( ) ) { removeLastChildNodeIfEmptyText ( parentNode , true ) ; } // foster if ( domBuilder . config . isUseFosterRules ( ) ) { HtmlFosterRules fosterRules = new HtmlFosterRules ( ) ; fosterRules . fixFosterElements ( rootNode ) ; } // elapsed rootNode . end ( ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "LagartoDom tree created in " + rootNode . getElapsedTime ( ) + " ms" ) ; } }


Input: Creates new element with correct configuration . [CODESPLIT] protected Element createElementNode ( final Tag tag ) { boolean hasVoidTags = htmlVoidRules != null ; boolean isVoid = false ; boolean selfClosed = false ; if ( hasVoidTags ) { isVoid = htmlVoidRules . isVoidTag ( tag . getName ( ) ) ; // HTML and XHTML if ( isVoid ) { // it's void tag, lookup the flag selfClosed = domBuilder . config . isSelfCloseVoidTags ( ) ; } } else { // XML, no voids, lookup the flag selfClosed = domBuilder . config . isSelfCloseVoidTags ( ) ; } return new Element ( rootNode , tag , isVoid , selfClosed ) ; }


Input: Visits tags . [CODESPLIT] @ Override public void tag ( final Tag tag ) { if ( ! enabled ) { return ; } TagType tagType = tag . getType ( ) ; Element node ; switch ( tagType ) { case START : if ( domBuilder . config . isIgnoreWhitespacesBetweenTags ( ) ) { removeLastChildNodeIfEmptyText ( parentNode , false ) ; } node = createElementNode ( tag ) ; if ( domBuilder . config . isImpliedEndTags ( ) ) { while ( true ) { String parentNodeName = parentNode . getNodeName ( ) ; if ( ! implRules . implicitlyCloseParentTagOnNewTag ( parentNodeName , node . getNodeName ( ) ) ) { break ; } parentNode = parentNode . getParentNode ( ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Implicitly closed tag <" + node . getNodeName ( ) + "> " ) ; } } } parentNode . addChild ( node ) ; if ( ! node . isVoidElement ( ) ) { parentNode = node ; } break ; case END : if ( domBuilder . config . isIgnoreWhitespacesBetweenTags ( ) ) { removeLastChildNodeIfEmptyText ( parentNode , true ) ; } String tagName = tag . getName ( ) . toString ( ) ; Node matchingParent = findMatchingParentOpenTag ( tagName ) ; if ( matchingParent == parentNode ) { // regular situation parentNode = parentNode . getParentNode ( ) ; break ; } if ( matchingParent == null ) { // matching open tag not found, remove it error ( "Orphan closed tag ignored: </" + tagName + "> " + tag . getTagPosition ( ) ) ; break ; } // try to close it implicitly if ( domBuilder . config . isImpliedEndTags ( ) ) { boolean fixed = false ; while ( implRules . implicitlyCloseParentTagOnTagEnd ( parentNode . getNodeName ( ) , tagName ) ) { parentNode = parentNode . getParentNode ( ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Implicitly closed tag <" + tagName + ">" ) ; } if ( parentNode == matchingParent ) { parentNode = matchingParent . parentNode ; fixed = true ; break ; } } if ( fixed ) { break ; } } // matching tag found, but it is not a regular situation // therefore close all unclosed tags in between fixUnclosedTagsUpToMatchingParent ( tag , matchingParent ) ; break ; case SELF_CLOSING : if ( domBuilder . config . isIgnoreWhitespacesBetweenTags ( ) ) { removeLastChildNodeIfEmptyText ( parentNode , false ) ; } node = createElementNode ( tag ) ; parentNode . addChild ( node ) ; break ; } }


Input: Removes last child node if contains just empty text . [CODESPLIT] protected void removeLastChildNodeIfEmptyText ( final Node parentNode , final boolean closedTag ) { if ( parentNode == null ) { return ; } Node lastChild = parentNode . getLastChild ( ) ; if ( lastChild == null ) { return ; } if ( lastChild . getNodeType ( ) != Node . NodeType . TEXT ) { return ; } if ( closedTag ) { if ( parentNode . getChildNodesCount ( ) == 1 ) { return ; } } Text text = ( Text ) lastChild ; if ( text . isBlank ( ) ) { lastChild . detachFromParent ( ) ; } }


Input: Finds matching parent open tag or <code > null< / code > if not found . [CODESPLIT] protected Node findMatchingParentOpenTag ( String tagName ) { Node parent = parentNode ; if ( ! rootNode . config . isCaseSensitive ( ) ) { tagName = tagName . toLowerCase ( ) ; } while ( parent != null ) { String parentNodeName = parent . getNodeName ( ) ; if ( parentNodeName != null ) { if ( ! rootNode . config . isCaseSensitive ( ) ) { parentNodeName = parentNodeName . toLowerCase ( ) ; } } if ( tagName . equals ( parentNodeName ) ) { return parent ; } parent = parent . getParentNode ( ) ; } return null ; }


Input: Fixes all unclosed tags up to matching parent . Missing end tags will be added just before parent tag is closed making the whole inner content as its tag body . <p > Tags that can be closed implicitly are checked and closed . <p > There is optional check for detecting orphan tags inside the table or lists . If set tags can be closed beyond the border of the table and the list and it is reported as orphan tag . <p > This is just a generic solutions closest to the rules . [CODESPLIT] protected void fixUnclosedTagsUpToMatchingParent ( final Tag tag , final Node matchingParent ) { if ( domBuilder . config . isUnclosedTagAsOrphanCheck ( ) ) { Node thisNode = parentNode ; if ( ! CharSequenceUtil . equalsIgnoreCase ( tag . getName ( ) , "table" ) ) { // check if there is table or list between this node // and matching parent while ( thisNode != matchingParent ) { String thisNodeName = thisNode . getNodeName ( ) . toLowerCase ( ) ; if ( thisNodeName . equals ( "table" ) || thisNodeName . equals ( "ul" ) || thisNodeName . equals ( "ol" ) ) { String positionString = tag . getPosition ( ) ; if ( positionString == null ) { positionString = StringPool . EMPTY ; } error ( "Orphan closed tag ignored: </" + tag . getName ( ) + "> " + positionString ) ; return ; } thisNode = thisNode . getParentNode ( ) ; } } } while ( true ) { if ( parentNode == matchingParent ) { parentNode = parentNode . getParentNode ( ) ; break ; } Node parentParentNode = parentNode . getParentNode ( ) ; if ( domBuilder . config . isImpliedEndTags ( ) ) { if ( implRules . implicitlyCloseParentTagOnNewTag ( parentParentNode . getNodeName ( ) , parentNode . getNodeName ( ) ) ) { // break the tree: detach this node and append it after parent parentNode . detachFromParent ( ) ; parentParentNode . getParentNode ( ) . addChild ( parentNode ) ; } } // debug message error ( "Unclosed tag closed: <" + parentNode . getNodeName ( ) + ">" ) ; // continue looping parentNode = parentParentNode ; } }


Input: ---------------------------------------------------------------- tree [CODESPLIT] @ Override public void script ( final Tag tag , final CharSequence body ) { if ( ! enabled ) { return ; } Element node = createElementNode ( tag ) ; parentNode . addChild ( node ) ; if ( body . length ( ) != 0 ) { Node text = new Text ( rootNode , body . toString ( ) ) ; node . addChild ( text ) ; } }


Input: ---------------------------------------------------------------- error [CODESPLIT] @ Override public void error ( final String message ) { rootNode . addError ( message ) ; log . log ( domBuilder . config . getParsingErrorLogLevel ( ) , message ) ; }


Input: Returns argument index from the history . <b > Must< / b > POP value from the stack after the execution . [CODESPLIT] protected int getArgumentIndex ( ) { if ( ! isPrevious ) { throw new ProxettaException ( "Unexpected previous instruction type used for setting argument index" ) ; } int argIndex ; switch ( opcode ) { case ICONST_0 : argIndex = 0 ; break ; case ICONST_1 : argIndex = 1 ; break ; case ICONST_2 : argIndex = 2 ; break ; case ICONST_3 : argIndex = 3 ; break ; case ICONST_4 : argIndex = 4 ; break ; case ICONST_5 : argIndex = 5 ; break ; case BIPUSH : case SIPUSH : argIndex = operand ; break ; default : throw new ProxettaException ( "Unexpected previous instruction used for setting argument index" ) ; } return argIndex ; }


Input: ---------------------------------------------------------------- visitors [CODESPLIT] @ Override public void visitInsn ( final int opcode ) { this . opcode = opcode ; isPrevious = true ; traceNext = false ; super . visitInsn ( opcode ) ; }


Input: Visits replacement code for { [CODESPLIT] public static void argumentsCount ( final MethodVisitor mv , final MethodInfo methodInfo ) { int argsCount = methodInfo . getArgumentsCount ( ) ; pushInt ( mv , argsCount ) ; }


Input: Visits replacement code for { [CODESPLIT] public static void argumentType ( final MethodVisitor mv , final MethodInfo methodInfo , final int argIndex ) { checkArgumentIndex ( methodInfo , argIndex ) ; mv . visitInsn ( POP ) ; loadMethodArgumentClass ( mv , methodInfo , argIndex ) ; }


Input: Visits replacement code for { [CODESPLIT] public static void argument ( final MethodVisitor mv , final MethodInfo methodInfo , final int argIndex ) { checkArgumentIndex ( methodInfo , argIndex ) ; mv . visitInsn ( POP ) ; loadMethodArgumentAsObject ( mv , methodInfo , argIndex ) ; }


Input: Visits replacement code for { [CODESPLIT] public static void createArgumentsArray ( final MethodVisitor mv , final MethodInfo methodInfo ) { int argsCount = methodInfo . getArgumentsCount ( ) ; pushInt ( mv , argsCount ) ; mv . visitTypeInsn ( ANEWARRAY , AsmUtil . SIGNATURE_JAVA_LANG_OBJECT ) ; for ( int i = 0 ; i < argsCount ; i ++ ) { mv . visitInsn ( DUP ) ; pushInt ( mv , i ) ; loadMethodArgumentAsObject ( mv , methodInfo , i + 1 ) ; mv . visitInsn ( AASTORE ) ; } }


Input: Visits replacement code for { [CODESPLIT] public static void createArgumentsClassArray ( final MethodVisitor mv , final MethodInfo methodInfo ) { int argsCount = methodInfo . getArgumentsCount ( ) ; pushInt ( mv , argsCount ) ; mv . visitTypeInsn ( ANEWARRAY , AsmUtil . SIGNATURE_JAVA_LANG_CLASS ) ; for ( int i = 0 ; i < argsCount ; i ++ ) { mv . visitInsn ( DUP ) ; pushInt ( mv , i ) ; loadMethodArgumentClass ( mv , methodInfo , i + 1 ) ; mv . visitInsn ( AASTORE ) ; } }


Input: Visits replacement code for { [CODESPLIT] public static void returnType ( final MethodVisitor mv , final MethodInfo methodInfo ) { ProxettaAsmUtil . loadClass ( mv , methodInfo . getReturnType ( ) . getOpcode ( ) , methodInfo . getReturnType ( ) . getName ( ) ) ; }


Input: Visits replacement code for { [CODESPLIT] public static void targetClass ( final MethodVisitor mv , final MethodInfo methodInfo ) { ClassInfo classInfo = methodInfo . getClassInfo ( ) ; mv . visitLdcInsn ( Type . getType ( ' ' + classInfo . getReference ( ) + ' ' ) ) ; }


Input: Visits replacement code for { [CODESPLIT] public static void info ( final MethodVisitor mv , final MethodInfo methodInfo , final int argsOff ) { mv . visitTypeInsn ( Opcodes . NEW , PROXY_TARGET_INFO ) ; mv . visitInsn ( DUP ) ; mv . visitMethodInsn ( Opcodes . INVOKESPECIAL , PROXY_TARGET_INFO , "<init>" , "()V" , false ) ; //		int argsOff = methodInfo.getAllArgumentsSize(); //		argsOff++; mv . visitVarInsn ( Opcodes . ASTORE , argsOff ) ; // argument count mv . visitVarInsn ( Opcodes . ALOAD , argsOff ) ; argumentsCount ( mv , methodInfo ) ; mv . visitFieldInsn ( Opcodes . PUTFIELD , PROXY_TARGET_INFO , "argumentCount" , "I" ) ; // arguments class mv . visitVarInsn ( Opcodes . ALOAD , argsOff ) ; createArgumentsClassArray ( mv , methodInfo ) ; mv . visitFieldInsn ( Opcodes . PUTFIELD , PROXY_TARGET_INFO , "argumentsClasses" , "[Ljava/lang/Class;" ) ; // arguments mv . visitVarInsn ( Opcodes . ALOAD , argsOff ) ; createArgumentsArray ( mv , methodInfo ) ; mv . visitFieldInsn ( Opcodes . PUTFIELD , PROXY_TARGET_INFO , "arguments" , "[Ljava/lang/Object;" ) ; // return type mv . visitVarInsn ( Opcodes . ALOAD , argsOff ) ; returnType ( mv , methodInfo ) ; mv . visitFieldInsn ( Opcodes . PUTFIELD , PROXY_TARGET_INFO , "returnType" , AsmUtil . L_SIGNATURE_JAVA_LANG_CLASS ) ; // target method name mv . visitVarInsn ( Opcodes . ALOAD , argsOff ) ; targetMethodName ( mv , methodInfo ) ; mv . visitFieldInsn ( Opcodes . PUTFIELD , PROXY_TARGET_INFO , "targetMethodName" , AsmUtil . L_SIGNATURE_JAVA_LANG_STRING ) ; // target method name mv . visitVarInsn ( Opcodes . ALOAD , argsOff ) ; targetMethodDescription ( mv , methodInfo ) ; mv . visitFieldInsn ( Opcodes . PUTFIELD , PROXY_TARGET_INFO , "targetMethodDescription" , AsmUtil . L_SIGNATURE_JAVA_LANG_STRING ) ; // target method name mv . visitVarInsn ( Opcodes . ALOAD , argsOff ) ; targetMethodSignature ( mv , methodInfo ) ; mv . visitFieldInsn ( Opcodes . PUTFIELD , PROXY_TARGET_INFO , "targetMethodSignature" , AsmUtil . L_SIGNATURE_JAVA_LANG_STRING ) ; // target class mv . visitVarInsn ( Opcodes . ALOAD , argsOff ) ; targetClass ( mv , methodInfo ) ; mv . visitFieldInsn ( Opcodes . PUTFIELD , PROXY_TARGET_INFO , "targetClass" , AsmUtil . L_SIGNATURE_JAVA_LANG_CLASS ) ; // the end mv . visitVarInsn ( Opcodes . ALOAD , argsOff ) ; }


Input: Visits replacement code for { [CODESPLIT] public static void targetMethodAnnotation ( final MethodVisitor mv , final MethodInfo methodInfo , final String [ ] args ) { AnnotationInfo [ ] anns = methodInfo . getAnnotations ( ) ; if ( anns != null ) { targetAnnotation ( mv , anns , args ) ; } }


Input: Visits replacement code for { [CODESPLIT] public static void targetClassAnnotation ( final MethodVisitor mv , final ClassInfo classInfo , final String [ ] args ) { AnnotationInfo [ ] anns = classInfo . getAnnotations ( ) ; if ( anns != null ) { targetAnnotation ( mv , anns , args ) ; } else { mv . visitInsn ( Opcodes . ACONST_NULL ) ; } }


Input: Returns the query string . [CODESPLIT] public String getQueryString ( ) { if ( sqlTemplate == null ) { return toString ( ) ; } if ( parameterValues == null ) { return sqlTemplate ; } final StringBuilder sb = new StringBuilder ( ) ; int qMarkCount = 0 ; final StringTokenizer tok = new StringTokenizer ( sqlTemplate + ' ' , "?" ) ; while ( tok . hasMoreTokens ( ) ) { final String oneChunk = tok . nextToken ( ) ; sb . append ( oneChunk ) ; try { Object value = null ; if ( parameterValues . size ( ) > 1 + qMarkCount ) { value = parameterValues . get ( 1 + qMarkCount ) ; qMarkCount ++ ; } else { if ( ! tok . hasMoreTokens ( ) ) { value = "" ; } } if ( value == null ) { value = "?" ; } sb . append ( value ) ; } catch ( Throwable th ) { sb . append ( "--- Building query failed: " ) . append ( th . toString ( ) ) ; } } return sb . toString ( ) . trim ( ) ; }


Input: Saves the parameter value <code > obj< / code > for the specified <code > position< / code > for use in logging output . [CODESPLIT] protected void saveQueryParamValue ( final int position , final Object obj ) { final String strValue ; if ( obj instanceof String || obj instanceof Date ) { strValue = "'" + obj + ' ' ; // if we have a String or Date, include '' in the saved value } else if ( obj instanceof LocalDateTime || obj instanceof LocalDate || obj instanceof LocalTime ) { strValue = "'" + Converter . get ( ) . toString ( obj ) + ' ' ; // time as string with ' } else if ( obj == null ) { strValue = "<null>" ; // convert null to the string null } else { strValue = Converter . get ( ) . toString ( obj ) ; // all other objects (includes all Numbers, arrays, etc) } // if we are setting a position larger than current size of parameterValues, // first make it larger if ( parameterValues == null ) { parameterValues = new ArrayList <> ( ) ; } while ( position >= parameterValues . size ( ) ) { parameterValues . add ( null ) ; } parameterValues . set ( position , strValue ) ; }


Input: Returns correct action class name . Detects Proxetta classes . [CODESPLIT] protected String getActionClassName ( final Object action ) { Class clazz = action . getClass ( ) ; clazz = ProxettaUtil . resolveTargetClass ( clazz ) ; return clazz . getName ( ) ; }


Input: Calculates TO . [CODESPLIT] protected int calculateTo ( final int from , final int count , final int size ) { int to = size ; if ( count != - 1 ) { to = from + count ; if ( to > size ) { to = size ; } } return to ; }


Input: Iterates collection . [CODESPLIT] protected void iterateCollection ( final Collection collection , final int from , final int count , final PageContext pageContext ) throws JspException { JspFragment body = getJspBody ( ) ; Iterator iter = collection . iterator ( ) ; int i = 0 ; int to = calculateTo ( from , count , collection . size ( ) ) ; while ( i < to ) { Object item = iter . next ( ) ; if ( i >= from ) { if ( status != null ) { iteratorStatus . next ( ! iter . hasNext ( ) ) ; } TagUtil . setScopeAttribute ( var , item , scope , pageContext ) ; TagUtil . invokeBody ( body ) ; } i ++ ; } }


Input: Iterates arrays . [CODESPLIT] protected void iterateArray ( final Object [ ] array , final int from , final int count , final PageContext pageContext ) throws JspException { JspFragment body = getJspBody ( ) ; int len = array . length ; int to = calculateTo ( from , count , len ) ; int last = to - 1 ; for ( int i = from ; i < to ; i ++ ) { Object item = array [ i ] ; if ( status != null ) { iteratorStatus . next ( i == last ) ; } TagUtil . setScopeAttribute ( var , item , scope , pageContext ) ; TagUtil . invokeBody ( body ) ; } }


Input: Joins entity array using provided string hints . [CODESPLIT] public Object [ ] join ( final Object [ ] data , final String [ ] hints ) { if ( hints == null ) { return data ; } // build context Map < String , Object > context = new HashMap <> ( hints . length ) ; for ( int i = 0 ; i < hints . length ; i ++ ) { hints [ i ] = hints [ i ] . trim ( ) ; String hint = hints [ i ] ; if ( hint . indexOf ( ' ' ) == - 1 ) { context . put ( hint , data [ i ] ) ; } } // no joining hints found if ( context . size ( ) == data . length ) { return data ; } // joining Object [ ] result = new Object [ context . size ( ) ] ; int count = 0 ; for ( int i = 0 ; i < hints . length ; i ++ ) { String hint = hints [ i ] ; int ndx = hint . indexOf ( ' ' ) ; if ( ndx != - 1 ) { String key = hint . substring ( 0 , ndx ) ; Object value = context . get ( key ) ; if ( value == null ) { throw new DbOomException ( "Hint value missing: " + key ) ; } // don't merge nulls if ( data [ i ] == null ) { continue ; } String hintPropertyName = hint . substring ( ndx + 1 ) ; Class hintPropertyType = BeanUtil . pojo . getPropertyType ( value , hintPropertyName ) ; if ( hintPropertyType != null ) { ClassDescriptor cd = ClassIntrospector . get ( ) . lookup ( hintPropertyType ) ; if ( cd . isCollection ( ) ) { // add element to collection try { Collection collection = BeanUtil . declared . getProperty ( value , hintPropertyName ) ; if ( collection == null ) { collection = ( Collection ) ClassUtil . newInstance ( hintPropertyType ) ; BeanUtil . declaredSilent . setProperty ( value , hintPropertyName , collection ) ; } collection . add ( data [ i ] ) ; } catch ( Exception ex ) { throw new DbOomException ( ex ) ; } } else if ( cd . isArray ( ) ) { // add element to array try { Object [ ] array = BeanUtil . declared . getProperty ( value , hintPropertyName ) ; if ( array == null ) { array = ( Object [ ] ) Array . newInstance ( hintPropertyType . getComponentType ( ) , 1 ) ; BeanUtil . declaredSilent . setProperty ( value , hintPropertyName , array ) ; array [ 0 ] = data [ i ] ; } else { Object [ ] newArray = ArraysUtil . append ( array , data [ i ] ) ; if ( newArray != array ) { BeanUtil . declaredSilent . setProperty ( value , hintPropertyName , newArray ) ; } } } catch ( Exception ex ) { throw new DbOomException ( ex ) ; } } else { // set value BeanUtil . declaredSilent . setProperty ( value , hintPropertyName , data [ i ] ) ; } } else { // special case - the property probably contains the collection in the way int lastNdx = hintPropertyName . lastIndexOf ( ' ' ) ; String name = hintPropertyName . substring ( 0 , lastNdx ) ; Object target = resolveValueInSpecialCase ( value , name ) ; if ( target != null ) { String targetSimpleName = hintPropertyName . substring ( lastNdx + 1 ) ; BeanUtil . declaredForcedSilent . setProperty ( target , targetSimpleName , data [ i ] ) ; } } } else { result [ count ] = data [ i ] ; count ++ ; } } return result ; }


Input: Replaces all occurrences of a certain pattern in a string with a replacement string . This is the fastest replace function known to author . [CODESPLIT] public static String replace ( final String s , final String sub , final String with ) { if ( sub . isEmpty ( ) ) { return s ; } int c = 0 ; int i = s . indexOf ( sub , c ) ; if ( i == - 1 ) { return s ; } int length = s . length ( ) ; StringBuilder sb = new StringBuilder ( length + with . length ( ) ) ; do { sb . append ( s , c , i ) ; sb . append ( with ) ; c = i + sub . length ( ) ; } while ( ( i = s . indexOf ( sub , c ) ) != - 1 ) ; if ( c < length ) { sb . append ( s , c , length ) ; } return sb . toString ( ) ; }


Input: Replaces all occurrences of a character in a string . [CODESPLIT] public static String replaceChar ( final String s , final char sub , final char with ) { int startIndex = s . indexOf ( sub ) ; if ( startIndex == - 1 ) { return s ; } char [ ] str = s . toCharArray ( ) ; for ( int i = startIndex ; i < str . length ; i ++ ) { if ( str [ i ] == sub ) { str [ i ] = with ; } } return new String ( str ) ; }


Input: Replaces all occurrences of a characters in a string . [CODESPLIT] public static String replaceChars ( final String s , final char [ ] sub , final char [ ] with ) { char [ ] str = s . toCharArray ( ) ; for ( int i = 0 ; i < str . length ; i ++ ) { char c = str [ i ] ; for ( int j = 0 ; j < sub . length ; j ++ ) { if ( c == sub [ j ] ) { str [ i ] = with [ j ] ; break ; } } } return new String ( str ) ; }


Input: Replaces the very first occurrence of a substring with supplied string . [CODESPLIT] public static String replaceFirst ( final String s , final String sub , final String with ) { int i = s . indexOf ( sub ) ; if ( i == - 1 ) { return s ; } return s . substring ( 0 , i ) + with + s . substring ( i + sub . length ( ) ) ; }


Input: Replaces the very first occurrence of a character in a string . [CODESPLIT] public static String replaceFirst ( final String s , final char sub , final char with ) { int index = s . indexOf ( sub ) ; if ( index == - 1 ) { return s ; } char [ ] str = s . toCharArray ( ) ; str [ index ] = with ; return new String ( str ) ; }


Input: Replaces the very last occurrence of a substring with supplied string . [CODESPLIT] public static String replaceLast ( final String s , final String sub , final String with ) { int i = s . lastIndexOf ( sub ) ; if ( i == - 1 ) { return s ; } return s . substring ( 0 , i ) + with + s . substring ( i + sub . length ( ) ) ; }


Input: Replaces the very last occurrence of a character in a string . [CODESPLIT] public static String replaceLast ( final String s , final char sub , final char with ) { int index = s . lastIndexOf ( sub ) ; if ( index == - 1 ) { return s ; } char [ ] str = s . toCharArray ( ) ; str [ index ] = with ; return new String ( str ) ; }


Input: Removes all substring occurrences from the string . [CODESPLIT] public static String remove ( final String s , final String sub ) { int c = 0 ; int sublen = sub . length ( ) ; if ( sublen == 0 ) { return s ; } int i = s . indexOf ( sub , c ) ; if ( i == - 1 ) { return s ; } StringBuilder sb = new StringBuilder ( s . length ( ) ) ; do { sb . append ( s , c , i ) ; c = i + sublen ; } while ( ( i = s . indexOf ( sub , c ) ) != - 1 ) ; if ( c < s . length ( ) ) { sb . append ( s , c , s . length ( ) ) ; } return sb . toString ( ) ; }


Input: Removes a single character from string . [CODESPLIT] public static String remove ( final String string , final char ch ) { int stringLen = string . length ( ) ; char [ ] result = new char [ stringLen ] ; int offset = 0 ; for ( int i = 0 ; i < stringLen ; i ++ ) { char c = string . charAt ( i ) ; if ( c == ch ) { continue ; } result [ offset ] = c ; offset ++ ; } if ( offset == stringLen ) { return string ; // no changes } return new String ( result , 0 , offset ) ; }


Input: Determines if string array contains empty strings . [CODESPLIT] public static boolean isAllEmpty ( final String ... strings ) { for ( String string : strings ) { if ( ! isEmpty ( string ) ) { return false ; } } return true ; }


Input: Determines if string array contains just blank strings . [CODESPLIT] public static boolean isAllBlank ( final String ... strings ) { for ( String string : strings ) { if ( ! isBlank ( string ) ) { return false ; } } return true ; }


Input: Returns <code > true< / code > if string contains only white spaces . [CODESPLIT] public static boolean containsOnlyWhitespaces ( final CharSequence string ) { int size = string . length ( ) ; for ( int i = 0 ; i < size ; i ++ ) { char c = string . charAt ( i ) ; if ( ! CharUtil . isWhitespace ( c ) ) { return false ; } } return true ; }


Input: Returns <code > true< / code > if string contains only digits . [CODESPLIT] public static boolean containsOnlyDigits ( final CharSequence string ) { int size = string . length ( ) ; for ( int i = 0 ; i < size ; i ++ ) { char c = string . charAt ( i ) ; if ( ! CharUtil . isDigit ( c ) ) { return false ; } } return true ; }


Input: Converts an array object to array of strings where every element of input array is converted to a string . If input is not an array the result will still be an array with one element . [CODESPLIT] public static String [ ] toStringArray ( final Object value ) { if ( value == null ) { return new String [ 0 ] ; } Class < ? > type = value . getClass ( ) ; if ( ! type . isArray ( ) ) { return new String [ ] { value . toString ( ) } ; } Class componentType = type . getComponentType ( ) ; if ( componentType . isPrimitive ( ) ) { if ( componentType == int . class ) { return ArraysUtil . toStringArray ( ( int [ ] ) value ) ; } else if ( componentType == long . class ) { return ArraysUtil . toStringArray ( ( long [ ] ) value ) ; } else if ( componentType == double . class ) { return ArraysUtil . toStringArray ( ( double [ ] ) value ) ; } else if ( componentType == float . class ) { return ArraysUtil . toStringArray ( ( float [ ] ) value ) ; } else if ( componentType == boolean . class ) { return ArraysUtil . toStringArray ( ( boolean [ ] ) value ) ; } else if ( componentType == short . class ) { return ArraysUtil . toStringArray ( ( short [ ] ) value ) ; } else if ( componentType == byte . class ) { return ArraysUtil . toStringArray ( ( byte [ ] ) value ) ; } else { throw new IllegalArgumentException ( ) ; } } else { return ArraysUtil . toStringArray ( ( Object [ ] ) value ) ; } }


Input: Internal method for changing the first character case . [CODESPLIT] private static String changeFirstCharacterCase ( final boolean capitalize , final String string ) { int strLen = string . length ( ) ; if ( strLen == 0 ) { return string ; } char ch = string . charAt ( 0 ) ; char modifiedCh ; if ( capitalize ) { modifiedCh = Character . toUpperCase ( ch ) ; } else { modifiedCh = Character . toLowerCase ( ch ) ; } if ( modifiedCh == ch ) { // no change, return unchanged string return string ; } char [ ] chars = string . toCharArray ( ) ; chars [ 0 ] = modifiedCh ; return new String ( chars ) ; }


Input: Makes a title - cased string from given input . [CODESPLIT] public static String title ( final String string ) { char [ ] chars = string . toCharArray ( ) ; boolean wasWhitespace = true ; for ( int i = 0 ; i < chars . length ; i ++ ) { char c = chars [ i ] ; if ( CharUtil . isWhitespace ( c ) ) { wasWhitespace = true ; } else { if ( wasWhitespace ) { chars [ i ] = Character . toUpperCase ( c ) ; } else { chars [ i ] = Character . toLowerCase ( c ) ; } wasWhitespace = false ; } } return new String ( chars ) ; }


Input: Returns a new string that is a substring of this string . The substring begins at the specified <code > fromIndex< / code > and extends to the character at index <code > toIndex - 1< / code > . However index values can be negative and then the real index will be calculated from the strings end . This allows to specify e . g . <code > substring ( 1 - 1 ) < / code > to cut one character from both ends of the string . If <code > fromIndex< / code > is negative and <code > toIndex< / code > is 0 it will return last characters of the string . Also this method will never throw an exception if index is out of range . [CODESPLIT] public static String substring ( final String string , int fromIndex , int toIndex ) { int len = string . length ( ) ; if ( fromIndex < 0 ) { fromIndex = len + fromIndex ; if ( toIndex == 0 ) { toIndex = len ; } } if ( toIndex < 0 ) { toIndex = len + toIndex ; } // safe net if ( fromIndex < 0 ) { fromIndex = 0 ; } if ( toIndex > len ) { toIndex = len ; } if ( fromIndex >= toIndex ) { return StringPool . EMPTY ; } return string . substring ( fromIndex , toIndex ) ; }


Input: Returns <code > true< / code > if substring exist at given offset in a string . [CODESPLIT] public static boolean isSubstringAt ( final String string , final String substring , final int offset ) { int len = substring . length ( ) ; int max = offset + len ; if ( max > string . length ( ) ) { return false ; } int ndx = 0 ; for ( int i = offset ; i < max ; i ++ , ndx ++ ) { if ( string . charAt ( i ) != substring . charAt ( ndx ) ) { return false ; } } return true ; }


Input: Splits a string in several parts ( tokens ) that are separated by delimiter . Delimiter is <b > always< / b > surrounded by two strings! If there is no content between two delimiters empty string will be returned for that token . Therefore the length of the returned array will always be : #delimiters + 1 . <p > Method is much much faster then regexp <code > String . split () < / code > and a bit faster then <code > StringTokenizer< / code > . [CODESPLIT] public static String [ ] split ( final String src , final String delimiter ) { int maxparts = ( src . length ( ) / delimiter . length ( ) ) + 2 ; // one more for the last int [ ] positions = new int [ maxparts ] ; int dellen = delimiter . length ( ) ; int i , j = 0 ; int count = 0 ; positions [ 0 ] = - dellen ; while ( ( i = src . indexOf ( delimiter , j ) ) != - 1 ) { count ++ ; positions [ count ] = i ; j = i + dellen ; } count ++ ; positions [ count ] = src . length ( ) ; String [ ] result = new String [ count ] ; for ( i = 0 ; i < count ; i ++ ) { result [ i ] = src . substring ( positions [ i ] + dellen , positions [ i + 1 ] ) ; } return result ; }


Input: Splits a string in several parts ( tokens ) that are separated by delimiter characters . Delimiter may contains any number of character and it is always surrounded by two strings . [CODESPLIT] public static String [ ] splitc ( final String src , final String d ) { if ( ( d . length ( ) == 0 ) || ( src . length ( ) == 0 ) ) { return new String [ ] { src } ; } return splitc ( src , d . toCharArray ( ) ) ; }


Input: Compress multiple occurrences of given char into one appearance . [CODESPLIT] public static String compressChars ( final String s , final char c ) { int len = s . length ( ) ; StringBuilder sb = new StringBuilder ( len ) ; boolean wasChar = false ; for ( int i = 0 ; i < len ; i ++ ) { char c1 = s . charAt ( i ) ; if ( c1 == c ) { if ( wasChar ) { continue ; } wasChar = true ; } else { wasChar = false ; } sb . append ( c1 ) ; } if ( sb . length ( ) == len ) { return s ; } return sb . toString ( ) ; }


Input: Finds the first occurrence of a character in the given source but within limited range ( start end ] . [CODESPLIT] public static int indexOf ( final String src , final char c , int startIndex , int endIndex ) { if ( startIndex < 0 ) { startIndex = 0 ; } int srclen = src . length ( ) ; if ( endIndex > srclen ) { endIndex = srclen ; } for ( int i = startIndex ; i < endIndex ; i ++ ) { if ( src . charAt ( i ) == c ) { return i ; } } return - 1 ; }


Input: Finds the first occurrence of a character in the given source but within limited range ( start end ] . [CODESPLIT] public static int indexOfIgnoreCase ( final String src , char c , int startIndex , int endIndex ) { if ( startIndex < 0 ) { startIndex = 0 ; } int srclen = src . length ( ) ; if ( endIndex > srclen ) { endIndex = srclen ; } c = Character . toLowerCase ( c ) ; for ( int i = startIndex ; i < endIndex ; i ++ ) { if ( Character . toLowerCase ( src . charAt ( i ) ) == c ) { return i ; } } return - 1 ; }


Input: Finds first index of a substring in the given source string with ignored case . [CODESPLIT] public static int indexOfIgnoreCase ( final String src , final String subS ) { return indexOfIgnoreCase ( src , subS , 0 , src . length ( ) ) ; }


Input: Finds last index of a substring in the given source string with ignored case . [CODESPLIT] public static int lastIndexOfIgnoreCase ( final String s , final String subS ) { return lastIndexOfIgnoreCase ( s , subS , s . length ( ) , 0 ) ; }


Input: Finds last index of a substring in the given source string with ignored case . [CODESPLIT] public static int lastIndexOfIgnoreCase ( final String src , final String subS , final int startIndex ) { return lastIndexOfIgnoreCase ( src , subS , startIndex , 0 ) ; }


Input: Finds last index of a substring in the given source string in specified range [ end start ] See { @link #indexOf ( String String int int ) } for details about the speed . [CODESPLIT] public static int lastIndexOf ( final String src , final String sub , int startIndex , int endIndex ) { int sublen = sub . length ( ) ; int srclen = src . length ( ) ; if ( sublen == 0 ) { return startIndex > srclen ? srclen : ( startIndex < - 1 ? - 1 : startIndex ) ; } int total = srclen - sublen ; if ( total < 0 ) { return - 1 ; } if ( startIndex >= total ) { startIndex = total ; } if ( endIndex < 0 ) { endIndex = 0 ; } char c = sub . charAt ( 0 ) ; mainloop : for ( int i = startIndex ; i >= endIndex ; i -- ) { if ( src . charAt ( i ) != c ) { continue ; } int j = 1 ; int k = i + 1 ; while ( j < sublen ) { if ( sub . charAt ( j ) != src . charAt ( k ) ) { continue mainloop ; } j ++ ; k ++ ; } return i ; } return - 1 ; }


Input: Finds last index of a character in the given source string in specified range [ end start ] [CODESPLIT] public static int lastIndexOf ( final String src , final char c , int startIndex , int endIndex ) { int total = src . length ( ) - 1 ; if ( total < 0 ) { return - 1 ; } if ( startIndex >= total ) { startIndex = total ; } if ( endIndex < 0 ) { endIndex = 0 ; } for ( int i = startIndex ; i >= endIndex ; i -- ) { if ( src . charAt ( i ) == c ) { return i ; } } return - 1 ; }


Input: Tests if this string starts with the specified prefix with ignored case and with the specified prefix beginning a specified index . [CODESPLIT] public static boolean startsWithIgnoreCase ( final String src , final String subS , final int startIndex ) { String sub = subS . toLowerCase ( ) ; int sublen = sub . length ( ) ; if ( startIndex + sublen > src . length ( ) ) { return false ; } int j = 0 ; int i = startIndex ; while ( j < sublen ) { char source = Character . toLowerCase ( src . charAt ( i ) ) ; if ( sub . charAt ( j ) != source ) { return false ; } j ++ ; i ++ ; } return true ; }


Input: Returns if string ends with provided character . [CODESPLIT] public static boolean endsWithChar ( final String s , final char c ) { if ( s . length ( ) == 0 ) { return false ; } return s . charAt ( s . length ( ) - 1 ) == c ; }


Input: Count substring occurrences in a source string ignoring case . [CODESPLIT] public static int countIgnoreCase ( final String source , final String sub ) { int count = 0 ; int j = 0 ; int sublen = sub . length ( ) ; if ( sublen == 0 ) { return 0 ; } while ( true ) { int i = indexOfIgnoreCase ( source , sub , j ) ; if ( i == - 1 ) { break ; } count ++ ; j = i + sublen ; } return count ; }


Input: Finds the very last index of a substring from the specified array . It returns an int [ 2 ] where int [ 0 ] represents the substring index and int [ 1 ] represents position where substring was found . Returns <code > null< / code > if noting found . [CODESPLIT] public static int [ ] lastIndexOfIgnoreCase ( final String s , final String ... arr ) { return lastIndexOfIgnoreCase ( s , arr , s . length ( ) ) ; }


Input: Compares two string arrays . [CODESPLIT] public static boolean equalsIgnoreCase ( final String [ ] as , final String [ ] as1 ) { if ( as . length != as1 . length ) { return false ; } for ( int i = 0 ; i < as . length ; i ++ ) { if ( ! as [ i ] . equalsIgnoreCase ( as1 [ i ] ) ) { return false ; } } return true ; }


Input: Replaces many substring at once . Order of string array is important . [CODESPLIT] public static String replace ( final String s , final String [ ] sub , final String [ ] with ) { if ( ( sub . length != with . length ) || ( sub . length == 0 ) ) { return s ; } int start = 0 ; StringBuilder buf = new StringBuilder ( s . length ( ) ) ; while ( true ) { int [ ] res = indexOf ( s , sub , start ) ; if ( res == null ) { break ; } int end = res [ 1 ] ; buf . append ( s , start , end ) ; buf . append ( with [ res [ 0 ] ] ) ; start = end + sub [ res [ 0 ] ] . length ( ) ; } buf . append ( s . substring ( start ) ) ; return buf . toString ( ) ; }


Input: Replaces many substring at once . Order of string array is important . [CODESPLIT] public static String replaceIgnoreCase ( final String s , final String [ ] sub , final String [ ] with ) { if ( ( sub . length != with . length ) || ( sub . length == 0 ) ) { return s ; } int start = 0 ; StringBuilder buf = new StringBuilder ( s . length ( ) ) ; while ( true ) { int [ ] res = indexOfIgnoreCase ( s , sub , start ) ; if ( res == null ) { break ; } int end = res [ 1 ] ; buf . append ( s , start , end ) ; buf . append ( with [ res [ 0 ] ] ) ; start = end + sub [ 0 ] . length ( ) ; } buf . append ( s . substring ( start ) ) ; return buf . toString ( ) ; }


Input: Compares string with at least one from the provided array . If at least one equal string is found returns its index . Otherwise <code > - 1< / code > is returned . [CODESPLIT] public static int equalsOne ( final String src , final String ... dest ) { for ( int i = 0 ; i < dest . length ; i ++ ) { if ( src . equals ( dest [ i ] ) ) { return i ; } } return - 1 ; }


Input: Compares string with at least one from the provided array ignoring case . If at least one equal string is found it returns its index . Otherwise <code > - 1< / code > is returned . [CODESPLIT] public static int equalsOneIgnoreCase ( final String src , final String ... dest ) { for ( int i = 0 ; i < dest . length ; i ++ ) { if ( src . equalsIgnoreCase ( dest [ i ] ) ) { return i ; } } return - 1 ; }


Input: Checks if string starts with at least one string from the provided array . If at least one string is matched it returns its index . Otherwise <code > - 1< / code > is returned . [CODESPLIT] public static int startsWithOne ( final String src , final String ... dest ) { for ( int i = 0 ; i < dest . length ; i ++ ) { String m = dest [ i ] ; if ( m == null ) { continue ; } if ( src . startsWith ( m ) ) { return i ; } } return - 1 ; }


Input: Checks if string starts with at least one string from the provided array . If at least one string is matched it returns its index . Otherwise <code > - 1< / code > is returned . [CODESPLIT] public static int startsWithOneIgnoreCase ( final String src , final String ... dest ) { for ( int i = 0 ; i < dest . length ; i ++ ) { String m = dest [ i ] ; if ( m == null ) { continue ; } if ( startsWithIgnoreCase ( src , m ) ) { return i ; } } return - 1 ; }


Input: Checks if string ends with at least one string from the provided array . If at least one string is matched it returns its index . Otherwise <code > - 1< / code > is returned . [CODESPLIT] public static int endsWithOne ( final String src , final String ... dest ) { for ( int i = 0 ; i < dest . length ; i ++ ) { String m = dest [ i ] ; if ( m == null ) { continue ; } if ( src . endsWith ( m ) ) { return i ; } } return - 1 ; }


Input: Checks if string ends with at least one string from the provided array . If at least one string is matched it returns its index . Otherwise <code > - 1< / code > is returned . [CODESPLIT] public static int endsWithOneIgnoreCase ( final String src , final String ... dest ) { for ( int i = 0 ; i < dest . length ; i ++ ) { String m = dest [ i ] ; if ( m == null ) { continue ; } if ( endsWithIgnoreCase ( src , m ) ) { return i ; } } return - 1 ; }


Input: Returns first index of a whitespace character starting from specified index offset . [CODESPLIT] public static int indexOfWhitespace ( final String string , final int startindex , final int endindex ) { for ( int i = startindex ; i < endindex ; i ++ ) { if ( CharUtil . isWhitespace ( string . charAt ( i ) ) ) { return i ; } } return - 1 ; }


Input: Strips leading char if string starts with one . [CODESPLIT] public static String stripLeadingChar ( final String string , final char c ) { if ( string . length ( ) > 0 ) { if ( string . charAt ( 0 ) == c ) { return string . substring ( 1 ) ; } } return string ; }


Input: Strips trailing char if string ends with one . [CODESPLIT] public static String stripTrailingChar ( final String string , final char c ) { if ( string . length ( ) > 0 ) { if ( string . charAt ( string . length ( ) - 1 ) == c ) { return string . substring ( 0 , string . length ( ) - 1 ) ; } } return string ; }


Input: Strips leading and trailing char from given string . [CODESPLIT] public static String stripChar ( final String string , final char c ) { if ( string . length ( ) == 0 ) { return string ; } if ( string . length ( ) == 1 ) { if ( string . charAt ( 0 ) == c ) { return StringPool . EMPTY ; } return string ; } int left = 0 ; int right = string . length ( ) ; if ( string . charAt ( left ) == c ) { left ++ ; } if ( string . charAt ( right - 1 ) == c ) { right -- ; } return string . substring ( left , right ) ; }


Input: Strips everything up to the first appearance of given char . Character IS included in the returned string . [CODESPLIT] public static String stripToChar ( final String string , final char c ) { int ndx = string . indexOf ( c ) ; if ( ndx == - 1 ) { return string ; } return string . substring ( ndx ) ; }


Input: Strips everything from the first appearance of given char . Character IS NOT included in the returned string . [CODESPLIT] public static String stripFromChar ( final String string , final char c ) { int ndx = string . indexOf ( c ) ; if ( ndx == - 1 ) { return string ; } return string . substring ( 0 , ndx ) ; }


Input: Trims array of strings . <code > null< / code > array elements are ignored . [CODESPLIT] public static void trimAll ( final String ... strings ) { for ( int i = 0 ; i < strings . length ; i ++ ) { String string = strings [ i ] ; if ( string != null ) { strings [ i ] = string . trim ( ) ; } } }


Input: Trims array of strings where empty strings are set to <code > null< / code > . <code > null< / code > elements of the array are ignored . [CODESPLIT] public static void trimDownAll ( final String ... strings ) { for ( int i = 0 ; i < strings . length ; i ++ ) { String string = strings [ i ] ; if ( string != null ) { strings [ i ] = trimDown ( string ) ; } } }


Input: Trims string and sets to <code > null< / code > if trimmed string is empty . [CODESPLIT] public static String trimDown ( String string ) { string = string . trim ( ) ; if ( string . length ( ) == 0 ) { string = null ; } return string ; }


Input: Crops all elements of string array . [CODESPLIT] public static void cropAll ( final String ... strings ) { for ( int i = 0 ; i < strings . length ; i ++ ) { String string = strings [ i ] ; if ( string != null ) { string = crop ( strings [ i ] ) ; } strings [ i ] = string ; } }


Input: Trim whitespaces from the left . [CODESPLIT] public static String trimLeft ( final String src ) { int len = src . length ( ) ; int st = 0 ; while ( ( st < len ) && ( CharUtil . isWhitespace ( src . charAt ( st ) ) ) ) { st ++ ; } return st > 0 ? src . substring ( st ) : src ; }


Input: Trim whitespaces from the right . [CODESPLIT] public static String trimRight ( final String src ) { int len = src . length ( ) ; int count = len ; while ( ( len > 0 ) && ( CharUtil . isWhitespace ( src . charAt ( len - 1 ) ) ) ) { len -- ; } return ( len < count ) ? src . substring ( 0 , len ) : src ; }


Input: Returns indexes of the first region without escaping character . [CODESPLIT] public static int [ ] indexOfRegion ( final String string , final String leftBoundary , final String rightBoundary , final int offset ) { int ndx = offset ; int [ ] res = new int [ 4 ] ; ndx = string . indexOf ( leftBoundary , ndx ) ; if ( ndx == - 1 ) { return null ; } res [ 0 ] = ndx ; ndx += leftBoundary . length ( ) ; res [ 1 ] = ndx ; ndx = string . indexOf ( rightBoundary , ndx ) ; if ( ndx == - 1 ) { return null ; } res [ 2 ] = ndx ; res [ 3 ] = ndx + rightBoundary . length ( ) ; return res ; }


Input: Returns indexes of the first string region . Region is defined by its left and right boundary . Return value is an array of the following indexes : <ul > <li > start of left boundary index< / li > <li > region start index i . e . end of left boundary< / li > <li > region end index i . e . start of right boundary< / li > <li > end of right boundary index< / li > < / ul > <p > Escape character may be used to prefix boundaries so they can be ignored . Double escaped region will be found and first index of the result will be decreased to include one escape character . If region is not founded <code > null< / code > is returned . [CODESPLIT] public static int [ ] indexOfRegion ( final String string , final String leftBoundary , final String rightBoundary , final char escape , final int offset ) { int ndx = offset ; int [ ] res = new int [ 4 ] ; while ( true ) { ndx = string . indexOf ( leftBoundary , ndx ) ; if ( ndx == - 1 ) { return null ; } int leftBoundaryLen = leftBoundary . length ( ) ; if ( ndx > 0 ) { if ( string . charAt ( ndx - 1 ) == escape ) { // check previous char boolean cont = true ; if ( ndx > 1 ) { if ( string . charAt ( ndx - 2 ) == escape ) { // check double escapes ndx -- ; leftBoundaryLen ++ ; cont = false ; } } if ( cont ) { ndx += leftBoundaryLen ; continue ; } } } res [ 0 ] = ndx ; ndx += leftBoundaryLen ; res [ 1 ] = ndx ; while ( true ) { // find right boundary ndx = string . indexOf ( rightBoundary , ndx ) ; if ( ndx == - 1 ) { return null ; } if ( ndx > 0 ) { if ( string . charAt ( ndx - 1 ) == escape ) { ndx += rightBoundary . length ( ) ; continue ; } } res [ 2 ] = ndx ; res [ 3 ] = ndx + rightBoundary . length ( ) ; return res ; } } }


Input: Joins an collection of objects into one string with separator . [CODESPLIT] public static String join ( final Collection collection , final char separator ) { if ( collection == null ) { return null ; } if ( collection . size ( ) == 0 ) { return StringPool . EMPTY ; } final StringBuilder sb = new StringBuilder ( collection . size ( ) * 16 ) ; final Iterator it = collection . iterator ( ) ; for ( int i = 0 ; i < collection . size ( ) ; i ++ ) { if ( i > 0 ) { sb . append ( separator ) ; } sb . append ( it . next ( ) ) ; } return sb . toString ( ) ; }


Input: Joins an array of objects into one string with separator . [CODESPLIT] public static String join ( final Object [ ] array , final String separator ) { if ( array == null ) { return null ; } if ( array . length == 0 ) { return StringPool . EMPTY ; } if ( array . length == 1 ) { return String . valueOf ( array [ 0 ] ) ; } final StringBuilder sb = new StringBuilder ( array . length * 16 ) ; for ( int i = 0 ; i < array . length ; i ++ ) { if ( i > 0 ) { sb . append ( separator ) ; } sb . append ( array [ i ] ) ; } return sb . toString ( ) ; }


Input: Converts string charset . If charset names are the same the same string is returned . [CODESPLIT] public static String convertCharset ( final String source , final String srcCharsetName , final String newCharsetName ) { if ( srcCharsetName . equals ( newCharsetName ) ) { return source ; } return StringUtil . newString ( StringUtil . getBytes ( source , srcCharsetName ) , newCharsetName ) ; }


Input: Safely compares provided char with char on given location . [CODESPLIT] public static boolean isCharAtEqual ( final String string , final int index , final char charToCompare ) { if ( ( index < 0 ) || ( index >= string . length ( ) ) ) { return false ; } return string . charAt ( index ) == charToCompare ; }


Input: Surrounds the string with provided prefix and suffix if such missing from string . [CODESPLIT] public static String surround ( String string , final String prefix , final String suffix ) { if ( ! string . startsWith ( prefix ) ) { string = prefix + string ; } if ( ! string . endsWith ( suffix ) ) { string += suffix ; } return string ; }


Input: Inserts prefix if doesn t exist . [CODESPLIT] public static String prefix ( String string , final String prefix ) { if ( ! string . startsWith ( prefix ) ) { string = prefix + string ; } return string ; }


Input: Appends suffix if doesn t exist . [CODESPLIT] public static String suffix ( String string , final String suffix ) { if ( ! string . endsWith ( suffix ) ) { string += suffix ; } return string ; }


Input: Cuts the string from beginning to the first index of provided substring . [CODESPLIT] public static String cutToIndexOf ( String string , final String substring ) { int i = string . indexOf ( substring ) ; if ( i != - 1 ) { string = string . substring ( 0 , i ) ; } return string ; }


Input: Cuts the string from the first index of provided substring to the end . [CODESPLIT] public static String cutFromIndexOf ( String string , final String substring ) { int i = string . indexOf ( substring ) ; if ( i != - 1 ) { string = string . substring ( i ) ; } return string ; }


Input: Cuts prefix if exists . [CODESPLIT] public static String cutPrefix ( String string , final String prefix ) { if ( string . startsWith ( prefix ) ) { string = string . substring ( prefix . length ( ) ) ; } return string ; }


Input: Cuts sufix if exists . [CODESPLIT] public static String cutSuffix ( String string , final String suffix ) { if ( string . endsWith ( suffix ) ) { string = string . substring ( 0 , string . length ( ) - suffix . length ( ) ) ; } return string ; }


Input: Removes surrounding prefix and suffixes . [CODESPLIT] public static String cutSurrounding ( final String string , final String prefix , final String suffix ) { int start = 0 ; int end = string . length ( ) ; if ( string . startsWith ( prefix ) ) { start = prefix . length ( ) ; } if ( string . endsWith ( suffix ) ) { end -= suffix . length ( ) ; } if ( end <= start ) { return StringPool . EMPTY ; } return string . substring ( start , end ) ; }


Input: Cuts a string between two other strings . If either of left and right is missing nothing will be cut and <code > null< / code > is returned . If indexes of left or right strings are wrong empty string is returned . [CODESPLIT] public static String cutBetween ( final String string , final String left , final String right ) { int leftNdx = string . indexOf ( left ) ; if ( leftNdx == - 1 ) { return null ; } int rightNdx = string . indexOf ( right ) ; if ( rightNdx == - 1 ) { return null ; } leftNdx += left . length ( ) ; if ( leftNdx >= rightNdx ) { return StringPool . EMPTY ; } return string . substring ( leftNdx , rightNdx ) ; }


Input: Returns <code > true< / code > if character at provided index position is escaped by escape character . [CODESPLIT] public static boolean isCharAtEscaped ( final String src , int ndx , final char escapeChar ) { if ( ndx == 0 ) { return false ; } ndx -- ; return src . charAt ( ndx ) == escapeChar ; }


Input: Inserts a string on provided offset . [CODESPLIT] public static String insert ( final String src , final String insert , int offset ) { if ( offset < 0 ) { offset = 0 ; } if ( offset > src . length ( ) ) { offset = src . length ( ) ; } StringBuilder sb = new StringBuilder ( src ) ; sb . insert ( offset , insert ) ; return sb . toString ( ) ; }


Input: Creates a new string that contains the provided string a number of times . [CODESPLIT] public static String repeat ( final String source , int count ) { StringBand result = new StringBand ( count ) ; while ( count > 0 ) { result . append ( source ) ; count -- ; } return result . toString ( ) ; }


Input: Reverse a string . [CODESPLIT] public static String reverse ( final String s ) { StringBuilder result = new StringBuilder ( s . length ( ) ) ; for ( int i = s . length ( ) - 1 ; i >= 0 ; i -- ) { result . append ( s . charAt ( i ) ) ; } return result . toString ( ) ; }


Input: Returns max common prefix of two strings . [CODESPLIT] public static String maxCommonPrefix ( final String one , final String two ) { final int minLength = Math . min ( one . length ( ) , two . length ( ) ) ; final StringBuilder sb = new StringBuilder ( minLength ) ; for ( int pos = 0 ; pos < minLength ; pos ++ ) { final char currentChar = one . charAt ( pos ) ; if ( currentChar != two . charAt ( pos ) ) { break ; } sb . append ( currentChar ) ; } return sb . toString ( ) ; }


Input: Finds common prefix for several strings . Returns an empty string if arguments do not have a common prefix . [CODESPLIT] public static String findCommonPrefix ( final String ... strings ) { StringBuilder prefix = new StringBuilder ( ) ; int index = 0 ; char c = 0 ; loop : while ( true ) { for ( int i = 0 ; i < strings . length ; i ++ ) { String s = strings [ i ] ; if ( index == s . length ( ) ) { break loop ; } if ( i == 0 ) { c = s . charAt ( index ) ; } else { if ( s . charAt ( index ) != c ) { break loop ; } } } index ++ ; prefix . append ( c ) ; } return prefix . length ( ) == 0 ? StringPool . EMPTY : prefix . toString ( ) ; }


Input: Shorten string to given length . [CODESPLIT] public static String shorten ( String s , int length , final String suffix ) { length -= suffix . length ( ) ; if ( s . length ( ) > length ) { for ( int j = length ; j >= 0 ; j -- ) { if ( CharUtil . isWhitespace ( s . charAt ( j ) ) ) { length = j ; break ; } } String temp = s . substring ( 0 , length ) ; s = temp . concat ( suffix ) ; } return s ; }


Input: Converts all of the characters in the string to upper case based on the locale . [CODESPLIT] public static String toUpperCase ( final String s , Locale locale ) { if ( s == null ) { return null ; } StringBuilder sb = null ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) { char c = s . charAt ( i ) ; if ( c > 127 ) { // found non-ascii char, fallback to the slow unicode detection if ( locale == null ) { locale = Locale . getDefault ( ) ; } return s . toUpperCase ( locale ) ; } if ( ( c >= ' ' ) && ( c <= ' ' ) ) { if ( sb == null ) { sb = new StringBuilder ( s ) ; } sb . setCharAt ( i , ( char ) ( c - 32 ) ) ; } } if ( sb == null ) { return s ; } return sb . toString ( ) ; }


Input: Removes starting and ending single or double quotes . [CODESPLIT] public static String removeQuotes ( final String string ) { if ( ( startsWithChar ( string , ' ' ) && endsWithChar ( string , ' ' ) ) || ( startsWithChar ( string , ' ' ) && endsWithChar ( string , ' ' ) ) || ( startsWithChar ( string , ' ' ) && endsWithChar ( string , ' ' ) ) ) { return substring ( string , 1 , - 1 ) ; } return string ; }


Input: Converts bytes to hex string . [CODESPLIT] public static String toHexString ( final byte [ ] bytes ) { char [ ] chars = new char [ bytes . length * 2 ] ; int i = 0 ; for ( byte b : bytes ) { chars [ i ++ ] = CharUtil . int2hex ( ( b & 0xF0 ) >> 4 ) ; chars [ i ++ ] = CharUtil . int2hex ( b & 0x0F ) ; } return new String ( chars ) ; }


Input: Executes function on a string if not { [CODESPLIT] public static String ifNotNull ( final String input , final Function < String , String > stringFunction ) { if ( input == null ) { return StringPool . EMPTY ; } return stringFunction . apply ( input ) ; }


Input: Returns String bytes using Jodds default encoding . [CODESPLIT] public static byte [ ] getBytes ( final String string ) { try { return string . getBytes ( JoddCore . encoding ) ; } catch ( UnsupportedEncodingException e ) { throw new RuntimeException ( e ) ; } }


Input: Detects quote character or return 0 . [CODESPLIT] public static char detectQuoteChar ( final String str ) { if ( str . length ( ) < 2 ) { return 0 ; } final char c = str . charAt ( 0 ) ; if ( c != str . charAt ( str . length ( ) - 1 ) ) { return 0 ; } if ( c == ' ' || c == ' ' || c == ' ' ) { return c ; } return 0 ; }


Input: Redirects to the given location . Provided path is parsed action is used as a value context . [CODESPLIT] @ Override public void render ( final ActionRequest actionRequest , final Object resultValue ) { final PermRedirect redirectResult ; if ( resultValue == null ) { redirectResult = PermRedirect . to ( StringPool . SLASH ) ; } else { if ( resultValue instanceof String ) { redirectResult = PermRedirect . to ( ( String ) resultValue ) ; } else { redirectResult = ( PermRedirect ) resultValue ; } } final String resultBasePath = actionRequest . getActionRuntime ( ) . getResultBasePath ( ) ; final String redirectValue = redirectResult . path ( ) ; final String resultPath ; if ( redirectValue . startsWith ( "http://" ) || redirectValue . startsWith ( "https://" ) ) { resultPath = redirectValue ; } else { resultPath = resultMapper . resolveResultPathString ( resultBasePath , redirectValue ) ; } final HttpServletRequest request = actionRequest . getHttpServletRequest ( ) ; final HttpServletResponse response = actionRequest . getHttpServletResponse ( ) ; String path = beanTemplateParser . parseWithBean ( resultPath , actionRequest . getAction ( ) ) ; DispatcherUtil . redirectPermanent ( request , response , path ) ; }


Input: Appends another fast buffer to this one . [CODESPLIT] public FastIntBuffer append ( final FastIntBuffer buff ) { if ( buff . offset == 0 ) { return this ; } append ( buff . buffer , 0 , buff . offset ) ; return this ; }


Input: Visits a primitive value of the annotation . [CODESPLIT] public void visit ( final String name , final Object value ) { if ( av != null ) { av . visit ( name , value ) ; } }


Input: Visits an enumeration value of the annotation . [CODESPLIT] public void visitEnum ( final String name , final String descriptor , final String value ) { if ( av != null ) { av . visitEnum ( name , descriptor , value ) ; } }


Input: Visits a nested annotation value of the annotation . [CODESPLIT] public AnnotationVisitor visitAnnotation ( final String name , final String descriptor ) { if ( av != null ) { return av . visitAnnotation ( name , descriptor ) ; } return null ; }


Input: Lookups { [CODESPLIT] public < E > DbEntityDescriptor < E > lookupType ( final Class < E > type ) { String typeName = type . getName ( ) ; if ( StringUtil . startsWithOne ( typeName , primitiveEntitiesPrefixes ) != - 1 ) { return null ; } DbEntityDescriptor < E > ded = descriptorsMap . get ( type ) ; if ( ded == null ) { ded = registerType ( type ) ; } return ded ; }


Input: Registers just type and entity names . Enough for most usages . [CODESPLIT] public < E > DbEntityDescriptor < E > registerType ( final Class < E > type ) { DbEntityDescriptor < E > ded = createDbEntityDescriptor ( type ) ; DbEntityDescriptor < E > existing = descriptorsMap . put ( type , ded ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Register " + type . getName ( ) + " as " + ded . getTableName ( ) ) ; } if ( existing != null ) { if ( ded . getType ( ) == type ) { return ded ; } throw new DbOomException ( "Type already registered: " + existing . getType ( ) ) ; } existing = entityNamesMap . put ( ded . getEntityName ( ) , ded ) ; if ( existing != null ) { throw new DbOomException ( "Name '" + ded . getEntityName ( ) + "' already mapped to an entity: " + existing . getType ( ) ) ; } return ded ; }


Input: Registers entity . { [CODESPLIT] public < E > DbEntityDescriptor < E > registerEntity ( final Class < E > type ) { DbEntityDescriptor < E > ded = registerType ( type ) ; DbEntityDescriptor existing = tableNamesMap . put ( ded . getTableName ( ) , ded ) ; if ( existing != null ) { if ( ded . getType ( ) == type ) { return ded ; } throw new DbOomException ( "Entity registration failed! Table '" + ded . getTableName ( ) + "' already mapped to an entity: " + existing . getType ( ) ) ; } return ded ; }


Input: Registers entity . Existing entity will be removed if exist so no exception will be thrown . [CODESPLIT] public < E > DbEntityDescriptor < E > registerEntity ( final Class < E > type , final boolean force ) { if ( force ) { removeEntity ( type ) ; } return registerEntity ( type ) ; }


Input: Removes entity and returns removed descriptor . [CODESPLIT] public < E > DbEntityDescriptor < E > removeEntity ( final Class < E > type ) { DbEntityDescriptor < E > ded = descriptorsMap . remove ( type ) ; if ( ded == null ) { ded = createDbEntityDescriptor ( type ) ; } entityNamesMap . remove ( ded . getEntityName ( ) ) ; tableNamesMap . remove ( ded . getTableName ( ) ) ; return ded ; }


Input: Creates { [CODESPLIT] protected < E > DbEntityDescriptor < E > createDbEntityDescriptor ( final Class < E > type ) { final String schemaName = dbOomConfig . getSchemaName ( ) ; final TableNamingStrategy tableNames = dbOomConfig . getTableNames ( ) ; final ColumnNamingStrategy columnNames = dbOomConfig . getColumnNames ( ) ; return new DbEntityDescriptor <> ( type , schemaName , tableNames , columnNames ) ; }


Input: Creates new entity instances . [CODESPLIT] public < E > E createEntityInstance ( final Class < E > type ) { try { return ClassUtil . newInstance ( type ) ; } catch ( Exception ex ) { throw new DbOomException ( ex ) ; } }


Input: Defines the interface of the resulting class . [CODESPLIT] public WrapperProxettaFactory setTargetInterface ( final Class targetInterface ) { if ( ! targetInterface . isInterface ( ) ) { throw new ProxettaException ( "Not an interface: " + targetInterface . getName ( ) ) ; } this . targetInterface = targetInterface ; return this ; }


Input: { [CODESPLIT] @ Override protected WorkData process ( final ClassReader cr , final TargetClassInfoReader targetClassInfoReader ) { final ProxettaWrapperClassBuilder pcb = new ProxettaWrapperClassBuilder ( targetClassOrInterface , targetInterface , targetFieldName , destClassWriter , proxetta . getAspects ( new ProxyAspect [ 0 ] ) , resolveClassNameSuffix ( ) , requestedProxyClassName , targetClassInfoReader , createTargetInDefaultCtor ) ; cr . accept ( pcb , 0 ) ; return pcb . getWorkData ( ) ; }


Input: Injects target into wrapper . [CODESPLIT] public void injectTargetIntoWrapper ( final Object target , final Object wrapper ) { ProxettaUtil . injectTargetIntoWrapper ( target , wrapper , targetFieldName ) ; }


Input: Lookups for annotated properties . Caches all annotated properties on the first action class scan . [CODESPLIT] protected PropertyDescriptor [ ] lookupAnnotatedProperties ( final Class type ) { PropertyDescriptor [ ] properties = annotatedProperties . get ( type ) ; if ( properties != null ) { return properties ; } ClassDescriptor cd = ClassIntrospector . get ( ) . lookup ( type ) ; PropertyDescriptor [ ] allProperties = cd . getAllPropertyDescriptors ( ) ; List < PropertyDescriptor > list = new ArrayList <> ( ) ; for ( PropertyDescriptor propertyDescriptor : allProperties ) { Annotation ann = null ; if ( propertyDescriptor . getFieldDescriptor ( ) != null ) { ann = propertyDescriptor . getFieldDescriptor ( ) . getField ( ) . getAnnotation ( annotations ) ; } if ( ann == null && propertyDescriptor . getWriteMethodDescriptor ( ) != null ) { ann = propertyDescriptor . getWriteMethodDescriptor ( ) . getMethod ( ) . getAnnotation ( annotations ) ; } if ( ann == null && propertyDescriptor . getReadMethodDescriptor ( ) != null ) { ann = propertyDescriptor . getReadMethodDescriptor ( ) . getMethod ( ) . getAnnotation ( annotations ) ; } if ( ann != null ) { list . add ( propertyDescriptor ) ; } } if ( list . isEmpty ( ) ) { properties = EMPTY ; } else { properties = list . toArray ( new PropertyDescriptor [ 0 ] ) ; } annotatedProperties . put ( type , properties ) ; return properties ; }


Input: Detects database and configure DbOom engine . [CODESPLIT] public DbServer detectDatabaseAndConfigureDbOom ( final ConnectionProvider cp , final DbOomConfig dbOomConfig ) { cp . init ( ) ; final Connection connection = cp . getConnection ( ) ; final DbServer dbServer = detectDatabase ( connection ) ; cp . closeConnection ( connection ) ; dbServer . accept ( dbOomConfig ) ; return dbServer ; }


Input: Detects database and returns { [CODESPLIT] public DbServer detectDatabase ( final Connection connection ) { final String dbName ; final int dbMajorVersion ; final String version ; try { log . info ( "Detecting database..." ) ; DatabaseMetaData databaseMetaData = connection . getMetaData ( ) ; dbName = databaseMetaData . getDatabaseProductName ( ) ; dbMajorVersion = databaseMetaData . getDatabaseMajorVersion ( ) ; final int dbMinorVersion = databaseMetaData . getDatabaseMinorVersion ( ) ; version = dbMajorVersion + "." + dbMinorVersion ; log . info ( "Database: " + dbName + " v" + dbMajorVersion + "." + dbMinorVersion ) ; } catch ( SQLException sex ) { String msg = sex . getMessage ( ) ; if ( msg . contains ( "explicitly set for database: DB2" ) ) { return new Db2DbServer ( ) ; } throw new DbSqlException ( sex ) ; } if ( dbName . equals ( "Apache Derby" ) ) { return new DerbyDbServer ( version ) ; } if ( dbName . startsWith ( "DB2/" ) ) { return new Db2DbServer ( version ) ; } if ( dbName . equals ( "HSQL Database Engine" ) ) { return new HsqlDbServer ( version ) ; } if ( dbName . equals ( "Informix Dynamic Server" ) ) { return new InformixDbServer ( version ) ; } if ( dbName . startsWith ( "Microsoft SQL Server" ) ) { return new SqlServerDbServer ( version ) ; } if ( dbName . equals ( "MySQL" ) ) { return new MySqlDbServer ( version ) ; } if ( dbName . equals ( "Oracle" ) ) { return new OracleDbServer ( version ) ; } if ( dbName . equals ( "PostgreSQL" ) ) { return new PostgreSqlDbServer ( version ) ; } if ( dbName . equals ( "Sybase SQL Server" ) ) { return new SybaseDbServer ( version ) ; } if ( dbName . equals ( "ASE" ) && ( dbMajorVersion == 15 ) ) { return new SybaseDbServer ( version ) ; } if ( dbName . equals ( "SQLite" ) ) { return new SQLiteDbServer ( version ) ; } return new GenericDbServer ( ) ; }


Input: Closes this output stream causing any buffered data to be flushed and any further output data to throw an IOException . [CODESPLIT] @ Override public void close ( ) throws IOException { if ( closed ) { return ; } if ( gzipstream != null ) { flushToGZip ( ) ; gzipstream . close ( ) ; gzipstream = null ; } else { if ( bufferCount > 0 ) { output . write ( buffer , 0 , bufferCount ) ; bufferCount = 0 ; } } output . close ( ) ; closed = true ; }


Input: Writes the specified byte to our output stream . [CODESPLIT] @ Override public void write ( final int b ) throws IOException { if ( closed ) { throw new IOException ( "Cannot write to a closed output stream" ) ; } if ( bufferCount >= buffer . length ) { flushToGZip ( ) ; } buffer [ bufferCount ++ ] = ( byte ) b ; }


Input: Writes <code > len< / code > bytes from the specified byte array starting at the specified offset to our output stream . [CODESPLIT] @ Override public void write ( final byte [ ] b , final int off , final int len ) throws IOException { if ( closed ) { throw new IOException ( "Cannot write to a closed output stream" ) ; } if ( len == 0 ) { return ; } // Can we write into buffer ? if ( len <= ( buffer . length - bufferCount ) ) { System . arraycopy ( b , off , buffer , bufferCount , len ) ; bufferCount += len ; return ; } // There is not enough space in buffer. Flush it ... flushToGZip ( ) ; // ... and try again. Note, that bufferCount = 0 here ! if ( len <= ( buffer . length - bufferCount ) ) { System . arraycopy ( b , off , buffer , bufferCount , len ) ; bufferCount += len ; return ; } // write direct to gzip writeToGZip ( b , off , len ) ; }


Input: Writes byte array to gzip output stream . Creates new <code > GZIPOutputStream< / code > if not created yet . Also sets the Content - Encoding header . [CODESPLIT] public void writeToGZip ( final byte [ ] b , final int off , final int len ) throws IOException { if ( gzipstream == null ) { gzipstream = new GZIPOutputStream ( output ) ; response . setHeader ( "Content-Encoding" , "gzip" ) ; } gzipstream . write ( b , off , len ) ; }


Input: Filters requests to remove URL - based session identifiers . [CODESPLIT] @ Override public void doFilter ( final ServletRequest request , final ServletResponse response , final FilterChain chain ) throws IOException , ServletException { HttpServletRequest httpRequest = ( HttpServletRequest ) request ; HttpServletResponse httpResponse = ( HttpServletResponse ) response ; if ( isRequestedSessionIdFromURL ( httpRequest ) ) { HttpSession session = httpRequest . getSession ( false ) ; if ( session != null ) { session . invalidate ( ) ; // clear session if session id in URL } } // wrap response to remove URL encoding HttpServletResponseWrapper wrappedResponse = new HttpServletResponseWrapper ( httpResponse ) { @ Override public String encodeRedirectUrl ( final String url ) { return url ; } @ Override public String encodeRedirectURL ( final String url ) { return url ; } @ Override public String encodeUrl ( final String url ) { return url ; } @ Override public String encodeURL ( final String url ) { return url ; } } ; chain . doFilter ( request , wrappedResponse ) ; }


Input: Detects if session ID exist in the URL . It works more reliable than <code > servletRequest . isRequestedSessionIdFromURL () < / code > . [CODESPLIT] protected boolean isRequestedSessionIdFromURL ( final HttpServletRequest servletRequest ) { if ( servletRequest . isRequestedSessionIdFromURL ( ) ) { return true ; } HttpSession session = servletRequest . getSession ( false ) ; if ( session != null ) { String sessionId = session . getId ( ) ; StringBuffer requestUri = servletRequest . getRequestURL ( ) ; return requestUri . indexOf ( sessionId ) != - 1 ; } return false ; }


Input: Returns encoded attachment name . [CODESPLIT] public String getEncodedName ( ) { if ( name == null ) { return null ; } try { return MimeUtility . encodeText ( name ) ; } catch ( final UnsupportedEncodingException ueex ) { throw new MailException ( ueex ) ; } }


Input: Returns byte content of the attachment . [CODESPLIT] public byte [ ] toByteArray ( ) { final FastByteArrayOutputStream out ; if ( size != - 1 ) { out = new FastByteArrayOutputStream ( size ) ; } else { out = new FastByteArrayOutputStream ( ) ; } writeToStream ( out ) ; return out . toByteArray ( ) ; }


Input: Saves attachment to a file . [CODESPLIT] public void writeToFile ( final File destination ) { InputStream input = null ; final OutputStream output ; try { input = getDataSource ( ) . getInputStream ( ) ; output = new FileOutputStream ( destination ) ; StreamUtil . copy ( input , output ) ; } catch ( final IOException ioex ) { throw new MailException ( ioex ) ; } finally { StreamUtil . close ( input ) ; } }


Input: Saves attachment to the output stream . [CODESPLIT] public void writeToStream ( final OutputStream out ) { InputStream input = null ; try { input = getDataSource ( ) . getInputStream ( ) ; StreamUtil . copy ( input , out ) ; } catch ( final IOException ioex ) { throw new MailException ( ioex ) ; } finally { StreamUtil . close ( input ) ; } }


Input: { [CODESPLIT] @ Override public BigDecimal get ( final ResultSet rs , final int index , final int dbSqlType ) throws SQLException { return rs . getBigDecimal ( index ) ; }


Input: { [CODESPLIT] @ Override public void set ( final PreparedStatement st , final int index , final BigDecimal value , final int dbSqlType ) throws SQLException { st . setBigDecimal ( index , value ) ; }


Input: Invoked on INVOKEVIRTUAL INVOKESPECIAL INVOKESTATIC INVOKEINTERFACE or INVOKEDYNAMIC . [CODESPLIT] @ Override public void visitMethodInsn ( final int opcode , String owner , String name , String desc , final boolean isInterface ) { // replace NEW.<init> if ( ( newInvokeReplacer != null ) && ( opcode == INVOKESPECIAL ) ) { String exOwner = owner ; owner = newInvokeReplacer . getOwner ( ) ; name = newInvokeReplacer . getMethodName ( ) ; desc = changeReturnType ( desc , ' ' + exOwner + ' ' ) ; super . visitMethodInsn ( INVOKESTATIC , owner , name , desc , isInterface ) ; newInvokeReplacer = null ; return ; } InvokeInfo invokeInfo = new InvokeInfo ( owner , name , desc ) ; // [*] // creating FooClone.<init>; inside the FOO constructor // replace the very first invokespecial <init> call (SUB.<init>) // to targets subclass with target (FOO.<init>). if ( methodInfo . getMethodName ( ) . equals ( INIT ) ) { if ( ( ! firstSuperCtorInitCalled ) && ( opcode == INVOKESPECIAL ) && name . equals ( INIT ) && owner . equals ( wd . nextSupername ) ) { firstSuperCtorInitCalled = true ; owner = wd . superReference ; super . visitMethodInsn ( opcode , owner , name , desc , isInterface ) ; return ; } } // detection of super calls if ( ( opcode == INVOKESPECIAL ) && ( owner . equals ( wd . nextSupername ) && ( ! name . equals ( INIT ) ) ) ) { throw new ProxettaException ( "Super call detected in class " + methodInfo . getClassname ( ) + " method: " + methodInfo . getSignature ( ) + "\nProxetta can't handle super calls due to VM limitations." ) ; } InvokeReplacer ir = null ; // find first matching aspect for ( InvokeAspect aspect : aspects ) { ir = aspect . pointcut ( invokeInfo ) ; if ( ir != null ) { break ; } } if ( ir == null || ir . isNone ( ) ) { if ( ProxettaAsmUtil . isCreateArgumentsArrayMethod ( name , desc ) ) { ProxyTargetReplacement . createArgumentsArray ( mv , methodInfo ) ; wd . proxyApplied = true ; return ; } if ( ProxettaAsmUtil . isCreateArgumentsClassArrayMethod ( name , desc ) ) { ProxyTargetReplacement . createArgumentsClassArray ( mv , methodInfo ) ; wd . proxyApplied = true ; return ; } if ( ProxettaAsmUtil . isArgumentsCountMethod ( name , desc ) ) { ProxyTargetReplacement . argumentsCount ( mv , methodInfo ) ; wd . proxyApplied = true ; return ; } if ( ProxettaAsmUtil . isTargetMethodNameMethod ( name , desc ) ) { ProxyTargetReplacement . targetMethodName ( mv , methodInfo ) ; wd . proxyApplied = true ; return ; } if ( ProxettaAsmUtil . isTargetMethodDescriptionMethod ( name , desc ) ) { ProxyTargetReplacement . targetMethodDescription ( mv , methodInfo ) ; wd . proxyApplied = true ; return ; } if ( ProxettaAsmUtil . isTargetMethodSignatureMethod ( name , desc ) ) { ProxyTargetReplacement . targetMethodSignature ( mv , methodInfo ) ; wd . proxyApplied = true ; return ; } if ( ProxettaAsmUtil . isReturnTypeMethod ( name , desc ) ) { ProxyTargetReplacement . returnType ( mv , methodInfo ) ; wd . proxyApplied = true ; return ; } if ( ProxettaAsmUtil . isTargetClassMethod ( name , desc ) ) { ProxyTargetReplacement . targetClass ( mv , methodInfo ) ; wd . proxyApplied = true ; return ; } if ( isArgumentTypeMethod ( name , desc ) ) { int argIndex = this . getArgumentIndex ( ) ; ProxyTargetReplacement . argumentType ( mv , methodInfo , argIndex ) ; wd . proxyApplied = true ; return ; } if ( isArgumentMethod ( name , desc ) ) { int argIndex = this . getArgumentIndex ( ) ; ProxyTargetReplacement . argument ( mv , methodInfo , argIndex ) ; wd . proxyApplied = true ; return ; } if ( isInfoMethod ( name , desc ) ) { proxyInfoRequested = true ; // we are NOT calling the replacement here, as we would expect. // NO, we need to wait for the very next ASTORE method so we // can read the index and use it for replacement method!!! //ProxyTargetReplacement.info(mv, methodInfo); wd . proxyApplied = true ; return ; } if ( isTargetMethodAnnotationMethod ( name , desc ) ) { String [ ] args = getLastTwoStringArguments ( ) ; // pop current two args mv . visitInsn ( POP ) ; mv . visitInsn ( POP ) ; ProxyTargetReplacement . targetMethodAnnotation ( mv , methodInfo , args ) ; wd . proxyApplied = true ; return ; } if ( isTargetClassAnnotationMethod ( name , desc ) ) { String [ ] args = getLastTwoStringArguments ( ) ; // pop current two args mv . visitInsn ( POP ) ; mv . visitInsn ( POP ) ; ProxyTargetReplacement . targetClassAnnotation ( mv , methodInfo . getClassInfo ( ) , args ) ; wd . proxyApplied = true ; return ; } super . visitMethodInsn ( opcode , owner , name , desc , isInterface ) ; return ; } wd . proxyApplied = true ; String exOwner = owner ; owner = ir . getOwner ( ) ; name = ir . getMethodName ( ) ; switch ( opcode ) { case INVOKEINTERFACE : desc = prependArgument ( desc , AsmUtil . L_SIGNATURE_JAVA_LANG_OBJECT ) ; break ; case INVOKEVIRTUAL : desc = prependArgument ( desc , AsmUtil . L_SIGNATURE_JAVA_LANG_OBJECT ) ; break ; case INVOKESTATIC : break ; default : throw new ProxettaException ( "Unsupported opcode: " + opcode ) ; } // additional arguments if ( ir . isPassOwnerName ( ) ) { desc = appendArgument ( desc , AsmUtil . L_SIGNATURE_JAVA_LANG_STRING ) ; super . visitLdcInsn ( exOwner ) ; } if ( ir . isPassMethodName ( ) ) { desc = appendArgument ( desc , AsmUtil . L_SIGNATURE_JAVA_LANG_STRING ) ; super . visitLdcInsn ( methodInfo . getMethodName ( ) ) ; } if ( ir . isPassMethodSignature ( ) ) { desc = appendArgument ( desc , AsmUtil . L_SIGNATURE_JAVA_LANG_STRING ) ; super . visitLdcInsn ( methodInfo . getSignature ( ) ) ; } if ( ir . isPassTargetClass ( ) ) { desc = appendArgument ( desc , AsmUtil . L_SIGNATURE_JAVA_LANG_CLASS ) ; super . mv . visitLdcInsn ( Type . getType ( ' ' + wd . superReference + ' ' ) ) ; } if ( ir . isPassThis ( ) ) { desc = appendArgument ( desc , AsmUtil . L_SIGNATURE_JAVA_LANG_OBJECT ) ; super . mv . visitVarInsn ( ALOAD , 0 ) ; } super . visitMethodInsn ( INVOKESTATIC , owner , name , desc , false ) ; }


Input: Appends argument to the existing description . [CODESPLIT] protected static String appendArgument ( final String desc , final String type ) { int ndx = desc . indexOf ( ' ' ) ; return desc . substring ( 0 , ndx ) + type + desc . substring ( ndx ) ; }


Input: Prepends argument to the existing description . [CODESPLIT] protected static String prependArgument ( final String desc , final String type ) { int ndx = desc . indexOf ( ' ' ) ; ndx ++ ; return desc . substring ( 0 , ndx ) + type + desc . substring ( ndx ) ; }


Input: Changes return type . [CODESPLIT] protected static String changeReturnType ( final String desc , final String type ) { int ndx = desc . indexOf ( ' ' ) ; return desc . substring ( 0 , ndx + 1 ) + type ; }


Input: Cleans unnecessary whitespaces . [CODESPLIT] @ Override public void text ( final CharSequence text ) { if ( ! strip ) { super . text ( text ) ; return ; } int textLength = text . length ( ) ; char [ ] dest = new char [ textLength ] ; int ndx = 0 ; boolean regularChar = true ; for ( int i = 0 ; i < textLength ; i ++ ) { char c = text . charAt ( i ) ; if ( CharUtil . isWhitespace ( c ) ) { if ( regularChar ) { regularChar = false ; c = ' ' ; } else { continue ; } } else { regularChar = true ; } dest [ ndx ] = c ; ndx ++ ; } if ( regularChar || ( ndx != 1 ) ) { super . text ( CharBuffer . wrap ( dest , 0 , ndx ) ) ; strippedCharsCount += textLength - ndx ; } else { strippedCharsCount += textLength ; } }


Input: Registers default set of converters . [CODESPLIT] public void registerDefaults ( ) { register ( String . class , new StringConverter ( ) ) ; register ( String [ ] . class , new StringArrayConverter ( this ) ) ; IntegerConverter integerConverter = new IntegerConverter ( ) ; register ( Integer . class , integerConverter ) ; register ( int . class , integerConverter ) ; register ( MutableInteger . class , new MutableIntegerConverter ( this ) ) ; ShortConverter shortConverter = new ShortConverter ( ) ; register ( Short . class , shortConverter ) ; register ( short . class , shortConverter ) ; register ( MutableShort . class , new MutableShortConverter ( this ) ) ; LongConverter longConverter = new LongConverter ( ) ; register ( Long . class , longConverter ) ; register ( long . class , longConverter ) ; register ( MutableLong . class , new MutableLongConverter ( this ) ) ; ByteConverter byteConverter = new ByteConverter ( ) ; register ( Byte . class , byteConverter ) ; register ( byte . class , byteConverter ) ; register ( MutableByte . class , new MutableByteConverter ( this ) ) ; FloatConverter floatConverter = new FloatConverter ( ) ; register ( Float . class , floatConverter ) ; register ( float . class , floatConverter ) ; register ( MutableFloat . class , new MutableFloatConverter ( this ) ) ; DoubleConverter doubleConverter = new DoubleConverter ( ) ; register ( Double . class , doubleConverter ) ; register ( double . class , doubleConverter ) ; register ( MutableDouble . class , new MutableDoubleConverter ( this ) ) ; BooleanConverter booleanConverter = new BooleanConverter ( ) ; register ( Boolean . class , booleanConverter ) ; register ( boolean . class , booleanConverter ) ; CharacterConverter characterConverter = new CharacterConverter ( ) ; register ( Character . class , characterConverter ) ; register ( char . class , characterConverter ) ; register ( byte [ ] . class , new ByteArrayConverter ( this ) ) ; register ( short [ ] . class , new ShortArrayConverter ( this ) ) ; register ( int [ ] . class , new IntegerArrayConverter ( this ) ) ; register ( long [ ] . class , new LongArrayConverter ( this ) ) ; register ( float [ ] . class , new FloatArrayConverter ( this ) ) ; register ( double [ ] . class , new DoubleArrayConverter ( this ) ) ; register ( boolean [ ] . class , new BooleanArrayConverter ( this ) ) ; register ( char [ ] . class , new CharacterArrayConverter ( this ) ) ; // we don't really need these, but converters will be cached and not created every time register ( Integer [ ] . class , new ArrayConverter < Integer > ( this , Integer . class ) { @ Override protected Integer [ ] createArray ( final int length ) { return new Integer [ length ] ; } } ) ; register ( Long [ ] . class , new ArrayConverter < Long > ( this , Long . class ) { @ Override protected Long [ ] createArray ( final int length ) { return new Long [ length ] ; } } ) ; register ( Byte [ ] . class , new ArrayConverter < Byte > ( this , Byte . class ) { @ Override protected Byte [ ] createArray ( final int length ) { return new Byte [ length ] ; } } ) ; register ( Short [ ] . class , new ArrayConverter < Short > ( this , Short . class ) { @ Override protected Short [ ] createArray ( final int length ) { return new Short [ length ] ; } } ) ; register ( Float [ ] . class , new ArrayConverter < Float > ( this , Float . class ) { @ Override protected Float [ ] createArray ( final int length ) { return new Float [ length ] ; } } ) ; register ( Double [ ] . class , new ArrayConverter < Double > ( this , Double . class ) { @ Override protected Double [ ] createArray ( final int length ) { return new Double [ length ] ; } } ) ; register ( Boolean [ ] . class , new ArrayConverter < Boolean > ( this , Boolean . class ) { @ Override protected Boolean [ ] createArray ( final int length ) { return new Boolean [ length ] ; } } ) ; register ( Character [ ] . class , new ArrayConverter < Character > ( this , Character . class ) { @ Override protected Character [ ] createArray ( final int length ) { return new Character [ length ] ; } } ) ; register ( MutableInteger [ ] . class , new ArrayConverter <> ( this , MutableInteger . class ) ) ; register ( MutableLong [ ] . class , new ArrayConverter <> ( this , MutableLong . class ) ) ; register ( MutableByte [ ] . class , new ArrayConverter <> ( this , MutableByte . class ) ) ; register ( MutableShort [ ] . class , new ArrayConverter <> ( this , MutableShort . class ) ) ; register ( MutableFloat [ ] . class , new ArrayConverter <> ( this , MutableFloat . class ) ) ; register ( MutableDouble [ ] . class , new ArrayConverter <> ( this , MutableDouble . class ) ) ; register ( BigDecimal . class , new BigDecimalConverter ( ) ) ; register ( BigInteger . class , new BigIntegerConverter ( ) ) ; register ( BigDecimal [ ] . class , new ArrayConverter <> ( this , BigDecimal . class ) ) ; register ( BigInteger [ ] . class , new ArrayConverter <> ( this , BigInteger . class ) ) ; register ( java . util . Date . class , new DateConverter ( ) ) ; register ( java . sql . Date . class , new SqlDateConverter ( ) ) ; register ( Time . class , new SqlTimeConverter ( ) ) ; register ( Timestamp . class , new SqlTimestampConverter ( ) ) ; register ( Calendar . class , new CalendarConverter ( ) ) ; //		register(GregorianCalendar.class, new CalendarConverter()); register ( LocalDateTime . class , new LocalDateTimeConverter ( ) ) ; register ( LocalDate . class , new LocalDateConverter ( ) ) ; register ( LocalTime . class , new LocalTimeConverter ( ) ) ; register ( File . class , new FileConverter ( ) ) ; register ( FileUpload . class , new FileUploadConverter ( ) ) ; register ( Class . class , new ClassConverter ( ) ) ; register ( Class [ ] . class , new ClassArrayConverter ( this ) ) ; register ( URI . class , new URIConverter ( ) ) ; register ( URL . class , new URLConverter ( ) ) ; register ( Locale . class , new LocaleConverter ( ) ) ; register ( TimeZone . class , new TimeZoneConverter ( ) ) ; register ( UUID . class , new UUIDConverter ( ) ) ; }


Input: Registers a converter for specified type . User must register converter for all super - classes as well . [CODESPLIT] public < T > void register ( final Class < T > type , final TypeConverter < T > typeConverter ) { converters . put ( type , typeConverter ) ; }


Input: Retrieves converter for provided type . Only registered types are matched therefore subclasses must be also registered . [CODESPLIT] public < T > TypeConverter < T > lookup ( final Class < T > type ) { return converters . get ( type ) ; }