idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
22,300 | public Map < String , String > getValueMap ( ) { if ( tokensMap == null ) { return null ; } if ( tokensMap . isEmpty ( ) ) { return new LinkedHashMap < > ( ) ; } else { Map < String , String > map = new LinkedHashMap < > ( tokensMap . size ( ) ) ; for ( Map . Entry < String , Token [ ] > entry : tokensMap . entrySet ( ) ) { map . put ( entry . getKey ( ) , TokenParser . toString ( entry . getValue ( ) ) ) ; } return map ; } } | Returns a map of string values of this item . |
22,301 | public void setValue ( Map < String , Token [ ] > tokensMap ) { if ( type == null ) { type = ItemType . MAP ; } if ( ! isMappableType ( ) ) { throw new IllegalArgumentException ( "The type of this item must be 'map' or 'properties'" ) ; } this . tokensMap = tokensMap ; } | Sets a value to this Map type item . |
22,302 | public void setValue ( Properties properties ) { if ( properties == null ) { throw new IllegalArgumentException ( "properties must not be null" ) ; } if ( type == null ) { type = ItemType . PROPERTIES ; } if ( ! isMappableType ( ) ) { throw new IllegalArgumentException ( "The type of this item must be 'properties' or 'map'" ) ; } tokensMap = new LinkedHashMap < > ( ) ; for ( String key : properties . stringPropertyNames ( ) ) { Object o = properties . get ( key ) ; if ( o instanceof Token [ ] ) { tokensMap . put ( key , ( Token [ ] ) o ) ; } else if ( o instanceof Token ) { Token [ ] tokens = new Token [ ] { ( Token ) o } ; tokensMap . put ( key , tokens ) ; } else { Token [ ] tokens = TokenParser . makeTokens ( o . toString ( ) , isTokenize ( ) ) ; putValue ( name , tokens ) ; } } } | Sets a value to this Properties type item . |
22,303 | public void setValue ( List < Token [ ] > tokensList ) { if ( type == null ) { type = ItemType . LIST ; } if ( ! isListableType ( ) ) { throw new IllegalArgumentException ( "The item type must be 'array', 'list' or 'set' for this item " + this ) ; } this . tokensList = tokensList ; } | Sets a value to this List type item . |
22,304 | public void setValue ( Set < Token [ ] > tokensSet ) { if ( tokensSet == null ) { throw new IllegalArgumentException ( "tokensSet must not be null" ) ; } if ( type == null ) { type = ItemType . SET ; } if ( ! isListableType ( ) ) { throw new IllegalArgumentException ( "The type of this item must be 'set', 'array' or 'list'" ) ; } tokensList = new ArrayList < > ( tokensSet ) ; } | Sets a value to this Set type item . |
22,305 | public boolean isListableType ( ) { return ( type == ItemType . ARRAY || type == ItemType . LIST || type == ItemType . SET ) ; } | Return whether this item is listable type . |
22,306 | public static ItemRule newInstance ( String type , String name , String valueType , String defaultValue , Boolean tokenize , Boolean mandatory , Boolean secret ) throws IllegalRuleException { ItemRule itemRule = new ItemRule ( ) ; ItemType itemType = ItemType . resolve ( type ) ; if ( type != null && itemType == null ) { throw new IllegalRuleException ( "No item type for '" + type + "'" ) ; } if ( itemType != null ) { itemRule . setType ( itemType ) ; } else { itemRule . setType ( ItemType . SINGLE ) ; } if ( ! StringUtils . isEmpty ( name ) ) { itemRule . setName ( name ) ; } else { itemRule . setAutoNamed ( true ) ; } if ( tokenize != null ) { itemRule . setTokenize ( tokenize ) ; } if ( valueType != null ) { ItemValueType itemValueType = ItemValueType . resolve ( valueType ) ; if ( itemValueType == null ) { throw new IllegalRuleException ( "No item value type for '" + valueType + "'" ) ; } itemRule . setValueType ( itemValueType ) ; } if ( defaultValue != null ) { itemRule . setDefaultValue ( defaultValue ) ; } if ( mandatory != null ) { itemRule . setMandatory ( mandatory ) ; } if ( secret != null ) { itemRule . setSecret ( secret ) ; } return itemRule ; } | Returns a new derived instance of ItemRule . |
22,307 | public static Token makeReferenceToken ( String bean , String template , String parameter , String attribute , String property ) { Token token ; if ( bean != null ) { token = new Token ( TokenType . BEAN , bean ) ; } else if ( template != null ) { token = new Token ( TokenType . TEMPLATE , template ) ; } else if ( parameter != null ) { token = new Token ( TokenType . PARAMETER , parameter ) ; } else if ( attribute != null ) { token = new Token ( TokenType . ATTRIBUTE , attribute ) ; } else if ( property != null ) { token = new Token ( TokenType . PROPERTY , property ) ; } else { token = null ; } return token ; } | Returns a made reference token . |
22,308 | public InputStream getInputStream ( ) throws IOException { InputStream inputStream = fileItem . getInputStream ( ) ; return ( inputStream != null ? inputStream : new ByteArrayInputStream ( new byte [ 0 ] ) ) ; } | Return an InputStream to read the contents of the file from . |
22,309 | public File saveAs ( File destFile , boolean overwrite ) throws IOException { if ( destFile == null ) { throw new IllegalArgumentException ( "destFile can not be null" ) ; } validateFile ( ) ; try { destFile = determineDestinationFile ( destFile , overwrite ) ; fileItem . write ( destFile ) ; } catch ( FileUploadException e ) { throw new IllegalStateException ( e . getMessage ( ) ) ; } catch ( Exception e ) { throw new IOException ( "Could not save as file " + destFile , e ) ; } setSavedFile ( destFile ) ; return destFile ; } | Save an uploaded file as a given destination file . |
22,310 | private static String makeMessage ( int lineNumber , String line , String tline , String msg ) { int columnNumber = ( tline != null ? line . indexOf ( tline ) : 0 ) ; StringBuilder sb = new StringBuilder ( ) ; if ( msg != null ) { sb . append ( msg ) ; } sb . append ( " [lineNumber: " ) . append ( lineNumber ) ; if ( columnNumber != - 1 ) { String lspace = line . substring ( 0 , columnNumber ) ; int tabCnt = StringUtils . search ( lspace , "\t" ) ; if ( tline != null && tline . length ( ) > 33 ) { tline = tline . substring ( 0 , 30 ) + "..." ; } sb . append ( ", columnNumber: " ) . append ( columnNumber + 1 ) ; if ( tabCnt != 0 ) { sb . append ( " (" ) ; sb . append ( "Tabs " ) . append ( tabCnt ) ; sb . append ( ", Spaces " ) . append ( columnNumber - tabCnt ) ; sb . append ( ")" ) ; } sb . append ( "] " ) . append ( tline ) ; } return sb . toString ( ) ; } | Create a detail message . |
22,311 | private void prepare ( String requestName , MethodType requestMethod , TransletRule transletRule , Translet parentTranslet ) { try { if ( log . isDebugEnabled ( ) ) { log . debug ( "Translet " + transletRule ) ; } newTranslet ( requestMethod , requestName , transletRule , parentTranslet ) ; if ( parentTranslet == null ) { if ( isIncluded ( ) ) { backupCurrentActivity ( ) ; saveCurrentActivity ( ) ; } else { saveCurrentActivity ( ) ; } adapt ( ) ; } prepareAspectAdviceRule ( transletRule , ( parentTranslet != null ) ) ; parseRequest ( ) ; parsePathVariables ( ) ; if ( parentTranslet == null ) { resolveLocale ( ) ; } } catch ( ActivityTerminatedException e ) { throw e ; } catch ( Exception e ) { throw new ActivityPrepareException ( "Failed to prepare activity for translet " + transletRule , e ) ; } } | Prepares a new activity for the Translet Rule by taking the results of the process that was created earlier . |
22,312 | private void produce ( ) { ContentList contentList = getTransletRule ( ) . getContentList ( ) ; if ( contentList != null ) { ProcessResult processResult = translet . getProcessResult ( ) ; if ( processResult == null ) { processResult = new ProcessResult ( contentList . size ( ) ) ; processResult . setName ( contentList . getName ( ) ) ; processResult . setExplicit ( contentList . isExplicit ( ) ) ; translet . setProcessResult ( processResult ) ; } for ( ActionList actionList : contentList ) { execute ( actionList ) ; if ( isResponseReserved ( ) ) { break ; } } } Response res = getResponse ( ) ; if ( res != null ) { ActionList actionList = res . getActionList ( ) ; if ( actionList != null ) { execute ( actionList ) ; } } } | Produce the result of the content and its subordinate actions . |
22,313 | protected String resolveRequestEncoding ( ) { String encoding = getRequestRule ( ) . getEncoding ( ) ; if ( encoding == null ) { encoding = getSetting ( RequestRule . CHARACTER_ENCODING_SETTING_NAME ) ; } return encoding ; } | Determines the request encoding . |
22,314 | protected String resolveResponseEncoding ( ) { String encoding = getRequestRule ( ) . getEncoding ( ) ; if ( encoding == null ) { encoding = resolveRequestEncoding ( ) ; } return encoding ; } | Determines the response encoding . |
22,315 | protected LocaleResolver resolveLocale ( ) { LocaleResolver localeResolver = null ; String localeResolverBeanId = getSetting ( RequestRule . LOCALE_RESOLVER_SETTING_NAME ) ; if ( localeResolverBeanId != null ) { localeResolver = getBean ( localeResolverBeanId , LocaleResolver . class ) ; localeResolver . resolveLocale ( getTranslet ( ) ) ; localeResolver . resolveTimeZone ( getTranslet ( ) ) ; } return localeResolver ; } | Resolve the current locale . |
22,316 | protected void parseDeclaredParameters ( ) { ItemRuleMap parameterItemRuleMap = getRequestRule ( ) . getParameterItemRuleMap ( ) ; if ( parameterItemRuleMap != null && ! parameterItemRuleMap . isEmpty ( ) ) { ItemEvaluator evaluator = null ; ItemRuleList missingItemRules = null ; for ( ItemRule itemRule : parameterItemRuleMap . values ( ) ) { Token [ ] tokens = itemRule . getTokens ( ) ; if ( tokens != null ) { if ( evaluator == null ) { evaluator = new ItemExpression ( this ) ; } String [ ] values = evaluator . evaluateAsStringArray ( itemRule ) ; String [ ] oldValues = getRequestAdapter ( ) . getParameterValues ( itemRule . getName ( ) ) ; if ( values != oldValues ) { getRequestAdapter ( ) . setParameter ( itemRule . getName ( ) , values ) ; } } if ( itemRule . isMandatory ( ) ) { String [ ] values = getRequestAdapter ( ) . getParameterValues ( itemRule . getName ( ) ) ; if ( values == null ) { if ( missingItemRules == null ) { missingItemRules = new ItemRuleList ( ) ; } missingItemRules . add ( itemRule ) ; } } } if ( missingItemRules != null ) { throw new MissingMandatoryParametersException ( missingItemRules ) ; } } } | Parses the declared parameters . |
22,317 | protected void parseDeclaredAttributes ( ) { ItemRuleMap attributeItemRuleMap = getRequestRule ( ) . getAttributeItemRuleMap ( ) ; if ( attributeItemRuleMap != null && ! attributeItemRuleMap . isEmpty ( ) ) { ItemEvaluator evaluator = new ItemExpression ( this ) ; for ( ItemRule itemRule : attributeItemRuleMap . values ( ) ) { Object value = evaluator . evaluate ( itemRule ) ; getRequestAdapter ( ) . setAttribute ( itemRule . getName ( ) , value ) ; } } } | Parses the declared attributes . |
22,318 | protected void execute ( ActionList actionList ) { ProcessResult processResult = translet . getProcessResult ( ) ; if ( processResult == null ) { processResult = new ProcessResult ( 1 ) ; translet . setProcessResult ( processResult ) ; } ContentResult contentResult = processResult . getContentResult ( actionList . getName ( ) , actionList . isExplicit ( ) ) ; if ( contentResult == null ) { contentResult = new ContentResult ( processResult , actionList . size ( ) ) ; contentResult . setName ( actionList . getName ( ) ) ; if ( ! processResult . isExplicit ( ) ) { contentResult . setExplicit ( actionList . isExplicit ( ) ) ; } } for ( Executable action : actionList ) { execute ( action , contentResult ) ; if ( isResponseReserved ( ) ) { break ; } } } | Execute actions . |
22,319 | private void execute ( Executable action , ContentResult contentResult ) { try { ChooseWhenRule chooseWhenRule = null ; if ( action . getCaseNo ( ) > 0 ) { ChooseRuleMap chooseRuleMap = getTransletRule ( ) . getChooseRuleMap ( ) ; if ( chooseRuleMap == null || chooseRuleMap . isEmpty ( ) ) { throw new IllegalRuleException ( "No defined choose rules" ) ; } ChooseRule chooseRule = chooseRuleMap . getChooseRule ( action . getCaseNo ( ) ) ; if ( chooseRule == null ) { throw new IllegalRuleException ( "No choose rule with case number: " + ChooseRule . toCaseGroupNo ( action . getCaseNo ( ) ) ) ; } chooseWhenRule = chooseRule . getChooseWhenRule ( action . getCaseNo ( ) ) ; if ( chooseWhenRule == null ) { throw new IllegalRuleException ( "No choose rule with case number: " + action . getCaseNo ( ) ) ; } if ( processedChooses != null && processedChooses . contains ( chooseRule . getCaseNo ( ) ) ) { return ; } if ( processedChooses == null || ! processedChooses . contains ( chooseWhenRule . getCaseNo ( ) ) ) { BooleanExpression expression = new BooleanExpression ( this ) ; if ( expression . evaluate ( chooseWhenRule ) ) { if ( processedChooses == null ) { processedChooses = new HashSet < > ( ) ; } processedChooses . add ( chooseRule . getCaseNo ( ) ) ; processedChooses . add ( chooseWhenRule . getCaseNo ( ) ) ; } else { return ; } } } if ( log . isDebugEnabled ( ) ) { log . debug ( "Action " + action ) ; } Object resultValue = action . execute ( this ) ; if ( ! action . isHidden ( ) && contentResult != null && resultValue != ActionResult . NO_RESULT ) { if ( resultValue instanceof ProcessResult ) { contentResult . addActionResult ( action , ( ProcessResult ) resultValue ) ; } else { contentResult . addActionResult ( action , resultValue ) ; } } if ( action . isLastInChooseWhen ( ) && chooseWhenRule != null && chooseWhenRule . getResponse ( ) != null ) { reserveResponse ( chooseWhenRule . getResponse ( ) ) ; } } catch ( ActionExecutionException e ) { throw e ; } catch ( Exception e ) { setRaisedException ( e ) ; throw new ActionExecutionException ( "Failed to execute action " + action , e ) ; } } | Execute action . |
22,320 | public void scanConfigurableBeans ( String ... basePackages ) throws BeanRuleException { if ( basePackages == null || basePackages . length == 0 ) { return ; } log . info ( "Auto component scanning on packages [" + StringUtils . joinCommaDelimitedList ( basePackages ) + "]" ) ; for ( String basePackage : basePackages ) { BeanClassScanner scanner = new BeanClassScanner ( classLoader ) ; List < BeanRule > beanRules = new ArrayList < > ( ) ; scanner . scan ( basePackage + ".**" , ( resourceName , targetClass ) -> { if ( targetClass . isAnnotationPresent ( Component . class ) ) { BeanRule beanRule = new BeanRule ( ) ; beanRule . setBeanClass ( targetClass ) ; beanRule . setScopeType ( ScopeType . SINGLETON ) ; beanRules . add ( beanRule ) ; } } ) ; for ( BeanRule beanRule : beanRules ) { saveConfigurableBeanRule ( beanRule ) ; } } } | Scans for annotated components . |
22,321 | public void addBeanRule ( final BeanRule beanRule ) throws IllegalRuleException { PrefixSuffixPattern prefixSuffixPattern = PrefixSuffixPattern . parse ( beanRule . getId ( ) ) ; String scanPattern = beanRule . getScanPattern ( ) ; if ( scanPattern != null ) { BeanClassScanner scanner = createBeanClassScanner ( beanRule ) ; List < BeanRule > beanRules = new ArrayList < > ( ) ; scanner . scan ( scanPattern , ( resourceName , targetClass ) -> { BeanRule beanRule2 = beanRule . replicate ( ) ; if ( prefixSuffixPattern != null ) { beanRule2 . setId ( prefixSuffixPattern . join ( resourceName ) ) ; } else { if ( beanRule . getId ( ) != null ) { beanRule2 . setId ( beanRule . getId ( ) + resourceName ) ; } else if ( beanRule . getMaskPattern ( ) != null ) { beanRule2 . setId ( resourceName ) ; } } beanRule2 . setBeanClass ( targetClass ) ; beanRules . add ( beanRule2 ) ; } ) ; for ( BeanRule beanRule2 : beanRules ) { dissectBeanRule ( beanRule2 ) ; } } else { if ( ! beanRule . isFactoryOffered ( ) ) { String className = beanRule . getClassName ( ) ; if ( prefixSuffixPattern != null ) { beanRule . setId ( prefixSuffixPattern . join ( className ) ) ; } Class < ? > beanClass ; try { beanClass = classLoader . loadClass ( className ) ; } catch ( ClassNotFoundException e ) { throw new BeanRuleException ( "Failed to load bean class" , beanRule , e ) ; } beanRule . setBeanClass ( beanClass ) ; } dissectBeanRule ( beanRule ) ; } } | Adds a bean rule . |
22,322 | protected String getMessageFromParent ( String code , Object [ ] args , Locale locale ) { MessageSource parent = getParentMessageSource ( ) ; if ( parent != null ) { if ( parent instanceof AbstractMessageSource ) { return ( ( AbstractMessageSource ) parent ) . getMessageInternal ( code , args , locale ) ; } else { return parent . getMessage ( code , args , null , locale ) ; } } return null ; } | Try to retrieve the given message from the parent MessageSource if any . |
22,323 | public void reserve ( String beanId , Class < ? > beanClass , BeanReferenceable referenceable , RuleAppender ruleAppender ) { RefererKey key = new RefererKey ( beanClass , beanId ) ; Set < RefererInfo > refererInfoSet = refererInfoMap . get ( key ) ; if ( refererInfoSet == null ) { refererInfoSet = new LinkedHashSet < > ( ) ; refererInfoSet . add ( new RefererInfo ( referenceable , ruleAppender ) ) ; refererInfoMap . put ( key , refererInfoSet ) ; } else { refererInfoSet . add ( new RefererInfo ( referenceable , ruleAppender ) ) ; } } | Reserves to bean reference inspection . |
22,324 | public void inspect ( BeanRuleRegistry beanRuleRegistry ) throws BeanReferenceException , BeanRuleException { Set < Object > brokenReferences = new LinkedHashSet < > ( ) ; for ( Map . Entry < RefererKey , Set < RefererInfo > > entry : refererInfoMap . entrySet ( ) ) { RefererKey refererKey = entry . getKey ( ) ; String beanId = refererKey . getQualifier ( ) ; Class < ? > beanClass = refererKey . getType ( ) ; Set < RefererInfo > refererInfoSet = entry . getValue ( ) ; BeanRule beanRule = null ; BeanRule [ ] beanRules = null ; if ( beanClass != null ) { beanRules = beanRuleRegistry . getBeanRules ( beanClass ) ; if ( beanRules != null ) { if ( beanRules . length == 1 ) { if ( beanId != null ) { if ( beanId . equals ( beanRules [ 0 ] . getId ( ) ) ) { beanRule = beanRules [ 0 ] ; } } else { beanRule = beanRules [ 0 ] ; } } else { if ( beanId != null ) { for ( BeanRule br : beanRules ) { if ( beanId . equals ( br . getId ( ) ) ) { beanRule = br ; break ; } } } } } if ( beanRule == null && beanRules == null ) { beanRule = beanRuleRegistry . getBeanRuleForConfig ( beanClass ) ; } } else if ( beanId != null ) { beanRule = beanRuleRegistry . getBeanRule ( beanId ) ; } if ( beanRule == null ) { if ( beanRules != null && beanRules . length > 1 ) { for ( RefererInfo refererInfo : refererInfoSet ) { if ( beanId != null ) { log . error ( "Cannot resolve reference to bean " + refererKey + "; Referer: " + refererInfo ) ; } else { log . error ( "No unique bean of type [" + beanClass + "] is defined: " + "expected single matching bean but found " + beanRules . length + ": [" + NoUniqueBeanException . getBeanDescriptions ( beanRules ) + "]; Referer: " + refererInfo ) ; } } brokenReferences . add ( refererKey ) ; } else { int count = 0 ; for ( RefererInfo refererInfo : refererInfoSet ) { if ( ! isStaticMethodReference ( refererInfo ) ) { count ++ ; log . error ( "Cannot resolve reference to bean " + refererKey + "; Referer: " + refererInfo ) ; } } if ( count > 0 ) { brokenReferences . add ( refererKey ) ; } } } else { for ( RefererInfo refererInfo : refererInfoSet ) { if ( refererInfo . getBeanRefererType ( ) == BeanRefererType . BEAN_METHOD_ACTION_RULE ) { checkTransletActionParameter ( ( BeanMethodActionRule ) refererInfo . getReferenceable ( ) , beanRule , refererInfo ) ; } } } } if ( ! brokenReferences . isEmpty ( ) ) { throw new BeanReferenceException ( brokenReferences ) ; } } | Inspect bean reference . |
22,325 | public ItemRule putItemRule ( ItemRule itemRule ) { if ( itemRule . isAutoNamed ( ) ) { autoNaming ( itemRule ) ; } return put ( itemRule . getName ( ) , itemRule ) ; } | Adds a item rule . |
22,326 | protected void rejectRequest ( Translet translet , CorsException ce ) throws CorsException { HttpServletResponse res = translet . getResponseAdaptee ( ) ; res . setStatus ( ce . getHttpStatusCode ( ) ) ; translet . setAttribute ( CORS_HTTP_STATUS_CODE , ce . getHttpStatusCode ( ) ) ; translet . setAttribute ( CORS_HTTP_STATUS_TEXT , ce . getMessage ( ) ) ; throw ce ; } | Invoked when one of the CORS checks failed . The default implementation sets the response status to 403 . |
22,327 | private boolean isAllowedAddress ( String ipAddress ) { if ( allowedAddresses == null ) { return false ; } int offset = ipAddress . lastIndexOf ( '.' ) ; if ( offset == - 1 ) { offset = ipAddress . lastIndexOf ( ':' ) ; if ( offset == - 1 ) { return false ; } } String ipAddressClass = ipAddress . substring ( 0 , offset + 1 ) + '*' ; return ( allowedAddresses . contains ( ipAddressClass ) || allowedAddresses . contains ( ipAddress ) ) ; } | Returns whether IP address is valid . |
22,328 | public byte [ ] getBytes ( ) throws IOException { InputStream input = getInputStream ( ) ; ByteArrayOutputStream output = new ByteArrayOutputStream ( ) ; final byte [ ] buffer = new byte [ DEFAULT_BUFFER_SIZE ] ; int len ; try { while ( ( len = input . read ( buffer ) ) != - 1 ) { output . write ( buffer , 0 , len ) ; } } finally { try { output . close ( ) ; } catch ( IOException e ) { } try { input . close ( ) ; } catch ( IOException e ) { } } return output . toByteArray ( ) ; } | Returns the contents of the file in a byte array . Can not use a large array of memory than the JVM Heap deal . |
22,329 | public File saveAs ( File destFile , boolean overwrite ) throws IOException { if ( destFile == null ) { throw new IllegalArgumentException ( "destFile can not be null" ) ; } try { destFile = determineDestinationFile ( destFile , overwrite ) ; final byte [ ] buffer = new byte [ DEFAULT_BUFFER_SIZE ] ; int len ; try ( InputStream input = getInputStream ( ) ; OutputStream output = new FileOutputStream ( destFile ) ) { while ( ( len = input . read ( buffer ) ) != - 1 ) { output . write ( buffer , 0 , len ) ; } } } catch ( Exception e ) { throw new IOException ( "Could not save as file " + destFile , e ) ; } setSavedFile ( destFile ) ; return destFile ; } | Save an file as a given destination file . |
22,330 | public void release ( ) { if ( file != null ) { file . setWritable ( true ) ; } if ( savedFile != null ) { savedFile . setWritable ( true ) ; } } | Sets the access permission that allow write operations on the file associated with this FileParameter . |
22,331 | public static ActivityContext getActivityContext ( ServletContext servletContext ) { ActivityContext activityContext = getActivityContext ( servletContext , ROOT_WEB_SERVICE_ATTRIBUTE ) ; if ( activityContext == null ) { throw new IllegalStateException ( "No Root AspectranWebService found; " + "No AspectranServiceListener registered?" ) ; } return activityContext ; } | Find the root ActivityContext for this web aspectran service . |
22,332 | public static ActivityContext getActivityContext ( HttpServlet servlet ) { ServletContext servletContext = servlet . getServletContext ( ) ; String attrName = STANDALONE_WEB_SERVICE_ATTRIBUTE_PREFIX + servlet . getServletName ( ) ; ActivityContext activityContext = getActivityContext ( servletContext , attrName ) ; if ( activityContext != null ) { return activityContext ; } else { return getActivityContext ( servletContext ) ; } } | Find the standalone ActivityContext for this web aspectran service . |
22,333 | private static ActivityContext getActivityContext ( ServletContext servletContext , String attrName ) { Object attr = servletContext . getAttribute ( attrName ) ; if ( attr == null ) { return null ; } if ( ! ( attr instanceof AspectranWebService ) ) { throw new IllegalStateException ( "Context attribute [" + attr + "] is not of type [" + AspectranWebService . class . getName ( ) + "]" ) ; } return ( ( CoreService ) attr ) . getActivityContext ( ) ; } | Find the ActivityContext for this web aspectran service . |
22,334 | private boolean deleteFile ( String filename ) throws Exception { if ( filename == null ) { return false ; } File file = new File ( storeDir , filename ) ; return Files . deleteIfExists ( file . toPath ( ) ) ; } | Delete the file associated with a session |
22,335 | public Set < String > doGetExpired ( final Set < String > candidates ) { final long now = System . currentTimeMillis ( ) ; Set < String > expired = new HashSet < > ( ) ; for ( String filename : sessionFileMap . values ( ) ) { try { long expiry = getExpiryFromFilename ( filename ) ; if ( expiry > 0 && expiry < now ) { expired . add ( getIdFromFilename ( filename ) ) ; } } catch ( Exception e ) { log . warn ( e . getMessage ( ) , e ) ; } } for ( String c : candidates ) { if ( ! expired . contains ( c ) ) { String filename = sessionFileMap . get ( c ) ; if ( filename == null ) { expired . add ( c ) ; } } } if ( gracePeriodSec > 0 && ( lastSweepTime == 0L || ( ( now - lastSweepTime ) >= ( 5 * TimeUnit . SECONDS . toMillis ( gracePeriodSec ) ) ) ) ) { lastSweepTime = now ; sweepDisk ( ) ; } return expired ; } | Check to see which sessions have expired . |
22,336 | private String getIdFromFilename ( String filename ) { if ( ! StringUtils . hasText ( filename ) || filename . indexOf ( '_' ) < 0 ) { return null ; } return filename . substring ( 0 , filename . lastIndexOf ( '_' ) ) ; } | Extract the session id from the filename . |
22,337 | private boolean isSessionFilename ( String filename ) { if ( ! StringUtils . hasText ( filename ) ) { return false ; } String [ ] parts = filename . split ( "_" ) ; return ( parts . length >= 2 ) ; } | Check if the filename matches our session pattern . |
22,338 | public void sweepFile ( long now , Path p ) throws Exception { if ( p == null ) { return ; } long expiry = getExpiryFromFilename ( p . getFileName ( ) . toString ( ) ) ; if ( expiry > 0 && ( ( now - expiry ) >= ( 5 * TimeUnit . SECONDS . toMillis ( gracePeriodSec ) ) ) ) { Files . deleteIfExists ( p ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Sweep deleted " + p . getFileName ( ) ) ; } } } | Check to see if the expiry on the file is very old and delete the file if so . Old means that it expired at least 5 gracePeriods ago . |
22,339 | private void save ( OutputStream os , String id , SessionData data ) throws IOException { DataOutputStream out = new DataOutputStream ( os ) ; out . writeUTF ( id ) ; out . writeLong ( data . getCreationTime ( ) ) ; out . writeLong ( data . getAccessedTime ( ) ) ; out . writeLong ( data . getLastAccessedTime ( ) ) ; out . writeLong ( data . getExpiryTime ( ) ) ; out . writeLong ( data . getMaxInactiveInterval ( ) ) ; List < String > keys = new ArrayList < > ( data . getKeys ( ) ) ; out . writeInt ( keys . size ( ) ) ; ObjectOutputStream oos = new ObjectOutputStream ( out ) ; for ( String name : keys ) { oos . writeUTF ( name ) ; oos . writeObject ( data . getAttribute ( name ) ) ; } } | Save the session data . |
22,340 | private SessionData load ( InputStream is , String expectedId ) throws Exception { try { DataInputStream di = new DataInputStream ( is ) ; String id = di . readUTF ( ) ; long created = di . readLong ( ) ; long accessed = di . readLong ( ) ; long lastAccessed = di . readLong ( ) ; long expiry = di . readLong ( ) ; long maxIdle = di . readLong ( ) ; SessionData data = newSessionData ( id , created , accessed , lastAccessed , maxIdle ) ; data . setExpiryTime ( expiry ) ; data . setMaxInactiveInterval ( maxIdle ) ; restoreAttributes ( di , di . readInt ( ) , data ) ; return data ; } catch ( Exception e ) { throw new UnreadableSessionDataException ( expectedId , e ) ; } } | Load session data from an input stream that contains session data . |
22,341 | private void restoreAttributes ( InputStream is , int size , SessionData data ) throws Exception { if ( size > 0 ) { Map < String , Object > attributes = new HashMap < > ( ) ; ObjectInputStream ois = new CustomObjectInputStream ( is ) ; for ( int i = 0 ; i < size ; i ++ ) { String key = ois . readUTF ( ) ; Object value = ois . readObject ( ) ; attributes . put ( key , value ) ; } data . putAllAttributes ( attributes ) ; } } | Load attributes from an input stream that contains session data . |
22,342 | private void parseMultipartParameters ( Map < String , List < FileItem > > fileItemListMap , RequestAdapter requestAdapter ) { String encoding = requestAdapter . getEncoding ( ) ; MultiValueMap < String , String > parameterMap = new LinkedMultiValueMap < > ( ) ; MultiValueMap < String , FileParameter > fileParameterMap = new LinkedMultiValueMap < > ( ) ; for ( Map . Entry < String , List < FileItem > > entry : fileItemListMap . entrySet ( ) ) { String fieldName = entry . getKey ( ) ; List < FileItem > fileItemList = entry . getValue ( ) ; if ( fileItemList != null && ! fileItemList . isEmpty ( ) ) { for ( FileItem fileItem : fileItemList ) { if ( fileItem . isFormField ( ) ) { String value = getString ( fileItem , encoding ) ; parameterMap . add ( fieldName , value ) ; } else { String fileName = fileItem . getName ( ) ; if ( StringUtils . isEmpty ( fileName ) ) { continue ; } boolean valid = FilenameUtils . isValidFileExtension ( fileName , allowedFileExtensions , deniedFileExtensions ) ; if ( ! valid ) { continue ; } MemoryMultipartFileParameter fileParameter = new MemoryMultipartFileParameter ( fileItem ) ; fileParameterMap . add ( fieldName , fileParameter ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Found multipart file [" + fileParameter . getFileName ( ) + "] of size " + fileParameter . getFileSize ( ) + " bytes, stored " + fileParameter . getStorageDescription ( ) ) ; } } } } } if ( ! parameterMap . isEmpty ( ) ) { for ( Map . Entry < String , List < String > > entry : parameterMap . entrySet ( ) ) { String name = entry . getKey ( ) ; List < String > list = entry . getValue ( ) ; String [ ] values = list . toArray ( new String [ 0 ] ) ; requestAdapter . setParameter ( name , values ) ; } } if ( ! fileParameterMap . isEmpty ( ) ) { for ( Map . Entry < String , List < FileParameter > > entry : fileParameterMap . entrySet ( ) ) { String name = entry . getKey ( ) ; List < FileParameter > list = entry . getValue ( ) ; FileParameter [ ] values = list . toArray ( new FileParameter [ 0 ] ) ; requestAdapter . setFileParameter ( name , values ) ; } } } | Parse form fields and file items . |
22,343 | public Configuration createConfiguration ( ) throws IOException , TemplateException { Configuration config = newConfiguration ( ) ; Properties props = new Properties ( ) ; if ( this . freemarkerSettings != null ) { props . putAll ( this . freemarkerSettings ) ; } if ( ! props . isEmpty ( ) ) { config . setSettings ( props ) ; } if ( this . freemarkerVariables != null && freemarkerVariables . size ( ) > 0 ) { config . setAllSharedVariables ( new SimpleHash ( this . freemarkerVariables , config . getObjectWrapper ( ) ) ) ; } if ( this . defaultEncoding != null ) { config . setDefaultEncoding ( this . defaultEncoding ) ; } if ( templateLoaders == null ) { if ( templateLoaderPaths != null && templateLoaderPaths . length > 0 ) { List < TemplateLoader > templateLoaderList = new ArrayList < > ( ) ; for ( String path : templateLoaderPaths ) { templateLoaderList . add ( getTemplateLoaderForPath ( path ) ) ; } setTemplateLoader ( templateLoaderList ) ; } } TemplateLoader templateLoader = getAggregateTemplateLoader ( templateLoaders ) ; if ( templateLoader != null ) { config . setTemplateLoader ( templateLoader ) ; } if ( trimDirectives != null && trimDirectives . length > 0 ) { TrimDirectiveGroup group = new TrimDirectiveGroup ( trimDirectives ) ; for ( Map . Entry < String , Map < String , TrimDirective > > directives : group . entrySet ( ) ) { config . setSharedVariable ( directives . getKey ( ) , directives . getValue ( ) ) ; } } return config ; } | Prepare the FreeMarker Configuration and return it . |
22,344 | protected TemplateLoader getAggregateTemplateLoader ( TemplateLoader [ ] templateLoaders ) { int loaderCount = ( templateLoaders != null ? templateLoaders . length : 0 ) ; switch ( loaderCount ) { case 0 : if ( log . isDebugEnabled ( ) ) { log . debug ( "No FreeMarker TemplateLoaders specified; Can be used only inner template source" ) ; } return null ; case 1 : if ( log . isDebugEnabled ( ) ) { log . debug ( "One FreeMarker TemplateLoader registered: " + templateLoaders [ 0 ] ) ; } return templateLoaders [ 0 ] ; default : TemplateLoader loader = new MultiTemplateLoader ( templateLoaders ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Multiple FreeMarker TemplateLoader registered: " + loader ) ; } return loader ; } } | Return a TemplateLoader based on the given TemplateLoader list . If more than one TemplateLoader has been registered a FreeMarker MultiTemplateLoader needs to be created . |
22,345 | protected TemplateLoader getTemplateLoaderForPath ( String templateLoaderPath ) throws IOException { if ( templateLoaderPath . startsWith ( ResourceUtils . CLASSPATH_URL_PREFIX ) ) { String basePackagePath = templateLoaderPath . substring ( ResourceUtils . CLASSPATH_URL_PREFIX . length ( ) ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Template loader path [" + templateLoaderPath + "] resolved to class path [" + basePackagePath + "]" ) ; } return new ClassTemplateLoader ( environment . getClassLoader ( ) , basePackagePath ) ; } else if ( templateLoaderPath . startsWith ( ResourceUtils . FILE_URL_PREFIX ) ) { File file = new File ( templateLoaderPath . substring ( ResourceUtils . FILE_URL_PREFIX . length ( ) ) ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Template loader path [" + templateLoaderPath + "] resolved to file path [" + file . getAbsolutePath ( ) + "]" ) ; } return new FileTemplateLoader ( file ) ; } else { File file = new File ( environment . getBasePath ( ) , templateLoaderPath ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Template loader path [" + templateLoaderPath + "] resolved to file path [" + file . getAbsolutePath ( ) + "]" ) ; } return new FileTemplateLoader ( file ) ; } } | Determine a FreeMarker TemplateLoader for the given path . |
22,346 | public Options addOption ( Option opt ) { String key = opt . getKey ( ) ; if ( opt . hasLongName ( ) ) { longOpts . put ( opt . getLongName ( ) , opt ) ; } if ( opt . isRequired ( ) ) { if ( requiredOpts . contains ( key ) ) { requiredOpts . remove ( requiredOpts . indexOf ( key ) ) ; } requiredOpts . add ( key ) ; } shortOpts . put ( key , opt ) ; return this ; } | Adds an option instance . |
22,347 | public ItemRule newHeaderItemRule ( String headerName ) { ItemRule itemRule = new ItemRule ( ) ; itemRule . setName ( headerName ) ; addHeaderItemRule ( itemRule ) ; return itemRule ; } | Adds a new header rule with the specified name and returns it . |
22,348 | public void addHeaderItemRule ( ItemRule headerItemRule ) { if ( headerItemRuleMap == null ) { headerItemRuleMap = new ItemRuleMap ( ) ; } headerItemRuleMap . putItemRule ( headerItemRule ) ; } | Adds the header item rule . |
22,349 | public static HeaderActionRule newInstance ( String id , Boolean hidden ) { HeaderActionRule headerActionRule = new HeaderActionRule ( ) ; headerActionRule . setActionId ( id ) ; headerActionRule . setHidden ( hidden ) ; return headerActionRule ; } | Returns a new derived instance of HeaderActionRule . |
22,350 | protected Object getBean ( Token token ) { Object value ; if ( token . getAlternativeValue ( ) != null ) { if ( token . getDirectiveType ( ) == TokenDirectiveType . FIELD ) { Field field = ( Field ) token . getAlternativeValue ( ) ; if ( Modifier . isStatic ( field . getModifiers ( ) ) ) { value = ReflectionUtils . getField ( field , null ) ; } else { Class < ? > cls = field . getDeclaringClass ( ) ; Object target = activity . getBean ( cls ) ; value = ReflectionUtils . getField ( field , target ) ; } } else if ( token . getDirectiveType ( ) == TokenDirectiveType . METHOD ) { Method method = ( Method ) token . getAlternativeValue ( ) ; if ( Modifier . isStatic ( method . getModifiers ( ) ) ) { value = ReflectionUtils . invokeMethod ( method , null ) ; } else { Class < ? > cls = method . getDeclaringClass ( ) ; Object target = activity . getBean ( cls ) ; value = ReflectionUtils . invokeMethod ( method , target ) ; } } else { Class < ? > cls = ( Class < ? > ) token . getAlternativeValue ( ) ; try { value = activity . getBean ( cls ) ; } catch ( RequiredTypeBeanNotFoundException | NoUniqueBeanException e ) { if ( token . getGetterName ( ) != null ) { try { value = BeanUtils . getProperty ( cls , token . getGetterName ( ) ) ; if ( value == null ) { value = token . getDefaultValue ( ) ; } return value ; } catch ( InvocationTargetException e2 ) { } } throw e ; } if ( value != null && token . getGetterName ( ) != null ) { value = getBeanProperty ( value , token . getGetterName ( ) ) ; } } } else { value = activity . getBean ( token . getName ( ) ) ; if ( value != null && token . getGetterName ( ) != null ) { value = getBeanProperty ( value , token . getGetterName ( ) ) ; } } if ( value == null ) { value = token . getDefaultValue ( ) ; } return value ; } | Returns the bean instance that matches the given token . |
22,351 | protected Object getBeanProperty ( final Object object , String propertyName ) { Object value ; try { value = BeanUtils . getProperty ( object , propertyName ) ; } catch ( InvocationTargetException e ) { value = null ; } return value ; } | Invoke bean s property . |
22,352 | protected Object getProperty ( Token token ) throws IOException { if ( token . getDirectiveType ( ) == TokenDirectiveType . CLASSPATH ) { Properties props = PropertiesLoaderUtils . loadProperties ( token . getValue ( ) , activity . getEnvironment ( ) . getClassLoader ( ) ) ; Object value = ( token . getGetterName ( ) != null ? props . get ( token . getGetterName ( ) ) : props ) ; return ( value != null ? value : token . getDefaultValue ( ) ) ; } else { Object value = activity . getActivityContext ( ) . getEnvironment ( ) . getProperty ( token . getName ( ) , activity ) ; if ( value != null && token . getGetterName ( ) != null ) { value = getBeanProperty ( value , token . getGetterName ( ) ) ; } return ( value != null ? value : token . getDefaultValue ( ) ) ; } } | Returns an Environment variable that matches the given token . |
22,353 | protected String getTemplate ( Token token ) { TemplateRenderer templateRenderer = activity . getActivityContext ( ) . getTemplateRenderer ( ) ; StringWriter writer = new StringWriter ( ) ; templateRenderer . render ( token . getName ( ) , activity , writer ) ; String result = writer . toString ( ) ; return ( result != null ? result : token . getDefaultValue ( ) ) ; } | Executes template returns the generated output . |
22,354 | public String stringify ( ) { if ( type == TokenType . TEXT ) { return defaultValue ; } StringBuilder sb = new StringBuilder ( ) ; if ( type == TokenType . BEAN ) { sb . append ( BEAN_SYMBOL ) ; sb . append ( START_BRACKET ) ; if ( name != null ) { sb . append ( name ) ; } if ( value != null ) { sb . append ( VALUE_SEPARATOR ) ; sb . append ( value ) ; } if ( getterName != null ) { sb . append ( GETTER_SEPARATOR ) ; sb . append ( getterName ) ; } } else if ( type == TokenType . TEMPLATE ) { sb . append ( TEMPLATE_SYMBOL ) ; sb . append ( START_BRACKET ) ; if ( name != null ) { sb . append ( name ) ; } } else if ( type == TokenType . PARAMETER ) { sb . append ( PARAMETER_SYMBOL ) ; sb . append ( START_BRACKET ) ; if ( name != null ) { sb . append ( name ) ; } } else if ( type == TokenType . ATTRIBUTE ) { sb . append ( ATTRIBUTE_SYMBOL ) ; sb . append ( START_BRACKET ) ; if ( name != null ) { sb . append ( name ) ; } if ( getterName != null ) { sb . append ( GETTER_SEPARATOR ) ; sb . append ( getterName ) ; } } else if ( type == TokenType . PROPERTY ) { sb . append ( PROPERTY_SYMBOL ) ; sb . append ( START_BRACKET ) ; if ( name != null ) { sb . append ( name ) ; } if ( value != null ) { sb . append ( VALUE_SEPARATOR ) ; sb . append ( value ) ; } if ( getterName != null ) { sb . append ( GETTER_SEPARATOR ) ; sb . append ( getterName ) ; } } else { throw new InvalidTokenException ( "Unknown token type: " + type , this ) ; } if ( defaultValue != null ) { sb . append ( VALUE_SEPARATOR ) ; sb . append ( defaultValue ) ; } sb . append ( END_BRACKET ) ; return sb . toString ( ) ; } | Convert a Token object into a string . |
22,355 | public static boolean isTokenSymbol ( char c ) { return ( c == BEAN_SYMBOL || c == TEMPLATE_SYMBOL || c == PARAMETER_SYMBOL || c == ATTRIBUTE_SYMBOL || c == PROPERTY_SYMBOL ) ; } | Returns whether a specified character is the token symbol . |
22,356 | public static TokenType resolveTypeAsSymbol ( char symbol ) { TokenType type ; if ( symbol == Token . BEAN_SYMBOL ) { type = TokenType . BEAN ; } else if ( symbol == Token . TEMPLATE_SYMBOL ) { type = TokenType . TEMPLATE ; } else if ( symbol == Token . PARAMETER_SYMBOL ) { type = TokenType . PARAMETER ; } else if ( symbol == Token . ATTRIBUTE_SYMBOL ) { type = TokenType . ATTRIBUTE ; } else if ( symbol == Token . PROPERTY_SYMBOL ) { type = TokenType . PROPERTY ; } else { throw new IllegalArgumentException ( "Unknown token symbol: " + symbol ) ; } return type ; } | Returns the token type for the specified character . |
22,357 | public void setTransformType ( TransformType transformType ) { this . transformType = transformType ; if ( contentType == null && transformType != null ) { if ( transformType == TransformType . TEXT ) { contentType = ContentType . TEXT_PLAIN . toString ( ) ; } else if ( transformType == TransformType . JSON ) { contentType = ContentType . TEXT_JSON . toString ( ) ; } else if ( transformType == TransformType . XML ) { contentType = ContentType . TEXT_XML . toString ( ) ; } } } | Sets the transform type . |
22,358 | public void setTemplateRule ( TemplateRule templateRule ) { this . templateRule = templateRule ; if ( templateRule != null ) { if ( this . transformType == null ) { setTransformType ( TransformType . TEXT ) ; } if ( templateRule . getEncoding ( ) != null && this . encoding == null ) { this . encoding = templateRule . getEncoding ( ) ; } } } | Sets the template rule . |
22,359 | public void setResultValue ( String actionId , Object resultValue ) { if ( actionId == null || ! actionId . contains ( ActivityContext . ID_SEPARATOR ) ) { this . actionId = actionId ; this . resultValue = resultValue ; } else { String [ ] ids = StringUtils . tokenize ( actionId , ActivityContext . ID_SEPARATOR , true ) ; if ( ids . length == 1 ) { this . actionId = null ; this . resultValue = resultValue ; } else if ( ids . length == 2 ) { ResultValueMap resultValueMap = new ResultValueMap ( ) ; resultValueMap . put ( ids [ 1 ] , resultValue ) ; this . actionId = ids [ 0 ] ; this . resultValue = resultValueMap ; } else { ResultValueMap resultValueMap = new ResultValueMap ( ) ; for ( int i = 1 ; i < ids . length - 1 ; i ++ ) { ResultValueMap resultValueMap2 = new ResultValueMap ( ) ; resultValueMap . put ( ids [ i ] , resultValueMap2 ) ; resultValueMap = resultValueMap2 ; } resultValueMap . put ( ids [ ids . length - 1 ] , resultValue ) ; this . actionId = actionId ; this . resultValue = resultValueMap ; } } } | Sets the result value of the action . |
22,360 | public static URL getResource ( String resource , ClassLoader classLoader ) throws IOException { URL url = null ; if ( classLoader != null ) { url = classLoader . getResource ( resource ) ; } if ( url == null ) { url = ClassLoader . getSystemResource ( resource ) ; } if ( url == null ) { throw new IOException ( "Could not find resource '" + resource + "'" ) ; } return url ; } | Returns the URL of the resource on the classpath . |
22,361 | public static Reader getReader ( final File file , String encoding ) throws IOException { InputStream stream ; try { stream = AccessController . doPrivileged ( new PrivilegedExceptionAction < InputStream > ( ) { public InputStream run ( ) throws IOException { return new FileInputStream ( file ) ; } } ) ; } catch ( PrivilegedActionException e ) { throw ( IOException ) e . getException ( ) ; } Reader reader ; if ( encoding != null ) { reader = new InputStreamReader ( stream , encoding ) ; } else { reader = new InputStreamReader ( stream ) ; } return reader ; } | Returns a Reader for reading the specified file . |
22,362 | public static Reader getReader ( final URL url , String encoding ) throws IOException { InputStream stream ; try { stream = AccessController . doPrivileged ( new PrivilegedExceptionAction < InputStream > ( ) { public InputStream run ( ) throws IOException { InputStream is = null ; if ( url != null ) { URLConnection connection = url . openConnection ( ) ; if ( connection != null ) { connection . setUseCaches ( false ) ; is = connection . getInputStream ( ) ; } } return is ; } } ) ; } catch ( PrivilegedActionException e ) { throw ( IOException ) e . getException ( ) ; } Reader reader ; if ( encoding != null ) { reader = new InputStreamReader ( stream , encoding ) ; } else { reader = new InputStreamReader ( stream ) ; } return reader ; } | Returns a Reader for reading the specified url . |
22,363 | public static String read ( File file , String encoding ) throws IOException { Reader reader = getReader ( file , encoding ) ; String source ; try { source = read ( reader ) ; } finally { reader . close ( ) ; } return source ; } | Returns a string from the specified file . |
22,364 | public static String read ( URL url , String encoding ) throws IOException { Reader reader = getReader ( url , encoding ) ; String source ; try { source = read ( reader ) ; } finally { reader . close ( ) ; } return source ; } | Returns a string from the specified url . |
22,365 | public static String read ( Reader reader ) throws IOException { final char [ ] buffer = new char [ 1024 ] ; StringBuilder sb = new StringBuilder ( ) ; int len ; while ( ( len = reader . read ( buffer ) ) != - 1 ) { sb . append ( buffer , 0 , len ) ; } return sb . toString ( ) ; } | Returns a string from the specified Reader object . |
22,366 | private ViewDispatcher getViewDispatcher ( Activity activity ) throws ViewDispatcherException { if ( dispatchRule . getViewDispatcher ( ) != null ) { return dispatchRule . getViewDispatcher ( ) ; } try { String dispatcherName ; if ( dispatchRule . getDispatcherName ( ) != null ) { dispatcherName = dispatchRule . getDispatcherName ( ) ; } else { dispatcherName = activity . getSetting ( ViewDispatcher . VIEW_DISPATCHER_SETTING_NAME ) ; if ( dispatcherName == null ) { throw new IllegalArgumentException ( "The settings name '" + ViewDispatcher . VIEW_DISPATCHER_SETTING_NAME + "' has not been specified in the default response rule" ) ; } } ViewDispatcher viewDispatcher = cache . get ( dispatcherName ) ; if ( viewDispatcher == null ) { if ( dispatcherName . startsWith ( BeanRule . CLASS_DIRECTIVE_PREFIX ) ) { String dispatcherClassName = dispatcherName . substring ( BeanRule . CLASS_DIRECTIVE_PREFIX . length ( ) ) ; Class < ? > dispatcherClass = activity . getEnvironment ( ) . getClassLoader ( ) . loadClass ( dispatcherClassName ) ; viewDispatcher = ( ViewDispatcher ) activity . getBean ( dispatcherClass ) ; } else { viewDispatcher = activity . getBean ( dispatcherName ) ; } if ( viewDispatcher == null ) { throw new IllegalArgumentException ( "No bean named '" + dispatcherName + "' is defined" ) ; } if ( viewDispatcher . isSingleton ( ) ) { ViewDispatcher existing = cache . putIfAbsent ( dispatcherName , viewDispatcher ) ; if ( existing != null ) { viewDispatcher = existing ; } else { if ( log . isDebugEnabled ( ) ) { log . debug ( "Caching " + viewDispatcher ) ; } } } } return viewDispatcher ; } catch ( Exception e ) { throw new ViewDispatcherException ( "Unable to determine ViewDispatcher" , e ) ; } } | Determine the view dispatcher . |
22,367 | public static void fetchAttributes ( RequestAdapter requestAdapter , ProcessResult processResult ) { if ( processResult != null ) { for ( ContentResult contentResult : processResult ) { for ( ActionResult actionResult : contentResult ) { Object actionResultValue = actionResult . getResultValue ( ) ; if ( actionResultValue instanceof ProcessResult ) { fetchAttributes ( requestAdapter , ( ProcessResult ) actionResultValue ) ; } else { String actionId = actionResult . getActionId ( ) ; if ( actionId != null ) { requestAdapter . setAttribute ( actionId , actionResultValue ) ; } } } } } } | Stores an attribute in request . |
22,368 | public void excludePackage ( String ... packageNames ) { if ( packageNames == null ) { excludePackageNames = null ; } else { for ( String packageName : packageNames ) { if ( excludePackageNames == null ) { excludePackageNames = new HashSet < > ( ) ; } excludePackageNames . add ( packageName + PACKAGE_SEPARATOR_CHAR ) ; } } } | Adds packages that this ClassLoader should not handle . Any class whose fully - qualified name starts with the name registered here will be handled by the parent ClassLoader in the usual fashion . |
22,369 | public void excludeClass ( String ... classNames ) { if ( classNames == null ) { excludeClassNames = null ; } else { for ( String className : classNames ) { if ( ! isExcludePackage ( className ) ) { if ( excludeClassNames == null ) { excludeClassNames = new HashSet < > ( ) ; } excludeClassNames . add ( className ) ; } } } } | Adds classes that this ClassLoader should not handle . Any class whose fully - qualified name starts with the name registered here will be handled by the parent ClassLoader in the usual fashion . |
22,370 | public void open ( ) { if ( sqlSession == null ) { if ( executorType == null ) { executorType = ExecutorType . SIMPLE ; } sqlSession = sqlSessionFactory . openSession ( executorType , autoCommit ) ; if ( log . isDebugEnabled ( ) ) { ToStringBuilder tsb = new ToStringBuilder ( String . format ( "%s %s@%x" , ( arbitrarilyClosed ? "Reopened" : "Opened" ) , sqlSession . getClass ( ) . getSimpleName ( ) , sqlSession . hashCode ( ) ) ) ; tsb . append ( "executorType" , executorType ) ; tsb . append ( "autoCommit" , autoCommit ) ; log . debug ( tsb . toString ( ) ) ; } arbitrarilyClosed = false ; } } | Opens a new SqlSession and store its instance inside . Therefore whenever there is a request for a SqlSessionTxAdvice bean a new bean instance of the object must be created . |
22,371 | public void commit ( boolean force ) { if ( checkSession ( ) ) { return ; } if ( log . isDebugEnabled ( ) ) { ToStringBuilder tsb = new ToStringBuilder ( String . format ( "Committing transactional %s@%x" , sqlSession . getClass ( ) . getSimpleName ( ) , sqlSession . hashCode ( ) ) ) ; tsb . append ( "force" , force ) ; log . debug ( tsb . toString ( ) ) ; } sqlSession . commit ( force ) ; } | Flushes batch statements and commits database connection . |
22,372 | public void close ( boolean arbitrarily ) { if ( checkSession ( ) ) { return ; } arbitrarilyClosed = arbitrarily ; sqlSession . close ( ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( String . format ( "Closed %s@%x" , sqlSession . getClass ( ) . getSimpleName ( ) , sqlSession . hashCode ( ) ) ) ; } sqlSession = null ; } | Closes the session arbitrarily . If the transaction advice does not finally close the session the session will automatically reopen whenever necessary . |
22,373 | public void ifExceptionThrow ( ) throws Exception { if ( nested == null || nested . isEmpty ( ) ) { return ; } if ( nested . size ( ) == 1 ) { Throwable th = nested . get ( 0 ) ; if ( th instanceof Error ) { throw ( Error ) th ; } if ( th instanceof Exception ) { throw ( Exception ) th ; } } throw this ; } | Throw a MultiException . If this multi exception is empty then no action is taken . If it contains a single exception that is thrown otherwise the this multi exception is thrown . |
22,374 | public void ifExceptionThrowRuntime ( ) throws Error { if ( nested == null || nested . isEmpty ( ) ) { return ; } if ( nested . size ( ) == 1 ) { Throwable th = nested . get ( 0 ) ; if ( th instanceof Error ) { throw ( Error ) th ; } else if ( th instanceof RuntimeException ) { throw ( RuntimeException ) th ; } else { throw new RuntimeException ( th ) ; } } throw new RuntimeException ( this ) ; } | Throw a Runtime exception . If this multi exception is empty then no action is taken . If it contains a single error or runtime exception that is thrown otherwise the this multi exception is thrown wrapped in a runtime exception . |
22,375 | public void printHelp ( Command command ) { if ( command . getDescriptor ( ) . getUsage ( ) != null ) { printUsage ( command . getDescriptor ( ) . getUsage ( ) ) ; } else { printUsage ( command ) ; } int leftWidth = printOptions ( command . getOptions ( ) ) ; printArguments ( command . getArgumentsList ( ) , leftWidth ) ; } | Print the help with the given Command object . |
22,376 | public void printUsage ( Command command ) { String commandName = command . getDescriptor ( ) . getName ( ) ; StringBuilder sb = new StringBuilder ( getSyntaxPrefix ( ) ) . append ( commandName ) . append ( " " ) ; Collection < OptionGroup > processedGroups = new ArrayList < > ( ) ; Collection < Option > optList = command . getOptions ( ) . getAllOptions ( ) ; if ( optList . size ( ) > 1 && getOptionComparator ( ) != null ) { List < Option > optList2 = new ArrayList < > ( optList ) ; optList2 . sort ( getOptionComparator ( ) ) ; optList = optList2 ; } for ( Iterator < Option > it = optList . iterator ( ) ; it . hasNext ( ) ; ) { Option option = it . next ( ) ; OptionGroup group = command . getOptions ( ) . getOptionGroup ( option ) ; if ( group != null ) { if ( ! processedGroups . contains ( group ) ) { processedGroups . add ( group ) ; appendOptionGroup ( sb , group ) ; } } else { appendOption ( sb , option , option . isRequired ( ) ) ; } if ( it . hasNext ( ) ) { sb . append ( " " ) ; } } for ( Arguments arguments : command . getArgumentsList ( ) ) { sb . append ( " " ) ; appendArguments ( sb , arguments ) ; } printWrapped ( getSyntaxPrefix ( ) . length ( ) + commandName . length ( ) + 1 , sb . toString ( ) ) ; } | Prints the usage statement for the specified command . |
22,377 | private void appendOptionGroup ( StringBuilder sb , OptionGroup group ) { if ( ! group . isRequired ( ) ) { sb . append ( OPTIONAL_BRACKET_OPEN ) ; } List < Option > optList = new ArrayList < > ( group . getOptions ( ) ) ; if ( optList . size ( ) > 1 && getOptionComparator ( ) != null ) { optList . sort ( getOptionComparator ( ) ) ; } for ( Iterator < Option > it = optList . iterator ( ) ; it . hasNext ( ) ; ) { appendOption ( sb , it . next ( ) , true ) ; if ( it . hasNext ( ) ) { sb . append ( " | " ) ; } } if ( ! group . isRequired ( ) ) { sb . append ( OPTIONAL_BRACKET_CLOSE ) ; } } | Appends the usage clause for an OptionGroup to a StringBuilder . The clause is wrapped in square brackets if the group is required . The display of the options is handled by appendOption . |
22,378 | public ItemRule newArgumentItemRule ( String argumentName ) { ItemRule itemRule = new ItemRule ( ) ; itemRule . setName ( argumentName ) ; addArgumentItemRule ( itemRule ) ; return itemRule ; } | Adds a new argument rule with the specified name and returns it . |
22,379 | public void addArgumentItemRule ( ItemRule argumentItemRule ) { if ( argumentItemRuleMap == null ) { argumentItemRuleMap = new ItemRuleMap ( ) ; } argumentItemRuleMap . putItemRule ( argumentItemRule ) ; } | Adds the argument item rule . |
22,380 | public static BeanMethodActionRule newInstance ( String id , String beanId , String methodName , Boolean hidden ) throws IllegalRuleException { if ( methodName == null ) { throw new IllegalRuleException ( "The 'action' element requires an 'method' attribute" ) ; } BeanMethodActionRule beanMethodActionRule = new BeanMethodActionRule ( ) ; beanMethodActionRule . setActionId ( id ) ; beanMethodActionRule . setBeanId ( beanId ) ; beanMethodActionRule . setMethodName ( methodName ) ; beanMethodActionRule . setHidden ( hidden ) ; return beanMethodActionRule ; } | Returns a new instance of BeanActionRule . |
22,381 | public void setAll ( Map < String , String > params ) { for ( Map . Entry < String , String > entry : params . entrySet ( ) ) { setParameter ( entry . getKey ( ) , entry . getValue ( ) ) ; } } | Set the given parameters under . |
22,382 | public Object getParameterWithoutCache ( String name ) { if ( activity . getRequestAdapter ( ) != null ) { String [ ] values = activity . getRequestAdapter ( ) . getParameterValues ( name ) ; if ( values != null ) { if ( values . length == 1 ) { return values [ 0 ] ; } else { return values ; } } } return null ; } | Returns the value of the request parameter from the request adapter without storing it in the cache . If the parameter does not exist returns null . |
22,383 | public Object getAttributeWithoutCache ( String name ) { if ( activity . getRequestAdapter ( ) != null ) { return activity . getRequestAdapter ( ) . getAttribute ( name ) ; } else { return null ; } } | Returns the value of the named attribute from the request adapter without storing it in the cache . If no attribute of the given name exists returns null . |
22,384 | public Object getActionResultWithoutCache ( String name ) { if ( activity . getProcessResult ( ) != null ) { return activity . getProcessResult ( ) . getResultValue ( name ) ; } else { return null ; } } | Returns the value of the named action s process result without storing it in the cache . If no process result of the given name exists returns null . |
22,385 | public Object getSessionAttributeWithoutCache ( String name ) { if ( activity . getSessionAdapter ( ) != null ) { return activity . getSessionAdapter ( ) . getAttribute ( name ) ; } else { return null ; } } | Returns the value of the named attribute from the session adapter without storing it in the cache . If no attribute of the given name exists returns null . |
22,386 | public Session get ( String id ) throws Exception { Session session ; Exception ex = null ; while ( true ) { session = doGet ( id ) ; if ( sessionDataStore == null ) { break ; } if ( session == null ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Session " + id + " not found locally, attempting to load" ) ; } PlaceHolderSession phs = new PlaceHolderSession ( new SessionData ( id , 0 , 0 , 0 , 0 ) ) ; Lock phsLock = phs . lock ( ) ; Session s = doPutIfAbsent ( id , phs ) ; if ( s == null ) { try { session = loadSession ( id ) ; if ( session == null ) { doDelete ( id ) ; phsLock . close ( ) ; break ; } try ( Lock ignored = session . lock ( ) ) { boolean success = doReplace ( id , phs , session ) ; if ( ! success ) { doDelete ( id ) ; session = null ; log . warn ( "Replacement of placeholder for session " + id + " failed" ) ; phsLock . close ( ) ; break ; } else { session . setResident ( true ) ; session . updateInactivityTimer ( ) ; phsLock . close ( ) ; break ; } } } catch ( Exception e ) { ex = e ; doDelete ( id ) ; phsLock . close ( ) ; session = null ; break ; } } else { phsLock . close ( ) ; try ( Lock ignored = s . lock ( ) ) { if ( ! s . isResident ( ) || s instanceof PlaceHolderSession ) { continue ; } session = s ; break ; } } } else { try ( Lock ignored = session . lock ( ) ) { if ( ! session . isResident ( ) || session instanceof PlaceHolderSession ) { continue ; } break ; } } } if ( ex != null ) { throw ex ; } return session ; } | Get a session object . If the session object is not in this session store try getting the data for it from a SessionDataStore associated with the session manager . |
22,387 | private Session loadSession ( String id ) throws Exception { if ( sessionDataStore == null ) { return null ; } try { SessionData data = sessionDataStore . load ( id ) ; if ( data == null ) { return null ; } return newSession ( data ) ; } catch ( UnreadableSessionDataException e ) { if ( isRemoveUnloadableSessions ( ) ) { sessionDataStore . delete ( id ) ; } throw e ; } } | Load the info for the session from the session data store . |
22,388 | public void put ( String id , Session session ) throws Exception { if ( id == null || session == null ) { throw new IllegalArgumentException ( "Put key=" + id + " session=" + ( session == null ? "null" : session . getId ( ) ) ) ; } try ( Lock ignored = session . lock ( ) ) { if ( ! session . isValid ( ) ) { return ; } if ( sessionDataStore == null ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "No SessionDataStore, putting into SessionCache only id=" + id ) ; } session . setResident ( true ) ; if ( doPutIfAbsent ( id , session ) == null ) { session . updateInactivityTimer ( ) ; } return ; } if ( ( session . getRequests ( ) <= 0 ) ) { if ( ! sessionDataStore . isPassivating ( ) ) { sessionDataStore . store ( id , session . getSessionData ( ) ) ; if ( getEvictionPolicy ( ) == EVICT_ON_SESSION_EXIT ) { if ( log . isDebugEnabled ( ) ) { log . debug ( "Eviction on request exit id=" + id ) ; } doDelete ( session . getId ( ) ) ; session . setResident ( false ) ; } else { session . setResident ( true ) ; if ( doPutIfAbsent ( id , session ) == null ) { session . updateInactivityTimer ( ) ; } if ( log . isDebugEnabled ( ) ) { log . debug ( "Non passivating SessionDataStore, session in SessionCache only id=" + id ) ; } } } else { sessionHandler . willPassivate ( session ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Session passivating id=" + id ) ; } sessionDataStore . store ( id , session . getSessionData ( ) ) ; if ( getEvictionPolicy ( ) == EVICT_ON_SESSION_EXIT ) { doDelete ( id ) ; session . setResident ( false ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Evicted on request exit id=" + id ) ; } } else { sessionHandler . didActivate ( session ) ; session . setResident ( true ) ; if ( doPutIfAbsent ( id , session ) == null ) session . updateInactivityTimer ( ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Session reactivated id=" + id ) ; } } } } else { if ( log . isDebugEnabled ( ) ) { log . debug ( "Req count=" + session . getRequests ( ) + " for id=" + id ) ; } session . setResident ( true ) ; if ( doPutIfAbsent ( id , session ) == null ) { session . updateInactivityTimer ( ) ; } } } } | Put the Session object back into the session store . |
22,389 | public boolean exists ( String id ) throws Exception { Session s = doGet ( id ) ; if ( s != null ) { try ( Lock ignored = s . lock ( ) ) { return s . isValid ( ) ; } } return ( sessionDataStore != null && sessionDataStore . exists ( id ) ) ; } | Check to see if a session corresponding to the id exists . |
22,390 | public Session delete ( String id ) throws Exception { Session session = get ( id ) ; if ( sessionDataStore != null ) { boolean deleted = sessionDataStore . delete ( id ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Session " + id + " deleted in db: " + deleted ) ; } } if ( session != null ) { session . stopInactivityTimer ( ) ; session . setResident ( false ) ; } return doDelete ( id ) ; } | Remove a session object from this store and from any backing store . |
22,391 | public void checkInactiveSession ( Session session ) { if ( session == null ) { return ; } if ( log . isDebugEnabled ( ) ) { log . debug ( "Checking for idle " + session . getId ( ) ) ; } try ( Lock ignored = session . lock ( ) ) { if ( getEvictionPolicy ( ) > 0 && session . isIdleLongerThan ( getEvictionPolicy ( ) ) && session . isValid ( ) && session . isResident ( ) && session . getRequests ( ) <= 0 ) { try { if ( log . isDebugEnabled ( ) ) { log . debug ( "Evicting idle session " + session . getId ( ) ) ; } if ( isSaveOnInactiveEviction ( ) && sessionDataStore != null ) { if ( sessionDataStore . isPassivating ( ) ) { sessionHandler . willPassivate ( session ) ; } sessionDataStore . store ( session . getId ( ) , session . getSessionData ( ) ) ; } doDelete ( session . getId ( ) ) ; session . setResident ( false ) ; } catch ( Exception e ) { log . warn ( "Passivation of idle session" + session . getId ( ) + " failed" , e ) ; session . updateInactivityTimer ( ) ; } } } } | Check a session for being inactive and thus being able to be evicted if eviction is enabled . |
22,392 | public PebbleEngine createPebbleEngine ( ) { PebbleEngine . Builder builder = new PebbleEngine . Builder ( ) ; builder . strictVariables ( strictVariables ) ; if ( defaultLocale != null ) { builder . defaultLocale ( defaultLocale ) ; } if ( templateLoaders == null ) { if ( templateLoaderPaths != null && templateLoaderPaths . length > 0 ) { List < Loader < ? > > templateLoaderList = new ArrayList < > ( ) ; for ( String path : templateLoaderPaths ) { templateLoaderList . add ( getTemplateLoaderForPath ( path ) ) ; } setTemplateLoader ( templateLoaderList ) ; } } Loader < ? > templateLoader = getAggregateTemplateLoader ( templateLoaders ) ; builder . loader ( templateLoader ) ; return builder . build ( ) ; } | Creates a PebbleEngine instance . |
22,393 | protected Loader < ? > getAggregateTemplateLoader ( Loader < ? > [ ] templateLoaders ) { int loaderCount = ( templateLoaders == null ) ? 0 : templateLoaders . length ; switch ( loaderCount ) { case 0 : Loader < ? > stringLoader = new StringLoader ( ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Pebble Engine Template Loader not specified. Default Template Loader registered: " + stringLoader ) ; } return stringLoader ; case 1 : if ( log . isDebugEnabled ( ) ) { log . debug ( "One Pebble Engine Template Loader registered: " + templateLoaders [ 0 ] ) ; } return templateLoaders [ 0 ] ; default : List < Loader < ? > > defaultLoadingStrategies = new ArrayList < > ( ) ; Collections . addAll ( defaultLoadingStrategies , templateLoaders ) ; Loader < ? > delegatingLoader = new DelegatingLoader ( defaultLoadingStrategies ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Multiple Pebble Engine Template Loader registered: " + delegatingLoader ) ; } return delegatingLoader ; } } | Return a Template Loader based on the given Template Loader list . If more than one Template Loader has been registered a DelegatingLoader needs to be created . |
22,394 | protected Loader < ? > getTemplateLoaderForPath ( String templateLoaderPath ) { if ( templateLoaderPath . startsWith ( ResourceUtils . CLASSPATH_URL_PREFIX ) ) { String basePackagePath = templateLoaderPath . substring ( ResourceUtils . CLASSPATH_URL_PREFIX . length ( ) ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Template loader path [" + templateLoaderPath + "] resolved to class path [" + basePackagePath + "]" ) ; } ClasspathLoader loader = new ClasspathLoader ( environment . getClassLoader ( ) ) ; loader . setPrefix ( basePackagePath ) ; return loader ; } else if ( templateLoaderPath . startsWith ( ResourceUtils . FILE_URL_PREFIX ) ) { File file = new File ( templateLoaderPath . substring ( ResourceUtils . FILE_URL_PREFIX . length ( ) ) ) ; String prefix = file . getAbsolutePath ( ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Template loader path [" + templateLoaderPath + "] resolved to file path [" + prefix + "]" ) ; } FileLoader loader = new FileLoader ( ) ; loader . setPrefix ( prefix ) ; return loader ; } else { File file = new File ( environment . getBasePath ( ) , templateLoaderPath ) ; String prefix = file . getAbsolutePath ( ) ; if ( log . isDebugEnabled ( ) ) { log . debug ( "Template loader path [" + templateLoaderPath + "] resolved to file path [" + prefix + "]" ) ; } FileLoader loader = new FileLoader ( ) ; loader . setPrefix ( prefix ) ; return loader ; } } | Determine a Pebble Engine Template Loader for the given path . |
22,395 | public String newSessionId ( long seedTerm ) { synchronized ( random ) { long r0 ; if ( weakRandom ) { r0 = hashCode ( ) ^ Runtime . getRuntime ( ) . freeMemory ( ) ^ random . nextInt ( ) ^ ( seedTerm << 32 ) ; } else { r0 = random . nextLong ( ) ; } if ( r0 < 0 ) { r0 = - r0 ; } long r1 ; if ( weakRandom ) { r1 = hashCode ( ) ^ Runtime . getRuntime ( ) . freeMemory ( ) ^ random . nextInt ( ) ^ ( seedTerm << 32 ) ; } else { r1 = random . nextLong ( ) ; } if ( r1 < 0 ) { r1 = - r1 ; } StringBuilder id = new StringBuilder ( ) ; if ( ! StringUtils . isEmpty ( groupName ) ) { id . append ( groupName ) ; } id . append ( Long . toString ( r0 , 36 ) ) ; id . append ( Long . toString ( r1 , 36 ) ) ; id . append ( counter . getAndIncrement ( ) ) ; return id . toString ( ) ; } } | Returns a new unique session id . |
22,396 | private void initRandom ( ) { try { random = new SecureRandom ( ) ; } catch ( Exception e ) { log . warn ( "Could not generate SecureRandom for session-id randomness" , e ) ; random = new Random ( ) ; weakRandom = true ; } } | Set up a random number generator for the sessionids . |
22,397 | public void write ( Parameters parameters ) throws IOException { if ( parameters != null ) { for ( Parameter pv : parameters . getParameterValueMap ( ) . values ( ) ) { if ( pv . isAssigned ( ) ) { write ( pv ) ; } } } } | Write a Parameters object to the character - output stream . |
22,398 | public void comment ( String message ) throws IOException { if ( message . indexOf ( NEW_LINE_CHAR ) != - 1 ) { String line ; int start = 0 ; while ( ( line = readLine ( message , start ) ) != null ) { writer . write ( COMMENT_LINE_START ) ; writer . write ( SPACE_CHAR ) ; writer . write ( line ) ; newLine ( ) ; start += line . length ( ) ; start = skipNewLineChar ( message , start ) ; if ( start == - 1 ) { break ; } } if ( start != - 1 ) { writer . write ( COMMENT_LINE_START ) ; newLine ( ) ; } } else { writer . write ( COMMENT_LINE_START ) ; writer . write ( SPACE_CHAR ) ; writer . write ( message ) ; newLine ( ) ; } } | Writes a comment to the character - output stream . |
22,399 | public static String stringify ( Parameters parameters , String indentString ) { if ( parameters == null ) { return null ; } try { Writer writer = new StringWriter ( ) ; AponWriter aponWriter = new AponWriter ( writer ) ; aponWriter . setIndentString ( indentString ) ; aponWriter . write ( parameters ) ; aponWriter . close ( ) ; return writer . toString ( ) ; } catch ( IOException e ) { return null ; } } | Converts a Parameters object to an APON formatted string . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.