idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
22,200
@ Help ( help = "Delete the PhysicalNetworkFunctionRecord of a NetworkServiceRecord with specific id" ) public void deletePhysicalNetworkFunctionRecord ( final String idNsr , final String idPnfr ) throws SDKException { String url = idNsr + "/pnfrecords" + "/" + idPnfr ; requestDelete ( url ) ; }
Deletes a specific PhysicalNetworkFunctionRecord .
22,201
@ Help ( help = "Create the PhysicalNetworkFunctionRecord of a NetworkServiceRecord with specific id" ) public PhysicalNetworkFunctionRecord postPhysicalNetworkFunctionRecord ( final String idNsr , final PhysicalNetworkFunctionRecord physicalNetworkFunctionRecord ) throws SDKException { String url = idNsr + "/pnfrecords" + "/" ; return ( PhysicalNetworkFunctionRecord ) requestPost ( url , physicalNetworkFunctionRecord ) ; }
Create a new PhysicalnetworkFunctionRecord and add it ot a NetworkServiceRecord .
22,202
@ Help ( help = "Update the PhysicalNetworkFunctionRecord of a NetworkServiceRecord with specific id" ) public PhysicalNetworkFunctionRecord updatePNFD ( final String idNsr , final String idPnfr , final PhysicalNetworkFunctionRecord physicalNetworkFunctionRecord ) throws SDKException { String url = idNsr + "/pnfrecords" + "/" + idPnfr ; return ( PhysicalNetworkFunctionRecord ) requestPut ( url , physicalNetworkFunctionRecord ) ; }
Updates a specific PhysicalNetworkFunctionRecord .
22,203
@ Help ( help = "Scales out/add a VNF to a running NetworkServiceRecord with specific id" ) public void restartVnfr ( final String idNsr , final String idVnfr , String imageName ) throws SDKException { HashMap < String , Serializable > jsonBody = new HashMap < > ( ) ; jsonBody . put ( "imageName" , imageName ) ; String url = idNsr + "/vnfrecords" + "/" + idVnfr + "/restart" ; requestPost ( url , jsonBody ) ; }
Restarts a VNFR in a running NSR .
22,204
@ Help ( help = "Upgrades a VNFR to a defined VNFD in a running NSR with specific id" ) public void upgradeVnfr ( final String idNsr , final String idVnfr , final String idVnfd ) throws SDKException { HashMap < String , Serializable > jsonBody = new HashMap < > ( ) ; jsonBody . put ( "vnfdId" , idVnfd ) ; String url = idNsr + "/vnfrecords" + "/" + idVnfr + "/upgrade" ; requestPost ( url , jsonBody ) ; }
Upgrades a VNFR of a defined VNFD in a running NSR .
22,205
@ Help ( help = "Updates a VNFR to a defined VNFD in a running NSR with specific id" ) public void updateVnfr ( final String idNsr , final String idVnfr ) throws SDKException { String url = idNsr + "/vnfrecords" + "/" + idVnfr + "/update" ; requestPost ( url ) ; }
Updates a VNFR of a defined VNFD in a running NSR .
22,206
@ Help ( help = "Executes a script at runtime for a VNFR of a defined VNFD in a running NSR with specific id" ) public void executeScript ( final String idNsr , final String idVnfr , String script ) throws SDKException { String url = idNsr + "/vnfrecords" + "/" + idVnfr + "/execute-script" ; requestPost ( url , script ) ; }
Executes a script at runtime for a VNFR of a defined VNFD in a running NSR .
22,207
@ Help ( help = "Resumes a NSR that failed while executing a script in a VNFR. The id in the URL specifies the Network Service Record that will be resumed." ) public void resume ( final String idNsr ) throws SDKException { String url = idNsr + "/resume" ; requestPost ( url ) ; }
Resumes a NSR that failed while executing a script in a VNFR . The id in the URL specifies the Network Service Record that will be resumed ..
22,208
public static Token [ ] parse ( String text , boolean optimize ) { if ( text == null ) { return null ; } if ( text . length ( ) == 0 ) { Token t = new Token ( text ) ; return new Token [ ] { t } ; } Token [ ] tokens = null ; List < Token > tokenList = Tokenizer . tokenize ( text , optimize ) ; if ( ! tokenList . isEmpty ( ) ) { tokens = tokenList . toArray ( new Token [ 0 ] ) ; if ( optimize ) { tokens = Tokenizer . optimize ( tokens ) ; } } return tokens ; }
Returns an array of tokens that contains tokenized string .
22,209
public static Token [ ] makeTokens ( String text , boolean tokenize ) { if ( text == null ) { return null ; } Token [ ] tokens ; if ( tokenize ) { tokens = parse ( text ) ; } else { tokens = new Token [ 1 ] ; tokens [ 0 ] = new Token ( text ) ; } return tokens ; }
Convert the given string into tokens .
22,210
public static List < Token > tokenize ( CharSequence input , boolean textTrim ) { if ( input == null ) { throw new IllegalArgumentException ( "input must not be null" ) ; } int inputLen = input . length ( ) ; if ( inputLen == 0 ) { List < Token > tokens = new ArrayList < > ( 1 ) ; tokens . add ( new Token ( "" ) ) ; return tokens ; } int status = AT_TEXT ; int tokenStartOffset = 0 ; char symbol = Token . PARAMETER_SYMBOL ; char c ; StringBuilder nameBuf = new StringBuilder ( ) ; StringBuilder valueBuf = new StringBuilder ( ) ; StringBuilder textBuf = new StringBuilder ( ) ; List < Token > tokens = new ArrayList < > ( ) ; for ( int i = 0 ; i < inputLen ; i ++ ) { c = input . charAt ( i ) ; switch ( status ) { case AT_TEXT : textBuf . append ( c ) ; if ( Token . isTokenSymbol ( c ) ) { symbol = c ; status = AT_TOKEN_SYMBOL ; tokenStartOffset = textBuf . length ( ) - 1 ; } break ; case AT_TOKEN_SYMBOL : textBuf . append ( c ) ; if ( c == Token . START_BRACKET ) { status = AT_TOKEN_NAME ; } else { if ( Token . isTokenSymbol ( c ) ) { symbol = c ; status = AT_TOKEN_SYMBOL ; tokenStartOffset = textBuf . length ( ) - 1 ; } else { status = AT_TEXT ; } } break ; case AT_TOKEN_NAME : case AT_TOKEN_VALUE : textBuf . append ( c ) ; if ( status == AT_TOKEN_NAME ) { if ( c == Token . VALUE_SEPARATOR ) { status = AT_TOKEN_VALUE ; break ; } } if ( c == Token . END_BRACKET ) { if ( nameBuf . length ( ) > 0 || valueBuf . length ( ) > 0 ) { if ( tokenStartOffset > 0 ) { String text = trimBuffer ( textBuf , tokenStartOffset , textTrim ) ; Token token = new Token ( text ) ; tokens . add ( token ) ; } Token token = createToken ( symbol , nameBuf , valueBuf ) ; tokens . add ( token ) ; status = AT_TEXT ; textBuf . setLength ( 0 ) ; break ; } status = AT_TEXT ; break ; } if ( status == AT_TOKEN_NAME ) { if ( nameBuf . length ( ) > MAX_TOKEN_NAME_LENGTH ) { status = AT_TEXT ; nameBuf . setLength ( 0 ) ; } nameBuf . append ( c ) ; } else { valueBuf . append ( c ) ; } break ; } } if ( textBuf . length ( ) > 0 ) { String text = trimBuffer ( textBuf , textBuf . length ( ) , textTrim ) ; Token token = new Token ( text ) ; tokens . add ( token ) ; } return tokens ; }
Returns a list of tokens that contains tokenized string .
22,211
private static Token createToken ( char symbol , StringBuilder nameBuf , StringBuilder valueBuf ) { String value = null ; if ( valueBuf . length ( ) > 0 ) { value = valueBuf . toString ( ) ; valueBuf . setLength ( 0 ) ; } if ( nameBuf . length ( ) > 0 ) { TokenType type = Token . resolveTypeAsSymbol ( symbol ) ; String name = nameBuf . toString ( ) ; nameBuf . setLength ( 0 ) ; int offset = name . indexOf ( Token . GETTER_SEPARATOR ) ; if ( offset > - 1 ) { String name2 = name . substring ( 0 , offset ) ; String getter = name . substring ( offset + 1 ) ; Token token = new Token ( type , name2 ) ; if ( ! getter . isEmpty ( ) ) { token . setGetterName ( getter ) ; } token . setDefaultValue ( value ) ; return token ; } else if ( value != null ) { TokenDirectiveType directiveType = TokenDirectiveType . resolve ( name ) ; if ( directiveType != null ) { String getter = null ; String defaultValue = null ; offset = value . indexOf ( Token . GETTER_SEPARATOR ) ; if ( offset > - 1 ) { String value2 = value . substring ( 0 , offset ) ; String getter2 = value . substring ( offset + 1 ) ; value = value2 ; offset = getter2 . indexOf ( Token . VALUE_SEPARATOR ) ; if ( offset > - 1 ) { String getter3 = getter2 . substring ( 0 , offset ) ; String value3 = getter2 . substring ( offset + 1 ) ; if ( ! getter3 . isEmpty ( ) ) { getter = getter3 ; } if ( ! value3 . isEmpty ( ) ) { defaultValue = value3 ; } } else { if ( ! getter2 . isEmpty ( ) ) { getter = getter2 ; } } } Token token = new Token ( type , directiveType , value ) ; token . setGetterName ( getter ) ; token . setDefaultValue ( defaultValue ) ; return token ; } else { Token token = new Token ( type , name ) ; token . setDefaultValue ( value ) ; return token ; } } else { return new Token ( type , name ) ; } } else { return new Token ( value ) ; } }
Create a token .
22,212
public static Token [ ] optimize ( Token [ ] tokens ) { if ( tokens == null ) { return null ; } String firstVal = null ; String lastVal = null ; if ( tokens . length == 1 ) { if ( tokens [ 0 ] . getType ( ) == TokenType . TEXT ) { firstVal = tokens [ 0 ] . getDefaultValue ( ) ; } } else if ( tokens . length > 1 ) { if ( tokens [ 0 ] . getType ( ) == TokenType . TEXT ) { firstVal = tokens [ 0 ] . getDefaultValue ( ) ; } if ( tokens [ tokens . length - 1 ] . getType ( ) == TokenType . TEXT ) { lastVal = tokens [ tokens . length - 1 ] . getDefaultValue ( ) ; } } if ( firstVal != null ) { String text = trimLeadingWhitespace ( firstVal ) ; if ( ! Objects . equals ( firstVal , text ) ) { tokens [ 0 ] = new Token ( text ) ; } } if ( lastVal != null && ! lastVal . isEmpty ( ) ) { String text = trimTrailingWhitespace ( lastVal ) ; if ( ! Objects . equals ( lastVal , text ) ) { tokens [ tokens . length - 1 ] = new Token ( text ) ; } } return tokens ; }
Returns an array of tokens that is optimized . Eliminates unnecessary white spaces for the first and last tokens .
22,213
private static String trimLeadingWhitespace ( String string ) { if ( string . isEmpty ( ) ) { return string ; } int start = 0 ; char c ; for ( int i = 0 ; i < string . length ( ) ; i ++ ) { c = string . charAt ( i ) ; if ( ! Character . isWhitespace ( c ) ) { start = i ; break ; } } if ( start == 0 ) { return string ; } return string . substring ( start ) ; }
Returns a string that contains a copy of a specified string without leading whitespaces .
22,214
private static String trimTrailingWhitespace ( String string ) { int end = 0 ; char c ; for ( int i = string . length ( ) - 1 ; i >= 0 ; i -- ) { c = string . charAt ( i ) ; if ( ! Character . isWhitespace ( c ) ) { end = i ; break ; } } if ( end == 0 ) { return string ; } return string . substring ( 0 , end + 1 ) ; }
Returns a string that contains a copy of a specified string without trailing whitespaces .
22,215
public InputSource resolveEntity ( String publicId , String systemId ) throws SAXException { if ( validating ) { try { InputSource source = null ; if ( publicId != null ) { String path = doctypeMap . get ( publicId . toUpperCase ( ) ) ; source = getInputSource ( path ) ; } if ( source == null && systemId != null ) { String path = doctypeMap . get ( systemId . toUpperCase ( ) ) ; source = getInputSource ( path ) ; } return source ; } catch ( Exception e ) { throw new SAXException ( e . toString ( ) ) ; } } else { return new InputSource ( new StringReader ( "" ) ) ; } }
Converts a public DTD into a local one .
22,216
public static Pointcut createPointcut ( PointcutRule pointcutRule ) { if ( pointcutRule . getPointcutType ( ) == PointcutType . REGEXP ) { return createRegexpPointcut ( pointcutRule . getPointcutPatternRuleList ( ) ) ; } else { return createWildcardPointcut ( pointcutRule . getPointcutPatternRuleList ( ) ) ; } }
Creates a new Pointcut instance .
22,217
@ SuppressWarnings ( "rawtypes" ) protected String parseStringParameter ( Map params , String paramName ) { Object paramModel = params . get ( paramName ) ; if ( paramModel == null ) { return null ; } if ( ! ( paramModel instanceof SimpleScalar ) ) { throw new IllegalArgumentException ( paramName + " must be string" ) ; } return ( ( SimpleScalar ) paramModel ) . getAsString ( ) ; }
Parse string parameter .
22,218
@ SuppressWarnings ( "rawtypes" ) protected String [ ] parseSequenceParameter ( Map params , String paramName ) throws TemplateModelException { Object paramModel = params . get ( paramName ) ; if ( paramModel == null ) { return null ; } if ( ! ( paramModel instanceof SimpleSequence ) ) { throw new IllegalArgumentException ( paramName + " must be sequence" ) ; } List < String > list = transformSimpleSequenceAsStringList ( ( SimpleSequence ) paramModel , paramName ) ; return list . toArray ( new String [ 0 ] ) ; }
Parse sequence parameter .
22,219
private List < String > transformSimpleSequenceAsStringList ( SimpleSequence sequence , String paramName ) throws TemplateModelException { List < String > list = new ArrayList < > ( ) ; int size = sequence . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { TemplateModel model = sequence . get ( i ) ; if ( ! ( model instanceof SimpleScalar ) ) { throw new IllegalArgumentException ( paramName + "'s item must be string" ) ; } list . add ( ( ( SimpleScalar ) model ) . getAsString ( ) ) ; } return list ; }
Transform simple sequence as string list .
22,220
public ItemRule newAttributeItemRule ( String attributeName ) { ItemRule itemRule = new ItemRule ( ) ; itemRule . setName ( attributeName ) ; addAttributeItemRule ( itemRule ) ; return itemRule ; }
Adds a new attribute rule with the specified name and returns it .
22,221
public static EchoActionRule newInstance ( String id , Boolean hidden ) { EchoActionRule echoActionRule = new EchoActionRule ( ) ; echoActionRule . setActionId ( id ) ; echoActionRule . setHidden ( hidden ) ; return echoActionRule ; }
Returns a new derived instance of EchoActionRule .
22,222
public static EnvironmentRule newInstance ( String profile ) { EnvironmentRule environmentRule = new EnvironmentRule ( ) ; environmentRule . setProfile ( profile ) ; return environmentRule ; }
Returns a new instance of EnvironmentRule .
22,223
public String getName ( Activity activity ) { if ( nameTokens != null && nameTokens . length > 0 ) { TokenEvaluator evaluator = new TokenExpression ( activity ) ; return evaluator . evaluateAsString ( nameTokens ) ; } else { return name ; } }
Gets the dispatch name .
22,224
public void setName ( String name ) { this . name = name ; List < Token > tokens = Tokenizer . tokenize ( name , true ) ; int tokenCount = 0 ; for ( Token t : tokens ) { if ( t . getType ( ) != TokenType . TEXT ) { tokenCount ++ ; } } if ( tokenCount > 0 ) { this . nameTokens = tokens . toArray ( new Token [ 0 ] ) ; } else { this . nameTokens = null ; } }
Sets the dispatch name .
22,225
public static DispatchRule replicate ( DispatchRule dispatchRule ) { DispatchRule dr = new DispatchRule ( ) ; dr . setName ( dispatchRule . getName ( ) , dispatchRule . getNameTokens ( ) ) ; dr . setContentType ( dispatchRule . getContentType ( ) ) ; dr . setEncoding ( dispatchRule . getEncoding ( ) ) ; dr . setDefaultResponse ( dispatchRule . getDefaultResponse ( ) ) ; dr . setActionList ( dispatchRule . getActionList ( ) ) ; return dr ; }
Returns a new derived instance of DispatchRule .
22,226
public Session newSession ( String id ) { long created = System . currentTimeMillis ( ) ; Session session = sessionCache . newSession ( id , created , ( defaultMaxIdleSecs > 0 ? defaultMaxIdleSecs * 1000L : - 1 ) ) ; try { sessionCache . put ( id , session ) ; sessionsCreatedStats . increment ( ) ; for ( SessionListener listener : sessionListeners ) { listener . sessionCreated ( session ) ; } return session ; } catch ( Exception e ) { log . warn ( "Failed to create a new session" , e ) ; return null ; } }
Create an entirely new Session .
22,227
private Session removeSession ( String id ) { try { Session session = sessionCache . delete ( id ) ; if ( session != null ) { session . beginInvalidate ( ) ; for ( int i = sessionListeners . size ( ) - 1 ; i >= 0 ; i -- ) { sessionListeners . get ( i ) . sessionDestroyed ( session ) ; } } return session ; } catch ( Exception e ) { log . warn ( "Failed to delete session" , e ) ; return null ; } }
Remove session from manager .
22,228
public void addEventListener ( EventListener listener ) { if ( listener instanceof SessionListener ) { sessionListeners . add ( ( SessionListener ) listener ) ; } if ( listener instanceof SessionAttributeListener ) { sessionAttributeListeners . add ( ( SessionAttributeListener ) listener ) ; } }
Adds an event listener for session - related events .
22,229
public void removeEventListener ( EventListener listener ) { if ( listener instanceof SessionListener ) { sessionListeners . remove ( listener ) ; } if ( listener instanceof SessionAttributeListener ) { sessionAttributeListeners . remove ( listener ) ; } }
Removes an event listener for for session - related events .
22,230
private static String getMessage ( Collection < Object > brokenReferences ) { StringBuilder sb = new StringBuilder ( ) ; for ( Object o : brokenReferences ) { if ( sb . length ( ) > 0 ) { sb . append ( ", " ) ; } sb . append ( o ) ; } return "Unable to resolve reference to bean [" + sb . toString ( ) + "]" ; }
Gets the detail message .
22,231
public void parse ( RuleAppender ruleAppender ) throws Exception { InputStream inputStream = null ; try { ruleAppender . setNodeTracker ( parser . getNodeTracker ( ) ) ; inputStream = ruleAppender . getInputStream ( ) ; InputSource inputSource = new InputSource ( inputStream ) ; inputSource . setSystemId ( ruleAppender . getQualifiedName ( ) ) ; parser . parse ( inputSource ) ; } catch ( Exception e ) { throw new Exception ( "Error parsing aspectran configuration" , e ) ; } finally { if ( inputStream != null ) { try { inputStream . close ( ) ; } catch ( IOException e ) { } } } }
Parses the aspectran configuration .
22,232
private void addDescriptionNodelets ( ) { parser . setXpath ( "/aspectran/description" ) ; parser . addNodelet ( attrs -> { String style = attrs . get ( "style" ) ; parser . pushObject ( style ) ; } ) ; parser . addNodeEndlet ( text -> { String style = parser . popObject ( ) ; if ( style != null ) { text = TextStyler . styling ( text , style ) ; } if ( StringUtils . hasText ( text ) ) { assistant . getAssistantLocal ( ) . setDescription ( text ) ; } } ) ; }
Adds the description nodelets .
22,233
private void addSettingsNodelets ( ) { parser . setXpath ( "/aspectran/settings" ) ; parser . addNodeEndlet ( text -> { assistant . applySettings ( ) ; } ) ; parser . setXpath ( "/aspectran/settings/setting" ) ; parser . addNodelet ( attrs -> { String name = attrs . get ( "name" ) ; String value = attrs . get ( "value" ) ; assistant . putSetting ( name , value ) ; parser . pushObject ( name ) ; } ) ; parser . addNodeEndlet ( text -> { String name = parser . popObject ( ) ; if ( text != null ) { assistant . putSetting ( name , text ) ; } } ) ; }
Adds the settings nodelets .
22,234
private void addTypeAliasNodelets ( ) { parser . setXpath ( "/aspectran/typeAliases" ) ; parser . addNodeEndlet ( text -> { if ( StringUtils . hasLength ( text ) ) { Parameters parameters = new VariableParameters ( text ) ; for ( String alias : parameters . getParameterNameSet ( ) ) { assistant . addTypeAlias ( alias , parameters . getString ( alias ) ) ; } } } ) ; parser . setXpath ( "/aspectran/typeAliases/typeAlias" ) ; parser . addNodelet ( attrs -> { String alias = attrs . get ( "alias" ) ; String type = attrs . get ( "type" ) ; assistant . addTypeAlias ( alias , type ) ; } ) ; }
Adds the type alias nodelets .
22,235
private void addAppendNodelets ( ) { parser . setXpath ( "/aspectran/append" ) ; parser . addNodelet ( attrs -> { String file = attrs . get ( "file" ) ; String resource = attrs . get ( "resource" ) ; String url = attrs . get ( "url" ) ; String format = attrs . get ( "format" ) ; String profile = attrs . get ( "profile" ) ; RuleAppendHandler appendHandler = assistant . getRuleAppendHandler ( ) ; if ( appendHandler != null ) { AppendRule appendRule = AppendRule . newInstance ( file , resource , url , format , profile ) ; appendHandler . pending ( appendRule ) ; } } ) ; }
Adds the append nodelets .
22,236
public static String getFullPath ( String filename ) { if ( filename == null ) { return null ; } int index = indexOfLastSeparator ( filename ) ; if ( index < 0 ) { return StringUtils . EMPTY ; } return filename . substring ( 0 , index ) ; }
Gets the path from a full filename .
22,237
public static boolean isValidFileExtension ( String filename , String allowedFileExtensions , String deniedFileExtensions ) { if ( filename == null ) { return false ; } String ext = getExtension ( filename ) . toLowerCase ( ) ; if ( allowedFileExtensions != null && ! allowedFileExtensions . isEmpty ( ) ) { if ( ext . length ( ) == 0 ) { return false ; } StringTokenizer st = new StringTokenizer ( allowedFileExtensions . toLowerCase ( ) , EXTENSIONS_SEPARATORS ) ; while ( st . hasMoreTokens ( ) ) { String ext2 = st . nextToken ( ) ; if ( ext . equals ( ext2 ) ) { return true ; } } return false ; } if ( deniedFileExtensions != null && ! deniedFileExtensions . isEmpty ( ) ) { if ( ext . length ( ) == 0 ) { return true ; } StringTokenizer st = new StringTokenizer ( deniedFileExtensions . toLowerCase ( ) , EXTENSIONS_SEPARATORS ) ; while ( st . hasMoreTokens ( ) ) { String ext2 = st . nextToken ( ) ; if ( ext . equals ( ext2 ) ) { return false ; } } return true ; } return true ; }
Checks whether the extension of the filename is valid . The extension check is case - sensitive on all platforms .
22,238
public static File getUniqueFile ( File srcFile , char extSeparator ) throws IOException { if ( srcFile == null ) { throw new IllegalArgumentException ( "srcFile must not be null" ) ; } String path = getFullPath ( srcFile . getCanonicalPath ( ) ) ; String name = removeExtension ( srcFile . getName ( ) ) ; String ext = getExtension ( srcFile . getName ( ) ) ; String newName ; if ( ext != null && ! ext . isEmpty ( ) ) { newName = name + extSeparator + ext ; } else { newName = name ; } int count = 0 ; File destFile = new File ( path , newName ) ; while ( destFile . exists ( ) ) { count ++ ; if ( ext != null && ! ext . isEmpty ( ) ) { newName = name + "-" + count + extSeparator + ext ; } else { newName = name + "-" + count ; } destFile = new File ( path , newName ) ; } return ( count == 0 ? srcFile : destFile ) ; }
Returns a file name that does not overlap in the specified directory . If a duplicate file name exists it is returned by appending a number after the file name .
22,239
private void execute ( Command command , CommandLineParser lineParser ) { ConsoleWrapper wrappedConsole = new ConsoleWrapper ( console ) ; PrintWriter outputWriter = null ; try { ParsedOptions options = lineParser . parseOptions ( command . getOptions ( ) ) ; outputWriter = OutputRedirection . determineOutputWriter ( lineParser . getRedirectionList ( ) , wrappedConsole ) ; wrappedConsole . setWriter ( outputWriter ) ; command . execute ( options , wrappedConsole ) ; } catch ( ConsoleTerminatedException e ) { throw e ; } catch ( OptionParserException e ) { wrappedConsole . writeError ( e . getMessage ( ) ) ; command . printHelp ( wrappedConsole ) ; } catch ( Exception e ) { log . error ( "Failed to execute command: " + lineParser . getCommandLine ( ) , e ) ; } finally { if ( outputWriter != null ) { outputWriter . close ( ) ; } } }
Executes a command built into Aspectran Shell .
22,240
private void execute ( TransletCommandLine transletCommandLine ) { if ( transletCommandLine . getRequestName ( ) != null ) { try { service . translate ( transletCommandLine , console ) ; } catch ( TransletNotFoundException e ) { console . writeError ( "No command or translet mapped to '" + e . getTransletName ( ) + "'" ) ; } catch ( ConsoleTerminatedException e ) { throw e ; } catch ( Exception e ) { log . error ( "Failed to execute command: " + transletCommandLine . getLineParser ( ) . getCommandLine ( ) , e ) ; } } else { console . writeError ( "No command or translet mapped to '" + transletCommandLine . getLineParser ( ) . getCommandLine ( ) + "'" ) ; } }
Executes a Translet defined in Aspectran .
22,241
public void setBeanClass ( Class < ? > beanClass ) { this . beanClass = beanClass ; this . className = beanClass . getName ( ) ; this . factoryBean = FactoryBean . class . isAssignableFrom ( beanClass ) ; this . disposableBean = DisposableBean . class . isAssignableFrom ( beanClass ) ; this . initializableBean = InitializableBean . class . isAssignableFrom ( beanClass ) ; this . initializableTransletBean = InitializableTransletBean . class . isAssignableFrom ( beanClass ) ; }
Sets the bean class .
22,242
public ItemRule newConstructorArgumentItemRule ( ) { ItemRule itemRule = new ItemRule ( ) ; itemRule . setAutoNamed ( true ) ; addConstructorArgumentItemRule ( itemRule ) ; return itemRule ; }
Adds a new constructor argument item rule and returns it .
22,243
public void addConstructorArgumentItemRule ( ItemRule constructorArgumentItemRule ) { if ( constructorArgumentItemRuleMap == null ) { constructorArgumentItemRuleMap = new ItemRuleMap ( ) ; } constructorArgumentItemRuleMap . putItemRule ( constructorArgumentItemRule ) ; }
Adds the constructor argument item rule .
22,244
public ItemRule newPropertyItemRule ( String propertyName ) { ItemRule itemRule = new ItemRule ( ) ; itemRule . setName ( propertyName ) ; addPropertyItemRule ( itemRule ) ; return itemRule ; }
Adds a new property rule with the specified name and returns it .
22,245
public void addPropertyItemRule ( ItemRule propertyItemRule ) { if ( propertyItemRuleMap == null ) { propertyItemRuleMap = new ItemRuleMap ( ) ; } propertyItemRuleMap . putItemRule ( propertyItemRule ) ; }
Adds the property item rule .
22,246
public void speak ( String text ) { if ( voice == null ) { throw new IllegalStateException ( "Cannot find a voice named " + voiceName ) ; } voice . speak ( text ) ; }
Synthesizes speech of the given text and plays immediately .
22,247
protected ActivityContext createActivityContext ( ContextRuleAssistant assistant ) throws BeanReferenceException , IllegalRuleException { initContextEnvironment ( assistant ) ; AspectranActivityContext activityContext = new AspectranActivityContext ( assistant . getContextEnvironment ( ) ) ; AspectRuleRegistry aspectRuleRegistry = assistant . getAspectRuleRegistry ( ) ; BeanRuleRegistry beanRuleRegistry = assistant . getBeanRuleRegistry ( ) ; beanRuleRegistry . postProcess ( assistant ) ; BeanReferenceInspector beanReferenceInspector = assistant . getBeanReferenceInspector ( ) ; beanReferenceInspector . inspect ( beanRuleRegistry ) ; initAspectRuleRegistry ( assistant ) ; BeanProxifierType beanProxifierType = BeanProxifierType . resolve ( ( String ) assistant . getSetting ( DefaultSettingType . BEAN_PROXIFIER ) ) ; ContextBeanRegistry contextBeanRegistry = new ContextBeanRegistry ( activityContext , beanRuleRegistry , beanProxifierType ) ; TemplateRuleRegistry templateRuleRegistry = assistant . getTemplateRuleRegistry ( ) ; ContextTemplateRenderer contextTemplateRenderer = new ContextTemplateRenderer ( activityContext , templateRuleRegistry ) ; ScheduleRuleRegistry scheduleRuleRegistry = assistant . getScheduleRuleRegistry ( ) ; TransletRuleRegistry transletRuleRegistry = assistant . getTransletRuleRegistry ( ) ; activityContext . setAspectRuleRegistry ( aspectRuleRegistry ) ; activityContext . setContextBeanRegistry ( contextBeanRegistry ) ; activityContext . setScheduleRuleRegistry ( scheduleRuleRegistry ) ; activityContext . setContextTemplateRenderer ( contextTemplateRenderer ) ; activityContext . setTransletRuleRegistry ( transletRuleRegistry ) ; activityContext . setDescription ( assistant . getAssistantLocal ( ) . getDescription ( ) ) ; return activityContext ; }
Returns a new instance of ActivityContext .
22,248
private void initAspectRuleRegistry ( ContextRuleAssistant assistant ) { AspectRuleRegistry aspectRuleRegistry = assistant . getAspectRuleRegistry ( ) ; BeanRuleRegistry beanRuleRegistry = assistant . getBeanRuleRegistry ( ) ; TransletRuleRegistry transletRuleRegistry = assistant . getTransletRuleRegistry ( ) ; AspectAdviceRulePostRegister sessionScopeAspectAdviceRulePostRegister = new AspectAdviceRulePostRegister ( ) ; for ( AspectRule aspectRule : aspectRuleRegistry . getAspectRules ( ) ) { PointcutRule pointcutRule = aspectRule . getPointcutRule ( ) ; if ( pointcutRule != null ) { Pointcut pointcut = PointcutFactory . createPointcut ( pointcutRule ) ; aspectRule . setPointcut ( pointcut ) ; } if ( aspectRule . getJoinpointTargetType ( ) == JoinpointTargetType . SESSION ) { sessionScopeAspectAdviceRulePostRegister . register ( aspectRule ) ; } } AspectAdviceRulePreRegister preRegister = new AspectAdviceRulePreRegister ( aspectRuleRegistry ) ; preRegister . register ( beanRuleRegistry ) ; preRegister . register ( transletRuleRegistry ) ; boolean pointcutPatternVerifiable = assistant . isPointcutPatternVerifiable ( ) ; if ( pointcutPatternVerifiable || log . isDebugEnabled ( ) ) { int invalidPointcutPatterns = 0 ; for ( AspectRule aspectRule : aspectRuleRegistry . getAspectRules ( ) ) { Pointcut pointcut = aspectRule . getPointcut ( ) ; if ( pointcut != null ) { List < PointcutPatternRule > pointcutPatternRuleList = pointcut . getPointcutPatternRuleList ( ) ; if ( pointcutPatternRuleList != null ) { for ( PointcutPatternRule ppr : pointcutPatternRuleList ) { if ( ppr . getBeanIdPattern ( ) != null && ppr . getMatchedBeanCount ( ) == 0 ) { invalidPointcutPatterns ++ ; String msg = "No beans matching to '" + ppr . getBeanIdPattern ( ) + "'; aspectRule " + aspectRule ; if ( pointcutPatternVerifiable ) { log . error ( msg ) ; } else { log . debug ( msg ) ; } } if ( ppr . getClassNamePattern ( ) != null && ppr . getMatchedClassCount ( ) == 0 ) { invalidPointcutPatterns ++ ; String msg = "No beans matching to '@class:" + ppr . getClassNamePattern ( ) + "'; aspectRule " + aspectRule ; if ( pointcutPatternVerifiable ) { log . error ( msg ) ; } else { log . debug ( msg ) ; } } if ( ppr . getMethodNamePattern ( ) != null && ppr . getMatchedMethodCount ( ) == 0 ) { invalidPointcutPatterns ++ ; String msg = "No beans have methods matching to '^" + ppr . getMethodNamePattern ( ) + "'; aspectRule " + aspectRule ; if ( pointcutPatternVerifiable ) { log . error ( msg ) ; } else { log . debug ( msg ) ; } } } } } } if ( invalidPointcutPatterns > 0 ) { String msg = "Invalid pointcut detected: " + invalidPointcutPatterns + "; Please check the logs for more information" ; if ( pointcutPatternVerifiable ) { log . error ( msg ) ; throw new InvalidPointcutPatternException ( msg ) ; } else { log . debug ( msg ) ; } } } AspectAdviceRuleRegistry sessionScopeAarr = sessionScopeAspectAdviceRulePostRegister . getAspectAdviceRuleRegistry ( ) ; if ( sessionScopeAarr != null ) { aspectRuleRegistry . setSessionAspectAdviceRuleRegistry ( sessionScopeAarr ) ; } }
Initialize the aspect rule registry .
22,249
public String getPath ( Activity activity ) { if ( pathTokens != null && pathTokens . length > 0 ) { TokenEvaluator evaluator = new TokenExpression ( activity ) ; return evaluator . evaluateAsString ( pathTokens ) ; } else { return path ; } }
Gets the redirect path .
22,250
public void setPath ( String path ) { this . path = path ; List < Token > tokens = Tokenizer . tokenize ( path , true ) ; int tokenCount = 0 ; for ( Token t : tokens ) { if ( t . getType ( ) != TokenType . TEXT ) { tokenCount ++ ; } } if ( tokenCount > 0 ) { this . pathTokens = tokens . toArray ( new Token [ 0 ] ) ; } else { this . pathTokens = null ; } }
Sets the redirect path .
22,251
public ItemRule newParameterItemRule ( String parameterName ) { ItemRule itemRule = new ItemRule ( ) ; itemRule . setName ( parameterName ) ; addParameterItemRule ( itemRule ) ; return itemRule ; }
Adds a new parameter rule with the specified name and returns it .
22,252
public void addParameterItemRule ( ItemRule parameterItemRule ) { if ( parameterItemRuleMap == null ) { parameterItemRuleMap = new ItemRuleMap ( ) ; } parameterItemRuleMap . putItemRule ( parameterItemRule ) ; }
Adds the parameter item rule .
22,253
public void setParameters ( Map < String , String > parameters ) { if ( parameters == null || parameters . isEmpty ( ) ) { this . parameterItemRuleMap = null ; } else { ItemRuleMap itemRuleMap = new ItemRuleMap ( ) ; for ( Map . Entry < String , String > entry : parameters . entrySet ( ) ) { ItemRule ir = new ItemRule ( ) ; ir . setTokenize ( false ) ; ir . setName ( entry . getKey ( ) ) ; ir . setValue ( entry . getValue ( ) ) ; itemRuleMap . putItemRule ( ir ) ; } this . parameterItemRuleMap = itemRuleMap ; } }
Sets the parameter map .
22,254
protected String formatMessage ( String msg , Object [ ] args , Locale locale ) { if ( msg == null || ( ! this . alwaysUseMessageFormat && ( args == null || args . length == 0 ) ) ) { return msg ; } MessageFormat messageFormat = null ; synchronized ( this . messageFormatsPerMessage ) { Map < Locale , MessageFormat > messageFormatsPerLocale = this . messageFormatsPerMessage . get ( msg ) ; if ( messageFormatsPerLocale != null ) { messageFormat = messageFormatsPerLocale . get ( locale ) ; } else { messageFormatsPerLocale = new HashMap < > ( ) ; this . messageFormatsPerMessage . put ( msg , messageFormatsPerLocale ) ; } if ( messageFormat == null ) { try { messageFormat = createMessageFormat ( msg , locale ) ; } catch ( IllegalArgumentException ex ) { if ( this . alwaysUseMessageFormat ) { throw ex ; } messageFormat = INVALID_MESSAGE_FORMAT ; } messageFormatsPerLocale . put ( locale , messageFormat ) ; } } if ( messageFormat == INVALID_MESSAGE_FORMAT ) { return msg ; } synchronized ( messageFormat ) { return messageFormat . format ( args ) ; } }
Format the given message String using cached MessageFormats . By default invoked for passed - in default messages to resolve any argument placeholders found in them .
22,255
protected MessageFormat createMessageFormat ( String msg , Locale locale ) { return new MessageFormat ( ( msg != null ? msg : "" ) , locale ) ; }
Create a MessageFormat for the given message and Locale .
22,256
public static < T > T createInstance ( Class < T > cls ) { Constructor < T > ctor ; try { ctor = findConstructor ( cls ) ; } catch ( NoSuchMethodException e ) { throw new IllegalArgumentException ( "Class " + cls . getName ( ) + " has no default (no arg) constructor" ) ; } try { return ctor . newInstance ( ) ; } catch ( Exception e ) { ExceptionUtils . unwrapAndThrowAsIAE ( e , "Unable to instantiate class " + cls . getName ( ) + ": " + e . getMessage ( ) ) ; throw new IllegalArgumentException ( e ) ; } }
Method that can be called to try to create an instantiate of specified type . Instantiation is done using default no - argument constructor .
22,257
public static < T > T createInstance ( Class < T > cls , Object ... args ) { Class < ? > [ ] argTypes = new Class < ? > [ args . length ] ; for ( int i = 0 ; i < args . length ; i ++ ) { argTypes [ i ] = args [ i ] . getClass ( ) ; } return createInstance ( cls , args , argTypes ) ; }
Method that can be called to try to create an instantiate of specified type .
22,258
public static < T > Constructor < T > findConstructor ( Class < T > cls , Class < ? > ... argTypes ) throws NoSuchMethodException { Constructor < T > ctor ; try { ctor = cls . getDeclaredConstructor ( argTypes ) ; } catch ( NoSuchMethodException e ) { throw e ; } catch ( Exception e ) { throw new IllegalArgumentException ( "Unable to find constructor of class " + cls . getName ( ) + ", problem: " + e . getMessage ( ) , ExceptionUtils . getRootCause ( e ) ) ; } if ( ! Modifier . isPublic ( ctor . getModifiers ( ) ) ) { throw new IllegalArgumentException ( "Constructor for " + cls . getName ( ) + " is not accessible (non-public?): not allowed to try modify access via Reflection: can not instantiate type" ) ; } return ctor ; }
Obtain an accessible constructor for the given class and parameters .
22,259
private static boolean isLoadable ( Class < ? > clazz , ClassLoader classLoader ) { try { return ( clazz == classLoader . loadClass ( clazz . getName ( ) ) ) ; } catch ( ClassNotFoundException ex ) { return false ; } }
Check whether the given class is loadable in the given ClassLoader .
22,260
public static Object invokeExactStaticMethod ( Class < ? > objectClass , String methodName ) throws NoSuchMethodException , IllegalAccessException , InvocationTargetException { return invokeExactStaticMethod ( objectClass , methodName , EMPTY_OBJECT_ARRAY , EMPTY_CLASS_PARAMETERS ) ; }
Invoke a static method that has no parameters .
22,261
private RequestContext createRequestContext ( final HttpServletRequest req ) { return new RequestContext ( ) { public String getCharacterEncoding ( ) { return req . getCharacterEncoding ( ) ; } public String getContentType ( ) { return req . getContentType ( ) ; } public int getContentLength ( ) { return req . getContentLength ( ) ; } public InputStream getInputStream ( ) throws IOException { return req . getInputStream ( ) ; } } ; }
Creates a RequestContext needed by Jakarta Commons Upload .
22,262
public boolean matches ( CharSequence input ) { separatorCount = - 1 ; separatorIndex = 0 ; if ( input == null ) { this . input = null ; separatorFlags = null ; return false ; } this . input = input ; separatorFlags = new int [ input . length ( ) ] ; boolean result = matches ( pattern , input , separatorFlags ) ; if ( result ) { for ( int i = separatorFlags . length - 1 ; i >= 0 ; i -- ) { if ( separatorFlags [ i ] > 0 ) { separatorCount = separatorFlags [ i ] ; break ; } } } return result ; }
Checks whether a string matches a given wildcard pattern .
22,263
private boolean isProfileActive ( String profile ) { validateProfile ( profile ) ; Set < String > currentActiveProfiles = doGetActiveProfiles ( ) ; return ( currentActiveProfiles . contains ( profile ) || ( currentActiveProfiles . isEmpty ( ) && doGetDefaultProfiles ( ) . contains ( profile ) ) ) ; }
Returns whether the given profile is active or if active profiles are empty whether the profile should be active by default .
22,264
protected void indent ( ) throws IOException { if ( prettyPrint ) { for ( int i = 0 ; i < indentDepth ; i ++ ) { writer . write ( indentString ) ; } } }
Write a tab character to a character stream .
22,265
public JsonWriter writeName ( String name ) throws IOException { indent ( ) ; writer . write ( escape ( name ) ) ; writer . write ( ":" ) ; if ( prettyPrint ) { writer . write ( " " ) ; } willWriteValue = true ; return this ; }
Writes a key name to a character stream .
22,266
public JsonWriter openSquareBracket ( ) throws IOException { if ( ! willWriteValue ) { indent ( ) ; } writer . write ( "[" ) ; nextLine ( ) ; indentDepth ++ ; willWriteValue = false ; return this ; }
Open a single square bracket .
22,267
public static String stringify ( Object object , boolean prettyPrint ) throws IOException { if ( prettyPrint ) { return stringify ( object , DEFAULT_INDENT_STRING ) ; } else { return stringify ( object , null ) ; } }
Converts an object to a JSON formatted string . If pretty - printing is enabled includes spaces tabs and new - lines to make the format more readable . The default indentation string is a tab character .
22,268
public static String stringify ( Object object , String indentString ) throws IOException { if ( object == null ) { return null ; } Writer out = new StringWriter ( ) ; JsonWriter jsonWriter = new JsonWriter ( out , indentString ) ; jsonWriter . write ( object ) ; jsonWriter . close ( ) ; return out . toString ( ) ; }
Converts an object to a JSON formatted string . If pretty - printing is enabled includes spaces tabs and new - lines to make the format more readable .
22,269
public void putSetting ( String name , String value ) throws IllegalRuleException { if ( StringUtils . isEmpty ( name ) ) { throw new IllegalRuleException ( "Default setting name can not be null" ) ; } DefaultSettingType settingType = DefaultSettingType . resolve ( name ) ; if ( settingType == null ) { throw new IllegalRuleException ( "No such default setting name as '" + name + "'" ) ; } settings . put ( settingType , value ) ; }
Puts the setting value .
22,270
public String resolveAliasType ( String alias ) { String type = getAliasedType ( alias ) ; return ( type == null ? alias : type ) ; }
Returns a type of an aliased type that is defined by assigning the type to the alias . If aliased type is not found it returns alias .
22,271
private void setAssistantLocal ( AssistantLocal newAssistantLocal ) { this . assistantLocal = newAssistantLocal ; scheduleRuleRegistry . setAssistantLocal ( newAssistantLocal ) ; transletRuleRegistry . setAssistantLocal ( newAssistantLocal ) ; templateRuleRegistry . setAssistantLocal ( newAssistantLocal ) ; }
Sets the assistant local .
22,272
public AssistantLocal backupAssistantLocal ( ) { AssistantLocal oldAssistantLocal = assistantLocal ; AssistantLocal newAssistantLocal = assistantLocal . replicate ( ) ; setAssistantLocal ( newAssistantLocal ) ; return oldAssistantLocal ; }
Backup the assistant local .
22,273
public void resolveAdviceBeanClass ( AspectRule aspectRule ) throws IllegalRuleException { String beanIdOrClass = aspectRule . getAdviceBeanId ( ) ; if ( beanIdOrClass != null ) { Class < ? > beanClass = resolveBeanClass ( beanIdOrClass , aspectRule ) ; if ( beanClass != null ) { aspectRule . setAdviceBeanClass ( beanClass ) ; reserveBeanReference ( beanClass , aspectRule ) ; } else { reserveBeanReference ( beanIdOrClass , aspectRule ) ; } } }
Resolve bean class for the aspect rule .
22,274
public void resolveActionBeanClass ( BeanMethodActionRule beanMethodActionRule ) throws IllegalRuleException { String beanIdOrClass = beanMethodActionRule . getBeanId ( ) ; if ( beanIdOrClass != null ) { Class < ? > beanClass = resolveBeanClass ( beanIdOrClass , beanMethodActionRule ) ; if ( beanClass != null ) { beanMethodActionRule . setBeanClass ( beanClass ) ; reserveBeanReference ( beanClass , beanMethodActionRule ) ; } else { reserveBeanReference ( beanIdOrClass , beanMethodActionRule ) ; } } }
Resolve bean class for bean method action rule .
22,275
public void resolveFactoryBeanClass ( BeanRule beanRule ) throws IllegalRuleException { String beanIdOrClass = beanRule . getFactoryBeanId ( ) ; if ( beanRule . isFactoryOffered ( ) && beanIdOrClass != null ) { Class < ? > beanClass = resolveBeanClass ( beanIdOrClass , beanRule ) ; if ( beanClass != null ) { beanRule . setFactoryBeanClass ( beanClass ) ; reserveBeanReference ( beanClass , beanRule ) ; } else { reserveBeanReference ( beanIdOrClass , beanRule ) ; } } }
Resolve bean class for factory bean rule .
22,276
public void resolveBeanClass ( ItemRule itemRule ) throws IllegalRuleException { Iterator < Token [ ] > it = ItemRule . tokenIterator ( itemRule ) ; if ( it != null ) { while ( it . hasNext ( ) ) { Token [ ] tokens = it . next ( ) ; if ( tokens != null ) { for ( Token token : tokens ) { resolveBeanClass ( token ) ; } } } } }
Resolve bean class .
22,277
public void resolveBeanClass ( Token [ ] tokens ) throws IllegalRuleException { if ( tokens != null ) { for ( Token token : tokens ) { resolveBeanClass ( token ) ; } } }
Resolve bean class for token .
22,278
public void resolveBeanClass ( AutowireRule autowireRule ) throws IllegalRuleException { if ( autowireRule . getTargetType ( ) == AutowireTargetType . FIELD ) { if ( autowireRule . isRequired ( ) ) { Class < ? > [ ] types = autowireRule . getTypes ( ) ; String [ ] qualifiers = autowireRule . getQualifiers ( ) ; reserveBeanReference ( qualifiers [ 0 ] , types [ 0 ] , autowireRule ) ; } } else if ( autowireRule . getTargetType ( ) == AutowireTargetType . FIELD_VALUE ) { Token token = autowireRule . getToken ( ) ; resolveBeanClass ( token , autowireRule ) ; } else if ( autowireRule . getTargetType ( ) == AutowireTargetType . METHOD || autowireRule . getTargetType ( ) == AutowireTargetType . CONSTRUCTOR ) { if ( autowireRule . isRequired ( ) ) { Class < ? > [ ] types = autowireRule . getTypes ( ) ; String [ ] qualifiers = autowireRule . getQualifiers ( ) ; for ( int i = 0 ; i < types . length ; i ++ ) { reserveBeanReference ( qualifiers [ i ] , types [ i ] , autowireRule ) ; } } } }
Resolve bean class for the autowire rule .
22,279
public void resolveBeanClass ( ScheduleRule scheduleRule ) throws IllegalRuleException { String beanId = scheduleRule . getSchedulerBeanId ( ) ; if ( beanId != null ) { Class < ? > beanClass = resolveBeanClass ( beanId , scheduleRule ) ; if ( beanClass != null ) { scheduleRule . setSchedulerBeanClass ( beanClass ) ; reserveBeanReference ( beanClass , scheduleRule ) ; } else { reserveBeanReference ( beanId , scheduleRule ) ; } } }
Resolve bean class for the schedule rule .
22,280
public void resolveBeanClass ( TemplateRule templateRule ) throws IllegalRuleException { String beanId = templateRule . getEngineBeanId ( ) ; if ( beanId != null ) { Class < ? > beanClass = resolveBeanClass ( beanId , templateRule ) ; if ( beanClass != null ) { templateRule . setEngineBeanClass ( beanClass ) ; reserveBeanReference ( beanClass , templateRule ) ; } else { reserveBeanReference ( beanId , templateRule ) ; } } else { resolveBeanClass ( templateRule . getTemplateTokens ( ) ) ; } }
Resolve bean class for the template rule .
22,281
public Collection < BeanRule > getBeanRules ( ) { Collection < BeanRule > idBasedBeanRules = beanRuleRegistry . getIdBasedBeanRules ( ) ; Collection < Set < BeanRule > > typeBasedBeanRules = beanRuleRegistry . getTypeBasedBeanRules ( ) ; Collection < BeanRule > configurableBeanRules = beanRuleRegistry . getConfigurableBeanRules ( ) ; int capacity = idBasedBeanRules . size ( ) ; for ( Set < BeanRule > brs : typeBasedBeanRules ) { capacity += brs . size ( ) ; } capacity += configurableBeanRules . size ( ) ; capacity = ( int ) ( capacity / 0.9f ) + 1 ; Set < BeanRule > beanRuleSet = new HashSet < > ( capacity , 0.9f ) ; beanRuleSet . addAll ( idBasedBeanRules ) ; for ( Set < BeanRule > brs : typeBasedBeanRules ) { beanRuleSet . addAll ( brs ) ; } beanRuleSet . addAll ( configurableBeanRules ) ; return beanRuleSet ; }
Returns all bean rules .
22,282
protected MessageFormat resolveCode ( String code , Locale locale ) { MessageFormat messageFormat = null ; for ( int i = 0 ; messageFormat == null && i < this . basenames . length ; i ++ ) { ResourceBundle bundle = getResourceBundle ( this . basenames [ i ] , locale ) ; if ( bundle != null ) { messageFormat = getMessageFormat ( bundle , code , locale ) ; } } return messageFormat ; }
Resolves the given message code as key in the registered resource bundles using a cached MessageFormat instance per message code .
22,283
protected ResourceBundle getResourceBundle ( String basename , Locale locale ) { if ( this . cacheMillis >= 0 ) { return doGetBundle ( basename , locale ) ; } else { Map < Locale , ResourceBundle > localeMap = this . cachedResourceBundles . get ( basename ) ; if ( localeMap != null ) { ResourceBundle bundle = localeMap . get ( locale ) ; if ( bundle != null ) { return bundle ; } } try { ResourceBundle bundle = doGetBundle ( basename , locale ) ; if ( localeMap == null ) { localeMap = new ConcurrentHashMap < > ( ) ; Map < Locale , ResourceBundle > existing = this . cachedResourceBundles . putIfAbsent ( basename , localeMap ) ; if ( existing != null ) { localeMap = existing ; } } localeMap . put ( locale , bundle ) ; return bundle ; } catch ( MissingResourceException ex ) { log . warn ( "ResourceBundle [" + basename + "] not found for MessageSource: " + ex . getMessage ( ) ) ; return null ; } } }
Return a ResourceBundle for the given basename and code fetching already generated MessageFormats from the cache .
22,284
protected ResourceBundle doGetBundle ( String basename , Locale locale ) throws MissingResourceException { return ResourceBundle . getBundle ( basename , locale , getClassLoader ( ) , new MessageSourceControl ( ) ) ; }
Obtain the resource bundle for the given basename and Locale .
22,285
protected MessageFormat getMessageFormat ( ResourceBundle bundle , String code , Locale locale ) throws MissingResourceException { Map < String , Map < Locale , MessageFormat > > codeMap = this . cachedBundleMessageFormats . get ( bundle ) ; Map < Locale , MessageFormat > localeMap = null ; if ( codeMap != null ) { localeMap = codeMap . get ( code ) ; if ( localeMap != null ) { MessageFormat result = localeMap . get ( locale ) ; if ( result != null ) { return result ; } } } String msg = getStringOrNull ( bundle , code ) ; if ( msg != null ) { if ( codeMap == null ) { codeMap = new ConcurrentHashMap < > ( ) ; Map < String , Map < Locale , MessageFormat > > existing = this . cachedBundleMessageFormats . putIfAbsent ( bundle , codeMap ) ; if ( existing != null ) { codeMap = existing ; } } if ( localeMap == null ) { localeMap = new ConcurrentHashMap < > ( ) ; Map < Locale , MessageFormat > existing = codeMap . putIfAbsent ( code , localeMap ) ; if ( existing != null ) { localeMap = existing ; } } MessageFormat result = createMessageFormat ( msg , locale ) ; localeMap . put ( locale , result ) ; return result ; } return null ; }
Return a MessageFormat for the given bundle and code fetching already generated MessageFormats from the cache .
22,286
public void addNodelet ( String xpath , NodeletAdder nodeletAdder ) { nodeletAdder . add ( xpath , this ) ; setXpath ( xpath ) ; }
Adds the nodelet .
22,287
private void parseMultipartFormData ( ) { String multipartFormDataParser = getSetting ( MULTIPART_FORM_DATA_PARSER_SETTING_NAME ) ; if ( multipartFormDataParser == null ) { throw new MultipartRequestParseException ( "The setting name 'multipartFormDataParser' for multipart " + "form data parsing is not specified. Please specify 'multipartFormDataParser' via Aspect so " + "that Translet can parse multipart form data." ) ; } MultipartFormDataParser parser = getBean ( multipartFormDataParser ) ; if ( parser == null ) { throw new MultipartRequestParseException ( "No bean named '" + multipartFormDataParser + "' is defined" ) ; } parser . parse ( getRequestAdapter ( ) ) ; }
Parse the multipart form data .
22,288
public String getHeader ( String name ) { return ( headers != null ? headers . getFirst ( name ) : null ) ; }
Returns the value of the response header with the given name .
22,289
public Collection < String > getHeaders ( String name ) { return ( headers != null ? headers . get ( name ) : null ) ; }
Returns the values of the response header with the given name .
22,290
public void setHeader ( String name , String value ) { touchHeaders ( ) . set ( name , value ) ; }
Set the given single header value under the given header name .
22,291
public void addHeader ( String name , String value ) { touchHeaders ( ) . add ( name , value ) ; }
Add the given single header value to the current list of values for the given header .
22,292
private void setInactivityTimer ( long ms ) { if ( sessionInactivityTimer == null ) { sessionInactivityTimer = new SessionInactivityTimer ( sessionHandler . getScheduler ( ) , this ) ; } sessionInactivityTimer . setIdleTimeout ( ms ) ; }
Set the session inactivity timer .
22,293
protected void stopInactivityTimer ( ) { try ( Lock ignored = locker . lockIfNotHeld ( ) ) { if ( sessionInactivityTimer != null ) { sessionInactivityTimer . setIdleTimeout ( - 1 ) ; sessionInactivityTimer = null ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Session inactivity timer stopped" ) ; } } } }
Stop the session inactivity timer .
22,294
protected boolean isExpiredAt ( long time ) { try ( Lock ignored = locker . lockIfNotHeld ( ) ) { checkValidForRead ( ) ; return sessionData . isExpiredAt ( time ) ; } }
Check to see if session has expired as at the time given .
22,295
protected boolean isIdleLongerThan ( int sec ) { long now = System . currentTimeMillis ( ) ; try ( Lock ignored = locker . lockIfNotHeld ( ) ) { return ( ( sessionData . getAccessedTime ( ) + ( sec * 1000 ) ) <= now ) ; } }
Check if the Session has been idle longer than a number of seconds .
22,296
protected void checkValidForWrite ( ) throws IllegalStateException { checkLocked ( ) ; if ( state == State . INVALID ) { throw new IllegalStateException ( "Not valid for write: session " + this ) ; } if ( state == State . INVALIDATING ) { return ; } if ( ! isResident ( ) ) { throw new IllegalStateException ( "Not valid for write: session " + this ) ; } }
Check that the session can be modified .
22,297
protected void checkValidForRead ( ) throws IllegalStateException { checkLocked ( ) ; if ( state == State . INVALID ) { throw new IllegalStateException ( "Invalid for read: session " + this ) ; } if ( state == State . INVALIDATING ) { return ; } if ( ! isResident ( ) ) { throw new IllegalStateException ( "Invalid for read: session " + this ) ; } }
Check that the session data can be read .
22,298
public void setName ( String name ) { if ( name . endsWith ( ARRAY_SUFFIX ) ) { this . name = name . substring ( 0 , name . length ( ) - 2 ) ; type = ItemType . ARRAY ; } else if ( name . endsWith ( MAP_SUFFIX ) ) { this . name = name . substring ( 0 , name . length ( ) - 2 ) ; type = ItemType . MAP ; } else { this . name = name ; if ( type == null ) { type = ItemType . SINGLE ; } } }
Sets the name of the item .
22,299
public List < String > getValueList ( ) { if ( tokensList == null ) { return null ; } if ( tokensList . isEmpty ( ) ) { return new ArrayList < > ( ) ; } else { List < String > list = new ArrayList < > ( tokensList . size ( ) ) ; for ( Token [ ] tokens : tokensList ) { list . add ( TokenParser . toString ( tokens ) ) ; } return list ; } }
Returns a list of string values of this item .