idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
21,700
public Short getShort ( Map < String , Object > data , String name ) { return get ( data , name , Short . class ) ; }
Get Short .
21,701
protected Method findGetter ( Object data , String property ) throws IntrospectionException { Class < ? > clazz = getClass ( data ) ; String key = clazz . getName ( ) + ":" + property ; Method method = methods . get ( key ) ; if ( method == null ) { Method newMethod = null ; PropertyDescriptor [ ] props = Introspector ...
Cache the method if possible using the classname and property name to allow for similar named methods .
21,702
public final int getReadIndex ( String property ) { MethodInfo method = propertyReadMethods . get ( property ) ; return ( null == method ) ? - 1 : method . index ; }
Return property read index return - 1 when not found .
21,703
public final Class < ? > getPropertyType ( String property ) { MethodInfo info = propertyWriteMethods . get ( property ) ; if ( null == info ) return null ; else return info . parameterTypes [ 0 ] ; }
Return property type return null when not found .
21,704
public final int getWriteIndex ( String property ) { MethodInfo method = propertyWriteMethods . get ( property ) ; return ( null == method ) ? - 1 : method . index ; }
Return property write index return - 1 if not found .
21,705
public final int getIndex ( String name , Object ... args ) { Integer defaultIndex = methodIndexs . get ( name ) ; if ( null != defaultIndex ) return defaultIndex . intValue ( ) ; else { final List < MethodInfo > exists = methods . get ( name ) ; if ( null != exists ) { for ( MethodInfo info : exists ) if ( info . matc...
Return method index return - 1 if not found .
21,706
public final List < MethodInfo > getMethods ( String name ) { List < MethodInfo > namedMethod = methods . get ( name ) ; if ( null == namedMethod ) return Collections . emptyList ( ) ; else return namedMethod ; }
Return public metheds according to given name
21,707
public final List < MethodInfo > getMethods ( ) { List < MethodInfo > methodInfos = CollectUtils . newArrayList ( ) ; for ( Map . Entry < String , List < MethodInfo > > entry : methods . entrySet ( ) ) { for ( MethodInfo info : entry . getValue ( ) ) methodInfos . add ( info ) ; } Collections . sort ( methodInfos ) ; r...
Return all public methods .
21,708
public static < T > List < T > getAll ( Collection < Option < T > > values ) { List < T > results = CollectUtils . newArrayList ( values . size ( ) ) ; for ( Option < T > op : values ) { if ( op . isDefined ( ) ) results . add ( op . get ( ) ) ; } return results ; }
Return all value from Option Collection
21,709
public static List < Method > getBeanSetters ( Class < ? > clazz ) { List < Method > methods = CollectUtils . newArrayList ( ) ; for ( Method m : clazz . getMethods ( ) ) { if ( m . getName ( ) . startsWith ( "set" ) && m . getName ( ) . length ( ) > 3 ) { if ( Modifier . isPublic ( m . getModifiers ( ) ) && ! Modifier...
Return list of setters
21,710
protected List < ResultConfig > buildResultConfigs ( Class < ? > clazz , PackageConfig . Builder pcb ) { List < ResultConfig > configs = CollectUtils . newArrayList ( ) ; Result [ ] results = new Result [ 0 ] ; Results rs = clazz . getAnnotation ( Results . class ) ; if ( null == rs ) { org . beangle . struts2 . annota...
generator default results by method name
21,711
public Stopwatch start ( ) { Assert . isTrue ( ! isRunning ) ; isRunning = true ; startTick = ticker . read ( ) ; return this ; }
Starts the stopwatch .
21,712
protected void populateValue ( Object entity , EntityType type , String attr , Object value ) { if ( Strings . contains ( attr , '.' ) ) { if ( null != foreignerKeys ) { boolean isForeigner = isForeigner ( attr ) ; if ( isForeigner ) { String parentPath = Strings . substringBeforeLast ( attr , "." ) ; ObjectAndType pro...
Populate single attribute
21,713
@ SuppressWarnings ( "rawtypes" ) protected ModelFactory getModelFactory ( Class clazz ) { if ( altMapWrapper && Map . class . isAssignableFrom ( clazz ) ) { return FriendlyMapModel . FACTORY ; } return super . getModelFactory ( clazz ) ; }
of FM .
21,714
protected final Pair < ? , ? > entry ( Object key , Object value ) { return Pair . of ( key , value ) ; }
Return new map entry
21,715
protected final Definition bean ( Class < ? > clazz ) { Definition def = new Definition ( clazz . getName ( ) , clazz , Scope . SINGLETON . toString ( ) ) ; def . beanName = clazz . getName ( ) + "#" + Math . abs ( System . identityHashCode ( def ) ) ; return def ; }
Generate a inner bean definition
21,716
protected Option < TextBundle > loadJavaBundle ( String bundleName , Locale locale ) { Properties properties = new Properties ( ) ; String resource = toJavaResourceName ( bundleName , locale ) ; try { InputStream is = ClassLoaders . getResourceAsStream ( resource , getClass ( ) ) ; if ( null == is ) return Option . non...
Load java properties bundle with iso - 8859 - 1
21,717
protected final String toJavaResourceName ( String bundleName , Locale locale ) { String fullName = bundleName ; final String localeName = toLocaleStr ( locale ) ; final String suffix = "properties" ; if ( ! "" . equals ( localeName ) ) fullName = fullName + "_" + localeName ; StringBuilder sb = new StringBuilder ( ful...
java properties bundle name
21,718
private String getComponentName ( ) { Class < ? > c = getClass ( ) ; String name = c . getName ( ) ; int dot = name . lastIndexOf ( '.' ) ; return name . substring ( dot + 1 ) . toLowerCase ( ) ; }
Gets the name of this component .
21,719
protected Stack < Component > getComponentStack ( ) { @ SuppressWarnings ( "unchecked" ) Stack < Component > componentStack = ( Stack < Component > ) stack . getContext ( ) . get ( COMPONENT_STACK ) ; if ( componentStack == null ) { componentStack = new Stack < Component > ( ) ; stack . getContext ( ) . put ( COMPONENT...
Gets the component stack of this component .
21,720
@ SuppressWarnings ( "unchecked" ) protected < T extends Component > T findAncestor ( Class < T > clazz ) { Stack < ? extends Component > componentStack = getComponentStack ( ) ; for ( int i = componentStack . size ( ) - 2 ; i >= 0 ; i -- ) { Component component = componentStack . get ( i ) ; if ( clazz . equals ( comp...
Finds the nearest ancestor of this component stack .
21,721
public static List < String > readLines ( File file , Charset charset ) throws IOException { InputStream in = null ; try { in = new FileInputStream ( file ) ; if ( null == charset ) { return IOs . readLines ( new InputStreamReader ( in ) ) ; } else { InputStreamReader reader = new InputStreamReader ( in , charset . nam...
Reads the contents of a file line by line to a List of Strings . The file is always closed .
21,722
public String getParamstring ( ) { StringWriter sw = new StringWriter ( ) ; Enumeration < ? > em = req . getParameterNames ( ) ; while ( em . hasMoreElements ( ) ) { String attr = ( String ) em . nextElement ( ) ; if ( attr . equals ( "method" ) ) continue ; String value = req . getParameter ( attr ) ; if ( attr . equa...
query string and form control
21,723
protected void error ( String message , Element source , Throwable cause ) { logger . error ( message ) ; }
Report an error with the given message for the given source element .
21,724
protected void checkNameUniqueness ( String beanName , List < String > aliases , Element beanElement ) { String foundName = null ; if ( StringUtils . hasText ( beanName ) && this . usedNames . contains ( beanName ) ) foundName = beanName ; if ( foundName == null ) foundName = ( String ) CollectionUtils . findFirstMatch...
Validate that the specified bean name and aliases have not been used already .
21,725
protected AbstractBeanDefinition createBeanDefinition ( String className , String parentName ) throws ClassNotFoundException { return BeanDefinitionReaderUtils . createBeanDefinition ( parentName , className , null ) ; }
Create a bean definition for the given class name and parent name .
21,726
public void parseConstructorArgElements ( Element beanEle , BeanDefinition bd ) { NodeList nl = beanEle . getChildNodes ( ) ; for ( int i = 0 ; i < nl . getLength ( ) ; i ++ ) { Node node = nl . item ( i ) ; if ( node instanceof Element && nodeNameEquals ( node , CONSTRUCTOR_ARG_ELEMENT ) ) parseConstructorArgElement (...
Parse constructor - arg sub - elements of the given bean element .
21,727
public void parsePropertyElements ( Element beanEle , BeanDefinition bd ) { NodeList nl = beanEle . getChildNodes ( ) ; for ( int i = 0 ; i < nl . getLength ( ) ; i ++ ) { Node node = nl . item ( i ) ; if ( node instanceof Element && nodeNameEquals ( node , PROPERTY_ELEMENT ) ) parsePropertyElement ( ( Element ) node ,...
Parse property sub - elements of the given bean element .
21,728
public void parseQualifierElements ( Element beanEle , AbstractBeanDefinition bd ) { NodeList nl = beanEle . getChildNodes ( ) ; for ( int i = 0 ; i < nl . getLength ( ) ; i ++ ) { Node node = nl . item ( i ) ; if ( node instanceof Element && nodeNameEquals ( node , QUALIFIER_ELEMENT ) ) parseQualifierElement ( ( Eleme...
Parse qualifier sub - elements of the given bean element .
21,729
public void parseLookupOverrideSubElements ( Element beanEle , MethodOverrides overrides ) { NodeList nl = beanEle . getChildNodes ( ) ; for ( int i = 0 ; i < nl . getLength ( ) ; i ++ ) { Node node = nl . item ( i ) ; if ( node instanceof Element && nodeNameEquals ( node , LOOKUP_METHOD_ELEMENT ) ) { Element ele = ( E...
Parse lookup - override sub - elements of the given bean element .
21,730
public void parseReplacedMethodSubElements ( Element beanEle , MethodOverrides overrides ) { NodeList nl = beanEle . getChildNodes ( ) ; for ( int i = 0 ; i < nl . getLength ( ) ; i ++ ) { Node node = nl . item ( i ) ; if ( node instanceof Element && nodeNameEquals ( node , REPLACED_METHOD_ELEMENT ) ) { Element replace...
Parse replaced - method sub - elements of the given bean element .
21,731
public void parseConstructorArgElement ( Element ele , BeanDefinition bd ) { String indexAttr = ele . getAttribute ( INDEX_ATTRIBUTE ) ; String typeAttr = ele . getAttribute ( TYPE_ATTRIBUTE ) ; String nameAttr = ele . getAttribute ( NAME_ATTRIBUTE ) ; if ( StringUtils . hasLength ( indexAttr ) ) { try { int index = In...
Parse a constructor - arg element .
21,732
public void parsePropertyElement ( Element ele , BeanDefinition bd ) { String propertyName = ele . getAttribute ( NAME_ATTRIBUTE ) ; if ( ! StringUtils . hasLength ( propertyName ) ) { error ( "Tag 'property' must have a 'name' attribute" , ele ) ; return ; } this . parseState . push ( new PropertyEntry ( propertyName ...
Parse a property element .
21,733
public void parseQualifierElement ( Element ele , AbstractBeanDefinition bd ) { String typeName = ele . getAttribute ( TYPE_ATTRIBUTE ) ; if ( ! StringUtils . hasLength ( typeName ) ) { error ( "Tag 'qualifier' must have a 'type' attribute" , ele ) ; return ; } this . parseState . push ( new QualifierEntry ( typeName )...
Parse a qualifier element .
21,734
public Object parsePropertyValue ( Element ele , BeanDefinition bd , String propertyName ) { String elementName = ( propertyName != null ) ? "<property> element for property '" + propertyName + "'" : "<constructor-arg> element" ; NodeList nl = ele . getChildNodes ( ) ; Element subElement = null ; for ( int i = 0 ; i < ...
Get the value of a property element . May be a list etc . Also used for constructor arguments propertyName being null in this case .
21,735
public Object parsePropertySubElement ( Element ele , BeanDefinition bd , String defaultValueType ) { if ( ! isDefaultNamespace ( getNamespaceURI ( ele ) ) ) { error ( "Cannot support nested element ." , ele ) ; return null ; } else if ( nodeNameEquals ( ele , BEAN_ELEMENT ) ) { BeanDefinitionHolder nestedBd = parseBea...
Parse a value ref or collection sub - element of a property or constructor - arg element .
21,736
public Object parseIdRefElement ( Element ele ) { String refName = ele . getAttribute ( BEAN_REF_ATTRIBUTE ) ; if ( ! StringUtils . hasLength ( refName ) ) { refName = ele . getAttribute ( LOCAL_REF_ATTRIBUTE ) ; if ( ! StringUtils . hasLength ( refName ) ) { error ( "Either 'bean' or 'local' is required for <idref> el...
Return a typed String value Object for the given idref element .
21,737
public Object parseValueElement ( Element ele , String defaultTypeName ) { String value = DomUtils . getTextValue ( ele ) ; String specifiedTypeName = ele . getAttribute ( TYPE_ATTRIBUTE ) ; String typeName = specifiedTypeName ; if ( ! StringUtils . hasText ( typeName ) ) typeName = defaultTypeName ; try { TypedStringV...
Return a typed String value Object for the given value element .
21,738
public Object parseArrayElement ( Element arrayEle , BeanDefinition bd ) { String elementType = arrayEle . getAttribute ( VALUE_TYPE_ATTRIBUTE ) ; NodeList nl = arrayEle . getChildNodes ( ) ; ManagedArray target = new ManagedArray ( elementType , nl . getLength ( ) ) ; target . setSource ( extractSource ( arrayEle ) ) ...
Parse an array element .
21,739
public List < Object > parseListElement ( Element collectionEle , BeanDefinition bd ) { String defaultElementType = collectionEle . getAttribute ( VALUE_TYPE_ATTRIBUTE ) ; NodeList nl = collectionEle . getChildNodes ( ) ; ManagedList < Object > target = new ManagedList < Object > ( nl . getLength ( ) ) ; target . setSo...
Parse a list element .
21,740
public Set < Object > parseSetElement ( Element collectionEle , BeanDefinition bd ) { String defaultElementType = collectionEle . getAttribute ( VALUE_TYPE_ATTRIBUTE ) ; NodeList nl = collectionEle . getChildNodes ( ) ; ManagedSet < Object > target = new ManagedSet < Object > ( nl . getLength ( ) ) ; target . setSource...
Parse a set element .
21,741
protected Object parseKeyElement ( Element keyEle , BeanDefinition bd , String defaultKeyTypeName ) { NodeList nl = keyEle . getChildNodes ( ) ; Element subElement = null ; for ( int i = 0 ; i < nl . getLength ( ) ; i ++ ) { Node node = nl . item ( i ) ; if ( node instanceof Element ) { if ( subElement != null ) error ...
Parse a key sub - element of a map element .
21,742
public Properties parsePropsElement ( Element propsEle ) { ManagedProperties props = new ManagedProperties ( ) ; props . setSource ( extractSource ( propsEle ) ) ; props . setMergeEnabled ( parseMergeAttribute ( propsEle ) ) ; List < Element > propEles = DomUtils . getChildElementsByTagName ( propsEle , PROP_ELEMENT ) ...
Parse a props element .
21,743
public boolean parseMergeAttribute ( Element collectionElement ) { String value = collectionElement . getAttribute ( MERGE_ATTRIBUTE ) ; return TRUE_VALUE . equals ( value ) ; }
Parse the merge attribute of a collection element if any .
21,744
public final void init ( FilterConfig filterConfig ) throws ServletException { Assert . notNull ( filterConfig , "FilterConfig must not be null" ) ; logger . debug ( "Initializing filter '{}'" , filterConfig . getFilterName ( ) ) ; this . filterConfig = filterConfig ; initParams ( filterConfig ) ; initFilterBean ( ) ; ...
Standard way of initializing this filter . Map config parameters onto bean properties of this filter and invoke subclass initialization .
21,745
private Class < ? > getPropertyType ( PersistentClass pc , String propertyString ) { String [ ] properties = split ( propertyString , '.' ) ; Property p = pc . getProperty ( properties [ 0 ] ) ; Component cp = ( ( Component ) p . getValue ( ) ) ; int i = 1 ; for ( ; i < properties . length ; i ++ ) { p = cp . getProper...
get component class by component property string
21,746
protected final < T > T getId ( String name , Class < T > clazz ) { Object [ ] entityIds = getAll ( name + ".id" ) ; if ( Arrays . isEmpty ( entityIds ) ) entityIds = getAll ( name + "Id" ) ; if ( Arrays . isEmpty ( entityIds ) ) entityIds = getAll ( "id" ) ; if ( Arrays . isEmpty ( entityIds ) ) return null ; else { S...
Get entity s id from shortname . id shortnameId id
21,747
protected final < T > T [ ] getIds ( String name , Class < T > clazz ) { T [ ] datas = Params . getAll ( name + ".id" , clazz ) ; if ( null == datas ) { String datastring = Params . get ( name + ".ids" ) ; if ( null == datastring ) datastring = Params . get ( name + "Ids" ) ; if ( null == datastring ) Array . newInstan...
Get entity s id array from parameters shortname . id shortname . ids shortnameIds
21,748
public void evict ( K key ) { Object existed = store . getIfPresent ( key ) ; if ( null != existed ) store . invalidate ( key ) ; }
Evict specified key
21,749
public String constructLocalLoginServiceUrl ( final HttpServletRequest request , final HttpServletResponse response , final String service , final String serverName , final String artifactParameterName , final boolean encode ) { if ( Strings . isNotBlank ( service ) ) return encode ? response . encodeURL ( service ) : ...
Construct local login Service Url
21,750
public String constructServiceUrl ( final HttpServletRequest request , final HttpServletResponse response , final String service , final String serverName ) { if ( Strings . isNotBlank ( service ) ) { return response . encodeURL ( service ) ; } final StringBuilder buffer = new StringBuilder ( ) ; if ( ! serverName . st...
Constructs a service url from the HttpServletRequest or from the given serviceUrl . Prefers the serviceUrl provided if both a serviceUrl and a serviceName .
21,751
public String constructRedirectUrl ( final String casServerLoginUrl , final String serviceParameterName , final String serviceUrl , final boolean renew , final boolean gateway ) { try { return casServerLoginUrl + ( casServerLoginUrl . indexOf ( "?" ) != - 1 ? "&" : "?" ) + serviceParameterName + "=" + URLEncoder . enco...
Constructs the URL to use to redirect to the CAS server .
21,752
public Resource createRelative ( String relativePath ) { String pathToUse = StringUtils . applyRelativePath ( this . path , relativePath ) ; return new ServletContextResource ( this . servletContext , pathToUse ) ; }
This implementation creates a ServletContextResource applying the given path relative to the path of the underlying file of this resource descriptor .
21,753
public static byte [ ] join ( List < byte [ ] > arrays ) { int maxlength = 0 ; for ( byte [ ] array : arrays ) { maxlength += array . length ; } byte [ ] rs = new byte [ maxlength ] ; int pos = 0 ; for ( byte [ ] array : arrays ) { System . arraycopy ( array , 0 , rs , pos , array . length ) ; pos += array . length ; }...
join multi array
21,754
public ActionMapping getMapping ( HttpServletRequest request , ConfigurationManager configManager ) { ActionMapping mapping = new ActionMapping ( ) ; parseNameAndNamespace ( RequestUtils . getServletPath ( request ) , mapping ) ; String method = request . getParameter ( MethodParam ) ; if ( Strings . isNotEmpty ( metho...
reserved method parameter
21,755
public String encode ( String value ) { if ( value == null ) { return null ; } StringBuilder buffer = new StringBuilder ( ) ; buffer . append ( Prefix ) ; buffer . append ( charset ) ; buffer . append ( Sep ) ; buffer . append ( getEncoding ( ) ) ; buffer . append ( Sep ) ; buffer . append ( new String ( Base64 . encod...
Encodes a string into its Base64 form using the default charset . Unsafe characters are escaped .
21,756
public String decode ( String text ) { if ( text == null ) { return null ; } if ( ( ! text . startsWith ( Prefix ) ) || ( ! text . endsWith ( Postfix ) ) ) throw new IllegalArgumentException ( "RFC 1522 violation: malformed encoded content" ) ; int terminator = text . length ( ) - 2 ; int from = 2 ; int to = text . ind...
Decodes a Base64 string into its original form . Escaped characters are converted back to their original representation .
21,757
public static Cookie getCookie ( HttpServletRequest request , String name ) { Cookie [ ] cookies = request . getCookies ( ) ; Cookie returnCookie = null ; if ( cookies == null ) { return returnCookie ; } for ( int i = 0 ; i < cookies . length ; i ++ ) { Cookie thisCookie = cookies [ i ] ; if ( thisCookie . getName ( ) ...
Convenience method to get a cookie by name
21,758
public static void deleteCookie ( HttpServletResponse response , Cookie cookie , String path ) { if ( cookie != null ) { cookie . setMaxAge ( 0 ) ; cookie . setPath ( path ) ; response . addCookie ( cookie ) ; } }
Convenience method for deleting a cookie by name
21,759
private long lastModified ( URL url ) { if ( url . getProtocol ( ) . equals ( "file" ) ) { return new File ( url . getFile ( ) ) . lastModified ( ) ; } else { try { URLConnection conn = url . openConnection ( ) ; if ( conn instanceof JarURLConnection ) { URL jarURL = ( ( JarURLConnection ) conn ) . getJarFileURL ( ) ; ...
Return url s last modified date time . saves some opening and closing
21,760
protected String processLabel ( String label , String name ) { if ( null != label ) { if ( Strings . isEmpty ( label ) ) return null ; else return getText ( label ) ; } else return getText ( name ) ; }
Process label convert empty to null
21,761
public String edit ( ) { Entity < ? > entity = getEntity ( ) ; put ( getShortName ( ) , entity ) ; editSetting ( entity ) ; return forward ( ) ; }
Edit by entity . id or id
21,762
private int findIndexOfFrom ( String query ) { if ( query . startsWith ( "from" ) ) return 0 ; int fromIdx = query . indexOf ( " from " ) ; if ( - 1 == fromIdx ) return - 1 ; final int first = query . substring ( 0 , fromIdx ) . indexOf ( "(" ) ; if ( first > 0 ) { int leftCnt = 1 ; int i = first + 1 ; while ( leftCnt ...
Find index of from
21,763
private TraversableCodeGenStrategy getTraversableStrategy ( JType rawType , Map < String , JClass > directClasses ) { if ( rawType . isPrimitive ( ) ) { return TraversableCodeGenStrategy . NO ; } JClass clazz = ( JClass ) rawType ; if ( clazz . isParameterized ( ) ) { clazz = clazz . getTypeParameters ( ) . get ( 0 ) ;...
Tests to see if the rawType is traversable
21,764
public static Os parse ( String agentString ) { if ( Strings . isEmpty ( agentString ) ) { return Os . UNKNOWN ; } for ( OsCategory category : OsCategory . values ( ) ) { String version = category . match ( agentString ) ; if ( version != null ) { String key = category . getName ( ) + "/" + version ; Os os = osMap . ge...
Parses user agent string and returns the best match . Returns Os . UNKNOWN if there is no match .
21,765
private Template getTemplate ( String templateName ) throws ParseException { try { return config . getTemplate ( templateName , "UTF-8" ) ; } catch ( ParseException e ) { throw e ; } catch ( IOException e ) { logger . error ( "Couldn't load template '{}',loader is {}" , templateName , config . getTemplateLoader ( ) . g...
Load template in hierarchical path
21,766
@ SuppressWarnings ( "unchecked" ) public < T extends R > Converter < S , T > getConverter ( Class < T > targetType ) { return ( Converter < S , T > ) converters . get ( targetType ) ; }
Return convert from S to T
21,767
public int getIndex ( String expression ) { if ( expression == null || expression . length ( ) == 0 ) { return - 1 ; } for ( int i = 0 ; i < expression . length ( ) ; i ++ ) { char c = expression . charAt ( i ) ; if ( c == Nested || c == MappedStart ) { return - 1 ; } else if ( c == IndexedStart ) { int end = expressio...
Return the index value from the property expression or - 1 .
21,768
public String getProperty ( String expression ) { if ( expression == null || expression . length ( ) == 0 ) { return expression ; } for ( int i = 0 ; i < expression . length ( ) ; i ++ ) { char c = expression . charAt ( i ) ; if ( c == Nested ) { return expression . substring ( 0 , i ) ; } else if ( c == MappedStart ||...
Return the property name from the property expression .
21,769
public boolean hasNested ( String expression ) { if ( expression == null || expression . length ( ) == 0 ) return false ; else return remove ( expression ) != null ; }
Indicates whether or not the expression contains nested property expressions or not .
21,770
public boolean isIndexed ( String expression ) { if ( expression == null || expression . length ( ) == 0 ) { return false ; } for ( int i = 0 ; i < expression . length ( ) ; i ++ ) { char c = expression . charAt ( i ) ; if ( c == Nested || c == MappedStart ) { return false ; } else if ( c == IndexedStart ) { return tru...
Indicate whether the expression is for an indexed property or not .
21,771
public String next ( String expression ) { if ( expression == null || expression . length ( ) == 0 ) { return null ; } boolean indexed = false ; boolean mapped = false ; for ( int i = 0 ; i < expression . length ( ) ; i ++ ) { char c = expression . charAt ( i ) ; if ( indexed ) { if ( c == IndexedEnd ) { return express...
Extract the next property expression from the current expression .
21,772
public String remove ( String expression ) { if ( expression == null || expression . length ( ) == 0 ) { return null ; } String property = next ( expression ) ; if ( expression . length ( ) == property . length ( ) ) { return null ; } int start = property . length ( ) ; if ( expression . charAt ( start ) == Nested ) st...
Remove the last property expresson from the current expression .
21,773
public void initFrom ( SessionFactory sessionFactory ) { Assert . notNull ( sessionFactory ) ; Stopwatch watch = new Stopwatch ( ) . start ( ) ; Map < String , ClassMetadata > classMetadatas = sessionFactory . getAllClassMetadata ( ) ; int entityCount = entityTypes . size ( ) ; int collectionCount = collectionTypes . s...
Build context from session factory
21,774
public Object put ( Object key , Object value ) { return next . put ( key , value ) ; }
put value to next
21,775
public static int count ( final String host , final char charactor ) { int count = 0 ; for ( int i = 0 ; i < host . length ( ) ; i ++ ) { if ( host . charAt ( i ) == charactor ) { count ++ ; } } return count ; }
count char in host string
21,776
public static int count ( final String host , final String searchStr ) { int count = 0 ; for ( int startIndex = 0 ; startIndex < host . length ( ) ; startIndex ++ ) { int findLoc = host . indexOf ( searchStr , startIndex ) ; if ( findLoc == - 1 ) { break ; } else { count ++ ; startIndex = findLoc + searchStr . length (...
count inner string in host string
21,777
protected static String getFileName ( String file_name ) { if ( file_name == null ) return "" ; file_name = file_name . trim ( ) ; int iPos = 0 ; iPos = file_name . lastIndexOf ( "\\" ) ; if ( iPos > - 1 ) file_name = file_name . substring ( iPos + 1 ) ; iPos = file_name . lastIndexOf ( "/" ) ; if ( iPos > - 1 ) file_n...
Returns the file name by path .
21,778
public boolean isMultiSchema ( ) { Set < String > schemas = CollectUtils . newHashSet ( ) ; for ( TableNamePattern pattern : patterns ) { schemas . add ( ( null == pattern . getSchema ( ) ) ? "" : pattern . getSchema ( ) ) ; } return schemas . size ( ) > 1 ; }
is Multiple schema for entity
21,779
public static void setActive ( boolean active ) { if ( active ) System . setProperty ( ACTIVATE_PROPERTY , "true" ) ; else System . clearProperty ( ACTIVATE_PROPERTY ) ; TimerTrace . active = active ; }
Turn profiling on or off .
21,780
public void findStaticResource ( String path , HttpServletRequest request , HttpServletResponse response ) throws IOException { processor . process ( cleanupPath ( path ) , request , response ) ; }
Locate a static resource and copy directly to the response setting the appropriate caching headers .
21,781
public List < String > getBeanNames ( Class < ? > type ) { if ( typeNames . containsKey ( type ) ) { return typeNames . get ( type ) ; } List < String > names = CollectUtils . newArrayList ( ) ; for ( Map . Entry < String , Class < ? > > entry : nameTypes . entrySet ( ) ) { if ( type . isAssignableFrom ( entry . getVal...
Get bean name list according given type
21,782
public ObjectAndType initProperty ( final Object target , Type type , final String attr ) { Object propObj = target ; Object property = null ; int index = 0 ; String [ ] attrs = Strings . split ( attr , "." ) ; while ( index < attrs . length ) { try { property = getProperty ( propObj , attrs [ index ] ) ; Type property...
Initialize target s attribuate path Return the last property value and type .
21,783
public static Browser parse ( final String agentString ) { if ( Strings . isEmpty ( agentString ) ) { return Browser . UNKNOWN ; } for ( Engine engine : Engine . values ( ) ) { String egineName = engine . name ; if ( agentString . contains ( egineName ) ) { for ( BrowserCategory category : engine . browserCategories ) ...
Iterates over all Browsers to compare the browser signature with the user agent string . If no match can be found Browser . UNKNOWN will be returned .
21,784
public boolean requireScreenshot ( final ExtendedSeleniumCommand command , boolean result ) { return ( ! command . isAssertCommand ( ) && ! command . isVerifyCommand ( ) && ! command . isWaitForCommand ( ) && screenshotPolicy == ScreenshotPolicy . STEP ) || ( ! result && ( screenshotPolicy == ScreenshotPolicy . FAILURE...
Is a screenshot desired based on the command and the test result .
21,785
private void setTimeoutOnSelenium ( ) { executeCommand ( "setTimeout" , new String [ ] { "" + this . timeout } ) ; WebDriver . Timeouts timeouts = getWebDriver ( ) . manage ( ) . timeouts ( ) ; timeouts . setScriptTimeout ( this . timeout , TimeUnit . MILLISECONDS ) ; timeouts . pageLoadTimeout ( this . timeout , TimeU...
Set the default timeout on the selenium instance .
21,786
public void addAliasForLocator ( String alias , String locator ) { LOG . info ( "Add alias: '" + alias + "' for '" + locator + "'" ) ; aliases . put ( alias , locator ) ; }
Add a new locator alias to the fixture .
21,787
public void startSeleniumServer ( final String args ) { if ( seleniumProxy != null ) { throw new IllegalStateException ( "There is already a Selenium remote server running" ) ; } try { final RemoteControlConfiguration configuration ; LOG . info ( "Starting server with arguments: '" + args + "'" ) ; String [ ] argv = St...
Start server with arguments .
21,788
private Transactional readAnnotation ( MethodInvocation invocation ) { final Method method = invocation . getMethod ( ) ; if ( method . isAnnotationPresent ( Transactional . class ) ) { return method . getAnnotation ( Transactional . class ) ; } else { throw new RuntimeException ( "Could not find Transactional annotati...
Read the Transactional annotation for a given method invocation
21,789
private final void complete ( Transaction tx , boolean readOnly ) { if ( log . isTraceEnabled ( ) ) log . trace ( "Complete " + tx ) ; if ( ! readOnly ) tx . commit ( ) ; else tx . rollback ( ) ; }
Complete the transaction
21,790
private Connection getConnection ( final ICommandLine cl ) throws SQLException , InstantiationException , IllegalAccessException , ClassNotFoundException { String database = DEFAULT_TABLE ; if ( cl . hasOption ( "database" ) ) { database = cl . getOptionValue ( "database" ) ; } String hostname = DEFAULT_HOSTNAME ; if (...
Connect to the server .
21,791
protected void configureThresholdEvaluatorBuilder ( final ThresholdsEvaluatorBuilder thrb , final ICommandLine cl ) throws BadThresholdException { if ( cl . hasOption ( "th" ) ) { for ( Object obj : cl . getOptionValues ( "th" ) ) { thrb . withThreshold ( obj . toString ( ) ) ; } } }
Override this method if you don t use the new threshold syntax . Here you must tell the threshold evaluator all the threshold it must be able to evaluate . Give a look at the source of the CheckOracle plugin for an example of a plugin that supports both old and new syntax .
21,792
private boolean evaluate ( final Metric metric , final Prefixes prefix ) { if ( metric == null || metric . getMetricValue ( ) == null ) { throw new NullPointerException ( "Value can't be null" ) ; } BigDecimal value = metric . getMetricValue ( prefix ) ; if ( ! isNegativeInfinity ( ) ) { switch ( value . compareTo ( ge...
Evaluates if the passed in value falls inside the range . The negation is ignored .
21,793
public final ReturnValue execute ( final ICommandLine cl ) { File fProcessFile = new File ( cl . getOptionValue ( "executable" ) ) ; StreamManager streamMgr = new StreamManager ( ) ; if ( ! fProcessFile . exists ( ) ) { return new ReturnValue ( Status . UNKNOWN , "Could not exec executable : " + fProcessFile . getAbsol...
The first parameter must be the full path to the executable .
21,794
public static void configureFiles ( Iterable < File > files ) { for ( File file : files ) { if ( file != null && file . exists ( ) && file . canRead ( ) ) { setup ( file ) ; return ; } } System . out . println ( "(No suitable log config file found)" ) ; }
Configures the logging environment to use the first available config file in the list printing an error if none of the files are suitable
21,795
public Set < CommandDefinition > getAllCommandDefinition ( final String pluginName ) { Set < CommandDefinition > res = new HashSet < CommandDefinition > ( ) ; for ( CommandDefinition cd : commandDefinitionsMap . values ( ) ) { if ( cd . getPluginName ( ) . equals ( pluginName ) ) { res . add ( cd ) ; } } return res ; }
Returns all the command definition that involves the given plugin .
21,796
public synchronized void initialiseFromAPIToken ( final String token ) { final String responseStr = authService . getToken ( UserManagerOAuthService . GRANT_TYPE_TOKEN_EXCHANGE , null , getOwnCallbackUri ( ) . toString ( ) , clientId , clientSecret , null , null , null , token ) ; loadAuthResponse ( responseStr ) ; }
Initialise this session reference by exchanging an API token for an access_token and refresh_token
21,797
public URI getOwnCallbackUri ( ) { String localEndpointStr = ( oauthSelfEndpoint != null ) ? oauthSelfEndpoint : localEndpoint . toString ( ) ; if ( ! localEndpointStr . endsWith ( "/" ) ) localEndpointStr += "/" ; return URI . create ( localEndpointStr + "oauth2/client/cb" ) ; }
Return the URI for this service s callback resource
21,798
public URI getAuthFlowStartEndpoint ( final String returnTo , final String scope ) { final String oauthServiceRoot = ( oauthServiceRedirectEndpoint != null ) ? oauthServiceRedirectEndpoint : oauthServiceEndpoint ; final String endpoint = oauthServiceRoot + "/oauth2/authorize" ; UriBuilder builder = UriBuilder . fromUri...
Get the endpoint to redirect a client to in order to start an OAuth2 Authorisation Flow
21,799
public URI getRedirectToFromState ( final String state ) { final String [ ] pieces = decodeState ( state ) . split ( " " , 2 ) ; if ( ! StringUtils . equals ( callbackNonce , pieces [ 0 ] ) ) { throw new LiteralRestResponseException ( Response . seeOther ( URI . create ( "/" ) ) . build ( ) ) ; } if ( pieces . length =...
Decode the state to retrieve the redirectTo value