idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
9,500
public final void writeChildren ( ObjectOutputStream oos ) throws IOException { int serializable = 0 ; Set < Map . Entry < Object , BCChild > > bcChildren = _children . entrySet ( ) ; for ( Map . Entry < Object , BCChild > entry : bcChildren ) { if ( entry . getValue ( ) . isSerializable ( ) ) { serializable ++ ; } } oos . writeInt ( serializable ) ; if ( serializable > 0 ) { for ( Map . Entry < Object , BCChild > bc : bcChildren ) { if ( bc . getValue ( ) . isSerializable ( ) ) { oos . writeObject ( bc . getKey ( ) ) ; } } } }
Necessary for the case of this bean context having a peer . The specification states that a bean context which has a peer should not serialize its children this hook is necessary to allow the peer to serialize children .
9,501
private synchronized void readObject ( ObjectInputStream in ) throws IOException , ClassNotFoundException { in . defaultReadObject ( ) ; initialize ( ) ; if ( this . equals ( getPeer ( ) ) ) { readChildren ( in ) ; } int listenerCount = in . readInt ( ) ; for ( int i = 0 ; i < listenerCount ; i ++ ) { addBeanContextMembershipListener ( ( BeanContextMembershipListener ) in . readObject ( ) ) ; } }
Deserialize this an instance of this class including any children and BeanContextMembershipListeners which were present during serialization and were serializable .
9,502
public final void readChildren ( ObjectInputStream in ) throws IOException , ClassNotFoundException { int childCount = in . readInt ( ) ; for ( int i = 0 ; i < childCount ; i ++ ) { internalAdd ( in . readObject ( ) , false ) ; } }
This public api is necessary to allow a bean context with a peer to deserialize its children . This api is not part any standard api .
9,503
public static HttpResult executeSearch ( AsyncHttpClient client , HttpMethod method , String host , String path , String searchQuery ) { RequestBuilder requestBuilder = new RequestBuilder ( method . name ( ) ) ; log . debug ( "Executing request against host {} with path {}" , host , path ) ; if ( searchQuery != null ) { requestBuilder . setBody ( searchQuery ) ; } requestBuilder . setUrl ( host + path ) ; try { Response res = client . executeRequest ( requestBuilder . build ( ) , new AsyncCompletionHandlerBase ( ) ) . get ( ) ; return new HttpResult ( HttpSearchExecutionStatus . OK , res . getResponseBody ( ) ) ; } catch ( Exception e ) { Throwable cause = e . getCause ( ) ; if ( cause != null ) { if ( cause instanceof ConnectException ) { log . error ( "Unable to connect to {}" , host , e ) ; return HttpResult . CONNECTION_FAILURE ; } else if ( cause instanceof TimeoutException ) { log . error ( "Request timeout talking to {}" , host , e ) ; return HttpResult . REQUEST_TIMEOUT_FAILURE ; } else if ( cause instanceof IOException && cause . getMessage ( ) . equalsIgnoreCase ( "closed" ) ) { log . warn ( "Unable to use client, client is closed" ) ; return HttpResult . CLIENT_CLOSED ; } else { log . error ( "Exception talking to {}" , host , e ) ; return new HttpResult ( HttpSearchExecutionStatus . REQUEST_FAILURE , null ) ; } } else { if ( e instanceof IOException && e . getMessage ( ) . equalsIgnoreCase ( "closed" ) ) { log . warn ( "Unable to use client, client is closed" ) ; return HttpResult . CLIENT_CLOSED ; } else { log . error ( "Exception talking to {}" , host , e ) ; return new HttpResult ( HttpSearchExecutionStatus . REQUEST_FAILURE , null ) ; } } } }
Executes a blocking request .
9,504
public static OS determineOS ( ) { if ( currentOs == null ) { String osString = System . getProperty ( "os.name" ) . trim ( ) . toLowerCase ( ) ; if ( osString . startsWith ( "windows" ) ) { currentOs = OS . WIN32 ; } else if ( osString . startsWith ( "mac os x" ) ) { currentOs = OS . MACOSX ; } else if ( osString . startsWith ( "mac os" ) ) { currentOs = OS . MACOSCLASSIC ; } else if ( osString . startsWith ( "risc os" ) ) { currentOs = OS . RISCOS ; } else if ( ( osString . indexOf ( "linux" ) > - 1 ) || ( osString . indexOf ( "debian" ) > - 1 ) || ( osString . indexOf ( "redhat" ) > - 1 ) || ( osString . indexOf ( "lindows" ) > - 1 ) ) { currentOs = OS . LINUX ; } else if ( ( osString . indexOf ( "freebsd" ) > - 1 ) || ( osString . indexOf ( "openbsd" ) > - 1 ) || ( osString . indexOf ( "netbsd" ) > - 1 ) || ( osString . indexOf ( "irix" ) > - 1 ) || ( osString . indexOf ( "solaris" ) > - 1 ) || ( osString . indexOf ( "sunos" ) > - 1 ) || ( osString . indexOf ( "hp/ux" ) > - 1 ) || ( osString . indexOf ( "risc ix" ) > - 1 ) || ( osString . indexOf ( "dg/ux" ) > - 1 ) ) { currentOs = OS . BSD ; } else if ( osString . indexOf ( "beos" ) > - 1 ) { currentOs = OS . BEOS ; } else { currentOs = OS . UNKNOWN ; } } return currentOs ; }
Determines the current host platform .
9,505
public static boolean isRunningUnix ( ) { OS os = XRuntimeUtils . determineOS ( ) ; if ( os . equals ( OS . BSD ) || os . equals ( OS . LINUX ) || os . equals ( OS . MACOSX ) ) { return true ; } else { return false ; } }
Checks whether the current platform is some flavor of Unix .
9,506
public static String getSupportFolder ( ) { String homedir = System . getProperty ( "user.home" ) ; String dirName = "OpenXES" ; if ( isRunningWindows ( ) ) { ( new File ( homedir + "\\" + dirName ) ) . mkdirs ( ) ; return homedir + "\\" + dirName + "\\" ; } else if ( isRunningMacOsX ( ) ) { ( new File ( homedir + "/Library/Application Support/" + dirName ) ) . mkdirs ( ) ; return homedir + "/Library/Application Support/" + dirName + "/" ; } else { ( new File ( homedir + "/." + dirName ) ) . mkdirs ( ) ; return homedir + "/." + dirName + "/" ; } }
Retrieves the path of the platform - dependent OpenXES support folder .
9,507
protected boolean processActionOverride ( HttpServletRequest request , HttpServletResponse response ) throws IOException , ServletException { PageFlowRequestWrapper wrapper = PageFlowRequestWrapper . get ( request ) ; if ( ! wrapper . isForwardedByButton ( ) && ! wrapper . isForwardedRequest ( ) ) { HttpServletRequest multipartAwareRequest = processMultipart ( request ) ; for ( Enumeration e = multipartAwareRequest . getParameterNames ( ) ; e . hasMoreElements ( ) ; ) { String paramName = ( String ) e . nextElement ( ) ; if ( paramName . startsWith ( ACTION_OVERRIDE_PARAM_PREFIX ) ) { String actionPath = paramName . substring ( ACTION_OVERRIDE_PARAM_PREFIX_LEN ) ; ServletContext servletContext = getServletContext ( ) ; String qualifiedAction = InternalUtils . qualifyAction ( servletContext , actionPath ) ; actionPath = InternalUtils . createActionPath ( request , qualifiedAction ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "A request parameter overrode the action. Forwarding to: " + actionPath ) ; } wrapper . setForwardedByButton ( true ) ; doForward ( actionPath , request , response ) ; return true ; } } } return false ; }
The requested action can be overridden by a request parameter . In this case we parse the action from the request parameter and forward to a URI constructed from it .
9,508
protected boolean processPageFlowRequest ( HttpServletRequest request , HttpServletResponse response , String uri ) throws IOException , ServletException { if ( FileUtils . osSensitiveEndsWith ( uri , PageFlowConstants . PAGEFLOW_EXTENSION ) ) { String modulePath = PageFlowUtils . getModulePath ( request ) ; if ( ! moduleConfig . getPrefix ( ) . equals ( modulePath ) ) { if ( LOG . isErrorEnabled ( ) ) { InternalStringBuilder msg = new InternalStringBuilder ( "No module configuration registered for " ) ; msg . append ( uri ) . append ( " (module path " ) . append ( modulePath ) . append ( ")." ) ; LOG . error ( msg . toString ( ) ) ; } if ( modulePath . length ( ) == 0 ) modulePath = "/" ; InternalUtils . sendDevTimeError ( "PageFlow_NoModuleConf" , null , HttpServletResponse . SC_INTERNAL_SERVER_ERROR , request , response , getServletContext ( ) , new Object [ ] { uri , modulePath } ) ; return true ; } ActionMapping beginMapping = getBeginMapping ( ) ; if ( beginMapping != null ) { String desiredType = beginMapping . getParameter ( ) ; desiredType = desiredType . substring ( desiredType . lastIndexOf ( '.' ) + 1 ) + PAGEFLOW_EXTENSION ; String requestedType = InternalUtils . getDecodedServletPath ( request ) ; requestedType = requestedType . substring ( requestedType . lastIndexOf ( '/' ) + 1 ) ; if ( ! requestedType . equals ( desiredType ) ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Wrong .jpf requested for this directory: got " + requestedType + ", expected " + desiredType ) ; } if ( LOG . isErrorEnabled ( ) ) { InternalStringBuilder msg = new InternalStringBuilder ( "Wrong .jpf requested for this directory: got " ) ; msg . append ( requestedType ) . append ( ", expected " ) . append ( desiredType ) . append ( '.' ) ; LOG . error ( msg . toString ( ) ) ; } InternalUtils . sendDevTimeError ( "PageFlow_WrongPath" , null , HttpServletResponse . SC_INTERNAL_SERVER_ERROR , request , response , getServletContext ( ) , new Object [ ] { requestedType , desiredType } ) ; return true ; } } uri = PageFlowUtils . getBeginActionURI ( uri ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Got request for " + request . getRequestURI ( ) + ", forwarding to " + uri ) ; } doForward ( uri , request , response ) ; return true ; } return false ; }
Process any direct request for a page flow by forwarding to its begin action .
9,509
protected HttpServletRequest processMultipart ( HttpServletRequest request ) { if ( ! "POST" . equalsIgnoreCase ( request . getMethod ( ) ) ) return request ; String contentType = request . getContentType ( ) ; if ( contentType != null && contentType . startsWith ( "multipart/form-data" ) ) { PageFlowRequestWrapper pageFlowRequestWrapper = PageFlowRequestWrapper . get ( request ) ; MultipartRequestWrapper cachedWrapper = pageFlowRequestWrapper . getMultipartRequestWrapper ( ) ; if ( cachedWrapper != null && cachedWrapper . getRequest ( ) == request ) return cachedWrapper ; try { MultipartRequestUtils . preHandleMultipartRequest ( request ) ; } catch ( ServletException e ) { LOG . error ( "Could not parse multipart request." , e . getRootCause ( ) ) ; return request ; } MultipartRequestWrapper ret = new RehydratedMultipartRequestWrapper ( request ) ; pageFlowRequestWrapper . setMultipartRequestWrapper ( ret ) ; return ret ; } else { return request ; } }
If this is a multipart request wrap it with a special wrapper . Otherwise return the request unchanged .
9,510
protected void initDefinitionsMapping ( ) throws ServletException { definitionsFactory = null ; TilesUtilImpl tilesUtil = TilesUtil . getTilesUtil ( ) ; if ( tilesUtil instanceof TilesUtilStrutsImpl ) { definitionsFactory = ( ( TilesUtilStrutsImpl ) tilesUtil ) . getDefinitionsFactory ( getServletContext ( ) , moduleConfig ) ; if ( definitionsFactory == null && log . isDebugEnabled ( ) ) { log . debug ( "Definition Factory not found for module: '" + moduleConfig . getPrefix ( ) ) ; } } }
Read component instance mapping configuration file . This is where we read files properties .
9,511
protected void processNoCache ( HttpServletRequest request , HttpServletResponse response ) { boolean noCache = moduleConfig . getControllerConfig ( ) . getNocache ( ) ; if ( ! noCache ) { PageFlowConfig pfConfig = ConfigUtil . getConfig ( ) . getPageFlowConfig ( ) ; if ( pfConfig != null ) { PreventCache preventCache = pfConfig . getPreventCache ( ) ; if ( preventCache != null ) { switch ( preventCache . getValue ( ) ) { case PreventCache . INT_ALWAYS : noCache = true ; break ; case PreventCache . INT_IN_DEV_MODE : noCache = ! _servletContainerAdapter . isInProductionMode ( ) ; break ; } } } } if ( noCache ) { ServletUtils . preventCache ( response ) ; PageFlowUtils . setPreventCache ( request ) ; } }
Set the no - cache headers . This overrides the base Struts behavior to prevent caching even for the pages .
9,512
protected void prepareToAddChildNode ( ) throws IOException { if ( isOpen == false ) { throw new IOException ( "Attempting to write to a closed document!" ) ; } if ( lastChildNode != null ) { lastChildNode . close ( ) ; lastChildNode = null ; } writer . write ( "\n" ) ; }
Internal abstraction method ; prepares the document for inserting a new child tag of any type .
9,513
public static ServiceFactory newInstance ( ) throws ServiceException { if ( factory == null ) { PrivilegedAction action = new PropertyAccessAction ( SERVICEFACTORY_PROPERTY , DEFAULT_SERVICE_FACTORY ) ; String factoryName = ( String ) AccessController . doPrivileged ( action ) ; ClassLoader loader = Thread . currentThread ( ) . getContextClassLoader ( ) ; try { try { Class factoryClass = loader . loadClass ( factoryName ) ; factory = ( ServiceFactory ) factoryClass . newInstance ( ) ; } catch ( ClassNotFoundException e ) { if ( factoryName . equals ( DEFAULT_SERVICE_FACTORY ) == false ) throw e ; for ( int i = 0 ; i < alternativeFactories . length ; i ++ ) { factoryName = alternativeFactories [ i ] ; try { Class factoryClass = loader . loadClass ( factoryName ) ; return ( ServiceFactory ) factoryClass . newInstance ( ) ; } catch ( ClassNotFoundException e1 ) { log . severe ( "Cannot load factory: " + factoryName ) ; } } } } catch ( Throwable e ) { throw new ServiceException ( "Failed to create factory: " + factoryName , e ) ; } } if ( factory == null ) throw new ServiceException ( "Cannot find ServiceFactory implementation" ) ; return factory ; }
Gets an instance of the ServiceFactory Only one copy of a factory exists and is returned to the application each time this method is called .
9,514
public void setHandlerConfig ( Map config ) { configMap . clear ( ) ; if ( config != null ) configMap . putAll ( config ) ; }
Sets the Handler configuration as java . util . Map
9,515
public static boolean isLegacyJavaScript ( ) { if ( javascriptMode == - 1 ) { setLegacyJavaScriptMode ( ) ; } assert ( javascriptMode != - 1 ) ; return ( javascriptMode == IdJavascript . INT_LEGACY || javascriptMode == IdJavascript . INT_LEGACY_ONLY ) ; }
Return true if the legacy JavaScript support should be written to the output stream .
9,516
public static boolean isDefaultJavaScript ( ) { if ( javascriptMode == - 1 ) { setLegacyJavaScriptMode ( ) ; } assert ( javascriptMode != - 1 ) ; return ( javascriptMode == IdJavascript . INT_DEFAULT || javascriptMode == IdJavascript . INT_LEGACY ) ; }
Return true if the default JavaScript support should be written to the output stream .
9,517
private static void setLegacyJavaScriptMode ( ) { JspTagConfig tagConfig = ConfigUtil . getConfig ( ) . getJspTagConfig ( ) ; if ( tagConfig != null ) { javascriptMode = tagConfig . getIdJavascript ( ) . getValue ( ) ; } else { javascriptMode = IdJavascript . INT_DEFAULT ; } }
This will set the JavaScript support level for the id and name attributes .
9,518
public int doEndTag ( ) throws JspException { if ( hasErrors ( ) ) return reportAndExit ( EVAL_PAGE ) ; HttpServletRequest req = ( HttpServletRequest ) pageContext . getRequest ( ) ; WriteRenderAppender writer = new WriteRenderAppender ( pageContext ) ; TagRenderingBase trb = TagRenderingBase . Factory . getRendering ( TagRenderingBase . ANCHOR_TAG , req ) ; ByRef script = new ByRef ( ) ; if ( ! createAnchorBeginTag ( req , script , trb , writer , REQUIRED_ATTR ) ) { reportErrors ( ) ; if ( ! script . isNull ( ) ) write ( script . getRef ( ) . toString ( ) ) ; localRelease ( ) ; return EVAL_PAGE ; } HttpServletResponse response = ( HttpServletResponse ) pageContext . getResponse ( ) ; if ( _imgState . src != null ) { try { String uri = PageFlowTagUtils . rewriteResourceURL ( pageContext , _imgState . src , null , null ) ; _imgState . src = response . encodeURL ( uri ) ; } catch ( URISyntaxException e ) { String s = Bundle . getString ( "Tags_Image_URLException" , new Object [ ] { _imgState . src , e . getMessage ( ) } ) ; registerTagError ( s , e ) ; } } if ( _rolloverImage != null ) { try { String uri = PageFlowTagUtils . rewriteResourceURL ( pageContext , _rolloverImage , null , null ) ; _rolloverImage = response . encodeURL ( uri ) ; } catch ( URISyntaxException e ) { String s = Bundle . getString ( "Tags_Rollover_Image_URLException" , new Object [ ] { _rolloverImage , e . getMessage ( ) } ) ; registerTagError ( s , e ) ; } if ( getJavaScriptAttribute ( ONMOUSEOUT ) == null ) { String s = "swapImage(this,'" + response . encodeURL ( _imgState . src ) + "')" ; _imgState . registerAttribute ( AbstractHtmlState . ATTR_JAVASCRIPT , ONMOUSEOUT , s ) ; } if ( getJavaScriptAttribute ( ONMOUSEOVER ) == null ) { String s = "swapImage(this,'" + response . encodeURL ( _rolloverImage ) + "')" ; _imgState . registerAttribute ( AbstractHtmlState . ATTR_JAVASCRIPT , ONMOUSEOVER , s ) ; } } TagRenderingBase br = TagRenderingBase . Factory . getRendering ( TagRenderingBase . IMAGE_TAG , req ) ; br . doStartTag ( writer , _imgState ) ; br . doEndTag ( writer ) ; trb . doEndTag ( writer ) ; if ( ! script . isNull ( ) ) write ( script . getRef ( ) . toString ( ) ) ; localRelease ( ) ; return EVAL_PAGE ; }
Render the image and hyperlink .
9,519
public int doStartTag ( ) throws JspException { Tag parent = getParent ( ) ; if ( parent != null ) { String s = Bundle . getString ( "TempExcp_ContainedTemplate" ) ; registerTagError ( s , null ) ; reportErrors ( ) ; _fatalError = true ; return SKIP_BODY ; } ServletRequest req = pageContext . getRequest ( ) ; _savedContext = ( TemplateContext ) req . getAttribute ( TEMPLATE_SECTIONS ) ; TemplateContext ctxt = new TemplateContext ( ) ; req . setAttribute ( TEMPLATE_SECTIONS , ctxt ) ; return EVAL_BODY_INCLUDE ; }
the tag extension lifecycle method called when the tag is first encountered . This will cause the body of the tag to be evaluated .
9,520
protected void localRelease ( ) { super . localRelease ( ) ; _fatalError = false ; _templatePage = null ; _innerErrors = null ; _reportErrors = false ; _savedContext = null ; }
Reset all of the fields of the tag .
9,521
public static String convertCharsToXml ( String input ) { StringBuffer result = new StringBuffer ( ) ; for ( int i = 0 ; i < input . length ( ) ; i ++ ) { switch ( input . charAt ( i ) ) { case '<' : result . append ( "&lt;" ) ; break ; case '>' : result . append ( "&gt;" ) ; break ; case '"' : result . append ( "&quot;" ) ; break ; case '\'' : result . append ( "&apos;" ) ; break ; case '&' : result . append ( "&amp;" ) ; break ; default : result . append ( input . charAt ( i ) ) ; } } return result . toString ( ) . trim ( ) ; }
Convenience method to convert XML reserved chars .
9,522
public static String convertCharsFromXml ( String input ) { StringBuffer result = new StringBuffer ( ) ; for ( int i = 0 ; i < input . length ( ) ; ) { if ( input . charAt ( i ) == '&' ) { if ( input . substring ( i , i + 3 ) . equals ( "&lt;" ) ) { result . append ( '<' ) ; i += 4 ; } else if ( input . substring ( i , i + 3 ) . equals ( "&gt;" ) ) { result . append ( '>' ) ; i += 4 ; } else if ( input . substring ( i , i + 4 ) . equals ( "&amp;" ) ) { result . append ( '&' ) ; i += 5 ; } else if ( input . substring ( i , i + 5 ) . equals ( "&quot;" ) ) { result . append ( '"' ) ; i += 6 ; } else if ( input . substring ( i , i + 5 ) . equals ( "&apos;" ) ) { result . append ( '\'' ) ; i += 6 ; } else { result . append ( input . charAt ( i ) ) ; i ++ ; } } else { result . append ( input . charAt ( i ) ) ; i ++ ; } } return result . toString ( ) ; }
Convenience method for backward conversion of XML encoded chars .
9,523
public AjaxUrlInfo getAjaxUrl ( ServletContext servletContext , ServletRequest request , Object nameable ) { HttpServletRequest req = ( HttpServletRequest ) request ; String name = null ; if ( nameable instanceof INameable ) name = ( ( INameable ) nameable ) . getObjectName ( ) ; String path = req . getServletPath ( ) ; int idx = path . lastIndexOf ( '/' ) ; if ( idx != - 1 ) { path = "/" + path . substring ( 1 , idx ) ; } path = req . getContextPath ( ) + path ; return new AjaxUrlInfo ( path , name ) ; }
This method will get the prefix for all URLs that are used for AJAX processing
9,524
protected void addModelReference ( XAttributable object , SXTag target ) throws IOException { XAttributeLiteral modelRefAttr = ( XAttributeLiteral ) object . getAttributes ( ) . get ( XSemanticExtension . KEY_MODELREFERENCE ) ; if ( modelRefAttr != null ) { target . addAttribute ( "modelReference" , modelRefAttr . getValue ( ) ) ; } }
Helper method adds all model references of an attributable to the given tag .
9,525
public boolean isOWL2DLOntologyID ( ) { return ! ontologyIRI . isPresent ( ) || ! ontologyIRI . get ( ) . isReservedVocabulary ( ) && ( ! versionIRI . isPresent ( ) || ! versionIRI . get ( ) . isReservedVocabulary ( ) ) ; }
Determines if this is a valid OWL 2 DL ontology ID . To be a valid OWL 2 DL ID the ontology IRI and version IRI must not be reserved vocabulary .
9,526
public String ensureValidExpression ( String dataSource , String attrName , String errorId ) throws JspException { try { boolean isExpr = isExpression ( dataSource ) ; if ( ! isExpr && containsExpression ( dataSource ) ) { String s = Bundle . getString ( errorId , new Object [ ] { dataSource } ) ; _tag . registerTagError ( s , null ) ; return null ; } if ( ! isExpr ) { String s = Bundle . getString ( errorId , new Object [ ] { dataSource } ) ; _tag . registerTagError ( s , null ) ; return null ; } } catch ( Exception e ) { if ( e instanceof JspException ) throw ( JspException ) e ; String s = Bundle . getString ( errorId , new Object [ ] { dataSource } ) ; _tag . registerTagError ( s , e ) ; return null ; } return dataSource ; }
Ensure that the passed in data source is a valid expression .
9,527
private Object evaluateExpressionInternal ( String expression , String attrName , PageContext pageContext ) throws JspException { if ( logger . isDebugEnabled ( ) ) logger . debug ( "evaluate expression=\"" + expression + "\"" ) ; Object result = null ; try { VariableResolver vr = ImplicitObjectUtil . getReadVariableResolver ( pageContext ) ; result = getExpressionEvaluator ( ) . evaluateStrict ( expression , vr ) ; } catch ( ExpressionEvaluationException ee ) { if ( logger . isWarnEnabled ( ) ) logger . warn ( Bundle . getString ( "Tags_ExpressionEvaluationFailure" , expression ) ) ; EvalErrorInfo info = new EvalErrorInfo ( ) ; info . evalExcp = ee ; info . expression = expression ; info . attr = attrName ; info . tagType = _tag . getTagName ( ) ; _tag . registerTagError ( info ) ; return null ; } catch ( Exception e ) { String s = Bundle . getString ( "Tags_ExpressionEvaluationException" , new Object [ ] { expression , e . toString ( ) } ) ; _tag . registerTagError ( s , e ) ; return null ; } if ( logger . isDebugEnabled ( ) ) logger . debug ( "resulting object: " + result ) ; return result ; }
This is the real implementation of evaluateExpression .
9,528
public static String getModulePath ( HttpServletRequest request , String requestURI ) { return getModulePathForRelativeURI ( getRelativeURI ( request , requestURI , null ) ) ; }
Get the Struts module path for a URI . This is the parent directory relative to the web application root of the file referenced by the URI .
9,529
public static String getModulePathForRelativeURI ( String uri ) { if ( uri == null ) return null ; assert uri . length ( ) > 0 ; assert uri . charAt ( 0 ) == '/' : uri ; int slash = uri . lastIndexOf ( '/' ) ; uri = uri . substring ( 0 , slash ) ; return uri ; }
Get the Struts module path for a URI that is relative to the web application root .
9,530
public static String getRelativeURI ( HttpServletRequest request , PageFlowController relativeTo ) { if ( relativeTo == null ) return InternalUtils . getDecodedServletPath ( request ) ; return getRelativeURI ( request , InternalUtils . getDecodedURI ( request ) , relativeTo ) ; }
Get the request URI relative to the URI of the given PageFlowController .
9,531
public static String getRelativeURI ( HttpServletRequest request , String uri , PageFlowController relativeTo ) { String contextPath = request . getContextPath ( ) ; if ( relativeTo != null ) contextPath += relativeTo . getModulePath ( ) ; int overlap = uri . indexOf ( contextPath + '/' ) ; if ( overlap == - 1 ) return null ; return uri . substring ( overlap + contextPath . length ( ) ) ; }
Get a URI relative to the URI of the given PageFlowController .
9,532
public static String getBeginActionURI ( String requestURI ) { InternalStringBuilder retVal = new InternalStringBuilder ( ) ; int lastSlash = requestURI . lastIndexOf ( '/' ) ; if ( lastSlash != - 1 ) { retVal . append ( requestURI . substring ( 0 , lastSlash ) ) ; } retVal . append ( '/' ) . append ( BEGIN_ACTION_NAME ) . append ( ACTION_EXTENSION ) ; return retVal . toString ( ) ; }
Get a URI for the begin action in the PageFlowController associated with the given request URI .
9,533
public static SharedFlowController getSharedFlow ( String sharedFlowClassName , HttpServletRequest request , ServletContext servletContext ) { StorageHandler sh = Handlers . get ( servletContext ) . getStorageHandler ( ) ; HttpServletRequest unwrappedRequest = unwrapMultipart ( request ) ; RequestContext rc = new RequestContext ( unwrappedRequest , null ) ; String attrName = ScopedServletUtils . getScopedSessionAttrName ( InternalConstants . SHARED_FLOW_ATTR_PREFIX + sharedFlowClassName , request ) ; SharedFlowController sf = ( SharedFlowController ) sh . getAttribute ( rc , attrName ) ; if ( sf != null ) { sf . reinitializeIfNecessary ( request , null , servletContext ) ; } return sf ; }
Get the shared flow with the given class name .
9,534
public static String getFormBeanName ( ActionForm formInstance , HttpServletRequest request ) { return getFormBeanName ( formInstance . getClass ( ) , request ) ; }
Get the name for the type of a ActionForm instance . Use a name looked up from the current Struts module or if none is found create one .
9,535
public static String getFormBeanName ( Class formBeanClass , HttpServletRequest request ) { ModuleConfig moduleConfig = RequestUtils . getRequestModuleConfig ( request ) ; List names = getFormNamesFromModuleConfig ( formBeanClass . getName ( ) , moduleConfig ) ; if ( names != null ) { assert names . size ( ) > 0 ; return ( String ) names . get ( 0 ) ; } return generateFormBeanName ( formBeanClass , request ) ; }
Get the name for an ActionForm type . Use a name looked up from the current Struts module or if none is found create one .
9,536
private static String generateFormBeanName ( Class formBeanClass , HttpServletRequest request ) { ModuleConfig moduleConfig = RequestUtils . getRequestModuleConfig ( request ) ; String formBeanClassName = formBeanClass . getName ( ) ; String formType = formBeanClassName ; int lastQualifier = formType . lastIndexOf ( '$' ) ; if ( lastQualifier == - 1 ) { lastQualifier = formType . lastIndexOf ( '.' ) ; } String formName = formType . substring ( lastQualifier + 1 ) ; formName = Character . toLowerCase ( formName . charAt ( 0 ) ) + formName . substring ( 1 ) ; if ( moduleConfig . findFormBeanConfig ( formName ) != null ) { formName = formType . replace ( '.' , '_' ) . replace ( '$' , '_' ) ; assert moduleConfig . findFormBeanConfig ( formName ) == null : formName ; } return formName ; }
Create the name for a form bean type .
9,537
public static Object getActionOutput ( String name , ServletRequest request ) { Map map = InternalUtils . getActionOutputMap ( request , false ) ; return map != null ? map . get ( name ) : null ; }
Get a named action output that was registered in the current request .
9,538
public static String getRewrittenActionURI ( ServletContext servletContext , HttpServletRequest request , HttpServletResponse response , String actionName , Map params , String fragment , boolean forXML ) throws URISyntaxException { MutableURI uri = getActionURI ( servletContext , request , response , actionName ) ; if ( params != null ) uri . addParameters ( params , false ) ; if ( fragment != null ) uri . setFragment ( uri . encode ( fragment ) ) ; boolean needsToBeSecure = needsToBeSecure ( servletContext , request , uri . getPath ( ) , true ) ; URLRewriterService . rewriteURL ( servletContext , request , response , uri , URLType . ACTION , needsToBeSecure ) ; String key = getURLTemplateKey ( URLType . ACTION , needsToBeSecure ) ; URIContext uriContext = URIContextFactory . getInstance ( forXML ) ; return URLRewriterService . getTemplatedURL ( servletContext , request , uri , key , uriContext ) ; }
Create a fully - rewritten URI given an action name and parameters .
9,539
public static boolean needsToBeSecure ( ServletContext context , ServletRequest request , String uri , boolean stripContextPath ) { String secureCheck = uri ; if ( stripContextPath ) { String contextPath = ( ( HttpServletRequest ) request ) . getContextPath ( ) ; if ( secureCheck . startsWith ( contextPath ) ) { secureCheck = secureCheck . substring ( contextPath . length ( ) ) ; } } boolean secure = false ; if ( secureCheck . indexOf ( '?' ) > - 1 ) { secureCheck = secureCheck . substring ( 0 , secureCheck . indexOf ( '?' ) ) ; } SecurityProtocol sp = getSecurityProtocol ( secureCheck , context , ( HttpServletRequest ) request ) ; if ( sp . equals ( SecurityProtocol . UNSPECIFIED ) ) { secure = request . isSecure ( ) ; } else { secure = sp . equals ( SecurityProtocol . SECURE ) ; } return secure ; }
Tell whether a given URI should be written to be secure .
9,540
public static String getURLTemplateKey ( URLType urlType , boolean needsToBeSecure ) { String key = URLTemplatesFactory . ACTION_TEMPLATE ; if ( urlType . equals ( URLType . ACTION ) ) { if ( needsToBeSecure ) { key = URLTemplatesFactory . SECURE_ACTION_TEMPLATE ; } else { key = URLTemplatesFactory . ACTION_TEMPLATE ; } } else if ( urlType . equals ( URLType . RESOURCE ) ) { if ( needsToBeSecure ) { key = URLTemplatesFactory . SECURE_RESOURCE_TEMPLATE ; } else { key = URLTemplatesFactory . RESOURCE_TEMPLATE ; } } return key ; }
Returns a key for the URL template type given the URL type and a flag indicating a secure URL or not .
9,541
@ SuppressWarnings ( "unchecked" ) public void mousePressed ( MouseEvent e ) { if ( checkModifiers ( e ) ) { final VisualizationViewer < String , String > vv = ( VisualizationViewer < String , String > ) e . getSource ( ) ; final Point2D p = e . getPoint ( ) ; GraphElementAccessor < String , String > pickSupport = vv . getPickSupport ( ) ; if ( pickSupport != null ) { final String vertex = pickSupport . getVertex ( vv . getModel ( ) . getGraphLayout ( ) , p . getX ( ) , p . getY ( ) ) ; if ( vertex != null ) { startVertex = vertex ; down = e . getPoint ( ) ; transformEdgeShape ( down , down ) ; vv . addPostRenderPaintable ( edgePaintable ) ; transformArrowShape ( down , e . getPoint ( ) ) ; vv . addPostRenderPaintable ( arrowPaintable ) ; } } vv . repaint ( ) ; } }
If the mouse is pressed in an empty area create a new vertex there . If the mouse is pressed on an existing vertex prepare to create an edge from that vertex to another
9,542
@ SuppressWarnings ( "unchecked" ) public void mouseReleased ( MouseEvent e ) { if ( checkModifiers ( e ) ) { final VisualizationViewer < String , String > vv = ( VisualizationViewer < String , String > ) e . getSource ( ) ; final Point2D p = e . getPoint ( ) ; Layout < String , String > layout = vv . getModel ( ) . getGraphLayout ( ) ; GraphElementAccessor < String , String > pickSupport = vv . getPickSupport ( ) ; if ( pickSupport != null ) { final String vertex = pickSupport . getVertex ( layout , p . getX ( ) , p . getY ( ) ) ; if ( vertex != null && startVertex != null ) { Graph < String , String > graph = vv . getGraphLayout ( ) . getGraph ( ) ; try { if ( graph . addEdge ( startVertex + "-" + vertex , startVertex , vertex , EdgeType . DIRECTED ) ) { notifyListeners ( startVertex , vertex ) ; } } catch ( Exception ex ) { ex . printStackTrace ( ) ; } } vv . repaint ( ) ; } startVertex = null ; down = null ; vv . removePostRenderPaintable ( edgePaintable ) ; vv . removePostRenderPaintable ( arrowPaintable ) ; } }
If startVertex is non - null and the mouse is released over an existing vertex create an undirected edge from startVertex to the vertex under the mouse pointer . If shift was also pressed create a directed edge instead .
9,543
@ SuppressWarnings ( "unchecked" ) public void mouseDragged ( MouseEvent e ) { if ( checkModifiers ( e ) ) { if ( startVertex != null ) { transformEdgeShape ( down , e . getPoint ( ) ) ; transformArrowShape ( down , e . getPoint ( ) ) ; } VisualizationViewer < String , String > vv = ( VisualizationViewer < String , String > ) e . getSource ( ) ; vv . repaint ( ) ; } }
If startVertex is non - null stretch an edge shape between startVertex and the mouse pointer to simulate edge creation
9,544
private void transformEdgeShape ( Point2D down , Point2D out ) { float x1 = ( float ) down . getX ( ) ; float y1 = ( float ) down . getY ( ) ; float x2 = ( float ) out . getX ( ) ; float y2 = ( float ) out . getY ( ) ; AffineTransform xform = AffineTransform . getTranslateInstance ( x1 , y1 ) ; float dx = x2 - x1 ; float dy = y2 - y1 ; float thetaRadians = ( float ) Math . atan2 ( dy , dx ) ; xform . rotate ( thetaRadians ) ; float dist = ( float ) Math . sqrt ( dx * dx + dy * dy ) ; xform . scale ( dist / rawEdge . getBounds ( ) . getWidth ( ) , 1.0 ) ; edgeShape = xform . createTransformedShape ( rawEdge ) ; }
code lifted from PluggableRenderer to move an edge shape into an arbitrary position
9,545
public void init ( ServletRequest request ) { String [ ] vals = request . getParameterValues ( ITEM_PARAM ) ; if ( vals != null ) { _retrieveMap = new HashMap ( ) ; for ( int i = 0 ; i < vals . length ; i ++ ) { String val = vals [ i ] ; int delimPos = val . indexOf ( DELIM ) ; if ( delimPos != - 1 ) { String expressionToRetrieve = val . substring ( 0 , delimPos ) ; String fieldID = val . substring ( delimPos + 1 ) ; _retrieveMap . put ( fieldID , expressionToRetrieve ) ; } } } _callbackFunc = request . getParameter ( CALLBACK_PARAM ) ; }
Initialize based on request parameters we re looking for .
9,546
public static void write ( LogView logView , String path ) throws IOException { String xml = xstream . toXML ( logView ) ; try ( BufferedWriter out = new BufferedWriter ( new FileWriter ( path ) ) ) { out . write ( xml ) ; } }
Serializes the log view under the given path .
9,547
public int insertOrdered ( XEvent event ) { try { return events . insertOrdered ( event ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; return - 1 ; } }
Insert the event in an ordered manner if timestamp information is available in this trace .
9,548
public < T extends ControlBean > T instantiate ( Class < T > beanClass , PropertyMap props , ControlBeanContext context , String id ) { String beanClassName = beanClass . getName ( ) ; String extImplBinding = _extImplBindings . getProperty ( beanClassName + "_" + id ) ; if ( extImplBinding == null ) extImplBinding = _extImplBindings . getProperty ( beanClassName ) ; if ( extImplBinding != null ) { BeanPropertyMap bpm = props == null ? new BeanPropertyMap ( beanClass ) : new BeanPropertyMap ( props ) ; PropertyKey propKey = new PropertyKey ( org . apache . beehive . controls . api . properties . BaseProperties . class , KEY_CONTROL_IMPLEMENTATION ) ; bpm . setProperty ( propKey , extImplBinding ) ; props = bpm ; } T ret = null ; try { Constructor < T > ctor = _constructors . get ( beanClass ) ; if ( ctor == null ) { ctor = beanClass . getConstructor ( ControlBeanContext . class , String . class , PropertyMap . class ) ; _constructors . put ( beanClass , ctor ) ; } ret = ctor . newInstance ( context , id , props ) ; } catch ( InvocationTargetException ite ) { Throwable t = ite . getCause ( ) ; throw new ControlException ( "ControlBean constructor exception" , t ) ; } catch ( Exception e ) { throw new ControlException ( "Exception creating ControlBean" , e ) ; } return ret ; }
Instantiates a new ControlBean of the requested class using mechanisms provided by a provider - specific JavaBeans framework .
9,549
public static void checkReflectionParameters ( SqlFragmentContainer statement , MethodDeclaration methodDecl ) { ArrayList < ParameterDeclaration > params = new ArrayList < ParameterDeclaration > ( methodDecl . getParameters ( ) ) ; HashMap < String , ParameterDeclaration > paramMap = new HashMap < String , ParameterDeclaration > ( ) ; if ( params . size ( ) > 0 && params . get ( 0 ) . getSimpleName ( ) . equals ( "arg0" ) ) { return ; } for ( int i = 0 ; i < params . size ( ) ; i ++ ) { paramMap . put ( params . get ( i ) . getSimpleName ( ) , params . get ( i ) ) ; } doCheck ( statement , paramMap , methodDecl ) ; }
Verify that all reflection parameters in the statement element can be mapped to method parameters .
9,550
private static void doCheck ( SqlFragmentContainer statement , HashMap < String , ParameterDeclaration > paramMap , final MethodDeclaration method ) { SqlFragment [ ] fragments = statement . getChildren ( ) ; for ( SqlFragment fragment : fragments ) { if ( fragment instanceof SqlFragmentContainer ) { doCheck ( ( SqlFragmentContainer ) fragment , paramMap , method ) ; } else if ( fragment instanceof ReflectionFragment ) { checkReflectionFragment ( ( ReflectionFragment ) fragment , paramMap , method ) ; } } }
Walk the tree of children of the statement process all children of type ReflectionFragment .
9,551
private static String buildMessage ( String parameterName , String methodName ) { ResourceBundle rb = ResourceBundle . getBundle ( "org.apache.beehive.controls.system.jdbc.parser.strings" , Locale . getDefault ( ) ) ; String pattern = rb . getString ( "jdbccontrol.invalid.param" ) ; return MessageFormat . format ( pattern , parameterName , methodName ) ; }
Build the error message for this module .
9,552
public void setUserInfo ( String userInfo ) { _userInfo = null ; if ( userInfo != null && userInfo . length ( ) > 0 ) { _userInfo = userInfo ; } }
Sets the userInfo . Assumes this component is already escaped .
9,553
public void setHost ( String host ) { _host = null ; if ( host != null && host . length ( ) > 0 ) { boolean needBrackets = ( ( host . indexOf ( ':' ) >= 0 ) && ! host . startsWith ( "[" ) && ! host . endsWith ( "]" ) ) ; if ( needBrackets ) { _host = '[' + host + ']' ; } else { _host = host ; } _opaque = false ; setSchemeSpecificPart ( null ) ; } if ( _host == null ) { setUserInfo ( null ) ; setPort ( UNDEFINED_PORT ) ; } }
Sets the host .
9,554
public void setPort ( int port ) { assert ( port >= 0 && port <= 65535 ) || ( port == UNDEFINED_PORT ) : "Invalid port" ; if ( ( port > 65535 ) || ( port < 0 && port != UNDEFINED_PORT ) ) { throw new IllegalArgumentException ( "A port must be between 0 and 65535 or equal to " + UNDEFINED_PORT + "." ) ; } _port = port ; }
Sets the port .
9,555
public void setPath ( String path ) { if ( path == null ) { _path = null ; setQuery ( null ) ; setFragment ( null ) ; } else { _path = path ; _opaque = false ; setSchemeSpecificPart ( null ) ; } }
Sets the path . Assumes this component is already escaped .
9,556
public String getParameter ( String name ) { if ( _parameters == null || ! _parameters . hasParameters ( ) ) return null ; List parameters = _parameters . getParameterValues ( name ) ; if ( parameters != null && parameters . size ( ) > 0 ) return ( String ) parameters . get ( 0 ) ; else return null ; }
Returns the value of the parameter . If several values are associated with the given parameter name the first value is returned .
9,557
public List getParameters ( String name ) { if ( _parameters == null || ! _parameters . hasParameters ( ) ) return Collections . EMPTY_LIST ; else { List parameters = _parameters . getParameterValues ( name ) ; if ( parameters == null ) return Collections . EMPTY_LIST ; else return Collections . unmodifiableList ( parameters ) ; } }
Returns the values of the given parameter .
9,558
public void removeParameter ( String name ) { if ( _parameters == null || ! _parameters . hasParameters ( ) ) return ; _parameters . removeParameter ( name ) ; }
Removes the given parameter .
9,559
public void setFragment ( String fragment ) { _fragment = null ; if ( fragment != null && fragment . length ( ) > 0 ) { _fragment = fragment ; } }
Sets the fragment .
9,560
public static String encode ( String url , String encoding ) { String encodedURL = null ; try { encodedURL = URLCodec . encode ( url , encoding ) ; } catch ( java . io . UnsupportedEncodingException e ) { try { encodedURL = URLCodec . encode ( url , DEFAULT_ENCODING ) ; } catch ( java . io . UnsupportedEncodingException ignore ) { } } return encodedURL ; }
Convenience method to encode unencoded components of a URI .
9,561
protected static int indexFirstOf ( String s , String delims , int offset ) { if ( s == null || s . length ( ) == 0 ) { return - 1 ; } if ( delims == null || delims . length ( ) == 0 ) { return - 1 ; } if ( offset < 0 ) { offset = 0 ; } else if ( offset > s . length ( ) ) { return - 1 ; } int min = s . length ( ) ; char [ ] delim = delims . toCharArray ( ) ; for ( int i = 0 ; i < delim . length ; i ++ ) { int at = s . indexOf ( delim [ i ] , offset ) ; if ( at >= 0 && at < min ) { min = at ; } } return ( min == s . length ( ) ) ? - 1 : min ; }
Get the earliest index searching for the first occurrance of any one of the given delimiters .
9,562
public boolean canParse ( File file ) { for ( XParser parser : XParserRegistry . instance ( ) . getAvailable ( ) ) { if ( parser . canParse ( file ) ) { return true ; } } return false ; }
Checks whether the given file can be parsed by any parser .
9,563
public Collection < XLog > parse ( File file ) throws Exception { Collection < XLog > result = null ; for ( XParser parser : XParserRegistry . instance ( ) . getAvailable ( ) ) { if ( parser . canParse ( file ) ) { try { result = parser . parse ( file ) ; return result ; } catch ( Exception e ) { } } } throw new Exception ( "No suitable parser could be found!" ) ; }
Attempts to parse a collection of XES models from the given file using all available parsers .
9,564
public int doStartTag ( ) throws JspException { ServletRequest req = pageContext . getRequest ( ) ; Template . TemplateContext tc = ( Template . TemplateContext ) req . getAttribute ( TEMPLATE_SECTIONS ) ; if ( tc == null ) { String s = Bundle . getString ( "Tags_TemplateContextMissing" ) ; logger . warn ( stripBold ( s ) ) ; registerTagError ( s , null ) ; reportErrors ( ) ; localRelease ( ) ; return SKIP_BODY ; } if ( tc . secs == null ) { if ( _default != null ) { return callDefault ( req ) ; } String s = Bundle . getString ( "Tags_TemplateSectionMissing" , new Object [ ] { _name } ) ; logger . warn ( stripBold ( s ) ) ; registerTagError ( s , null ) ; reportErrors ( ) ; localRelease ( ) ; return SKIP_BODY ; } String val = ( String ) tc . secs . get ( _name ) ; if ( val == null ) { if ( _default == null ) { String s = Bundle . getString ( "Tags_TemplateSectionMissing" , new Object [ ] { _name } ) ; logger . warn ( stripBold ( s ) ) ; registerTagError ( s , null ) ; reportErrors ( ) ; localRelease ( ) ; return SKIP_BODY ; } return callDefault ( req ) ; } try { Writer out = pageContext . getOut ( ) ; out . write ( val ) ; } catch ( IOException e ) { String reason = Bundle . getString ( "TempExcp_WritingContent" ) ; String s = Bundle . getString ( "TempExcp_Except" , new Object [ ] { "IOException" , reason } ) ; logger . error ( s ) ; JspException jspException = new JspException ( s , e ) ; if ( jspException . getCause ( ) == null ) { jspException . initCause ( e ) ; } throw jspException ; } localRelease ( ) ; return SKIP_BODY ; }
Renders the content of the section into the template . Errors are reported inline within the template in development mode . If no sections are defined an error is reported . If a section is not defined and no default URL is provided an error is reported .
9,565
static String stripBold ( String in ) { String boldStart = "<b>" ; String boldEnd = "</b>" ; int pos = in . indexOf ( boldStart ) ; if ( pos == - 1 ) return in ; InternalStringBuilder sb = new InternalStringBuilder ( in . substring ( 0 , pos ) ) ; int fill = pos + boldStart . length ( ) ; pos = in . indexOf ( boldEnd , fill ) ; if ( pos == - 1 ) return in ; sb . append ( in . substring ( fill , pos ) ) ; pos += boldEnd . length ( ) ; sb . append ( in . substring ( pos ) ) ; return sb . toString ( ) ; }
This will strip any html out of a warning
9,566
public static < T extends Annotation > T getProxy ( Class < T > propertySet , PropertyMap propertyMap ) { assert propertySet != null && propertyMap != null ; if ( ! propertySet . isAnnotation ( ) ) throw new IllegalArgumentException ( propertySet + " is not an annotation type" ) ; return ( T ) Proxy . newProxyInstance ( propertySet . getClassLoader ( ) , new Class [ ] { propertySet } , new PropertySetProxy ( propertySet , propertyMap ) ) ; }
Creates a new proxy instance implementing the PropertySet interface and backed by the data from the property map .
9,567
protected boolean needsUniqueID ( ) { for ( AnnotationMirror annotMirror : _clientDecl . getAnnotationMirrors ( ) ) { String annotType = annotMirror . getAnnotationType ( ) . toString ( ) ; if ( annotType . equals ( "org.apache.beehive.netui.pageflow.annotations.Jpf.Controller" ) || annotType . equals ( "org.apache.beehive.netui.pageflow.annotations.Jpf.Backing" ) ) return true ; } return false ; }
Returns true if this type of client requires that nested controls have unique identifiers
9,568
public String getID ( AptControlField control ) { if ( ! needsUniqueID ( ) ) return "\"" + control . getName ( ) + "\"" ; return "client.getClass() + \"@\" + client.hashCode() + \"." + control . getClassName ( ) + "." + control . getName ( ) + "\"" ; }
Returns a unique ID for a control field
9,569
protected ArrayList < AptControlField > initControls ( ) { ArrayList < AptControlField > controls = new ArrayList < AptControlField > ( ) ; if ( _clientDecl == null || _clientDecl . getFields ( ) == null ) return controls ; Collection < FieldDeclaration > declaredFields = _clientDecl . getFields ( ) ; for ( FieldDeclaration fieldDecl : declaredFields ) { if ( fieldDecl . getAnnotation ( org . apache . beehive . controls . api . bean . Control . class ) != null ) controls . add ( new AptControlField ( this , fieldDecl , _ap ) ) ; } return controls ; }
Initializes the list of ControlFields declared directly by this ControlClient
9,570
public String getSuperClientName ( ) { ClassType superType = _clientDecl . getSuperclass ( ) ; while ( superType != null ) { ClassDeclaration superDecl = superType . getDeclaration ( ) ; Collection < FieldDeclaration > declaredFields = superDecl . getFields ( ) ; for ( FieldDeclaration fieldDecl : declaredFields ) { if ( fieldDecl . getAnnotation ( org . apache . beehive . controls . api . bean . Control . class ) != null ) { return superDecl . getQualifiedName ( ) ; } } superType = superType . getSuperclass ( ) ; } return null ; }
Returns the fully qualified classname of the closest control client in the inheritance chain .
9,571
private void enforceVersionRequired ( FieldDeclaration f , InterfaceDeclaration controlIntf ) { VersionRequired versionRequired = f . getAnnotation ( VersionRequired . class ) ; Version versionPresent = controlIntf . getAnnotation ( Version . class ) ; if ( versionRequired != null ) { int majorRequired = - 1 ; try { majorRequired = versionRequired . major ( ) ; } catch ( NullPointerException ignore ) { return ; } int minorRequired = versionRequired . minor ( ) ; if ( majorRequired < 0 ) return ; int majorPresent = - 1 ; int minorPresent = - 1 ; if ( versionPresent != null ) { try { majorPresent = versionPresent . major ( ) ; } catch ( NullPointerException ignore ) { } minorPresent = versionPresent . minor ( ) ; if ( majorRequired <= majorPresent && ( minorRequired < 0 || minorRequired <= minorPresent ) ) { return ; } } printError ( f , "control.field.bad.version" , f . getSimpleName ( ) , majorRequired , minorRequired , majorPresent , minorPresent ) ; } }
Enforces the VersionRequired annotation for control fields .
9,572
protected Method getExceptionHandlerMethod ( FlowControllerHandlerContext context , String methodName , Throwable ex , Object formBean ) { FlowController flowController = context . getFlowController ( ) ; String cacheKey = methodName + '/' + ex . getClass ( ) . getName ( ) ; ClassLevelCache cache = ClassLevelCache . getCache ( flowController . getClass ( ) ) ; Method method = ( Method ) cache . get ( CACHEID_EXCEPTION_HANDLER_METHODS , cacheKey ) ; if ( method != null ) { return method ; } Class flowControllerClass = flowController . getClass ( ) ; for ( Class exClass = ex . getClass ( ) ; exClass != null ; exClass = exClass . getSuperclass ( ) ) { Class [ ] args = new Class [ ] { exClass , String . class , String . class , Object . class } ; Method foundMethod = InternalUtils . lookupMethod ( flowControllerClass , methodName , args ) ; if ( foundMethod == null && ( formBean == null || formBean instanceof FormData ) ) { args = new Class [ ] { exClass , String . class , String . class , FormData . class } ; foundMethod = InternalUtils . lookupMethod ( flowControllerClass , methodName , args ) ; } if ( foundMethod == null && ( formBean == null || formBean instanceof ActionForm ) ) { args = new Class [ ] { exClass , String . class , String . class , ActionForm . class } ; foundMethod = InternalUtils . lookupMethod ( flowControllerClass , methodName , args ) ; } if ( foundMethod != null ) { if ( _log . isDebugEnabled ( ) ) { _log . debug ( "Found exception handler for " + exClass . getName ( ) ) ; } if ( ! Modifier . isPublic ( foundMethod . getModifiers ( ) ) ) foundMethod . setAccessible ( true ) ; cache . put ( CACHEID_EXCEPTION_HANDLER_METHODS , cacheKey , foundMethod ) ; return foundMethod ; } else { if ( _log . isErrorEnabled ( ) ) { InternalStringBuilder msg = new InternalStringBuilder ( "Could not find exception handler method " ) ; msg . append ( methodName ) . append ( " for " ) . append ( exClass . getName ( ) ) . append ( '.' ) ; _log . error ( msg . toString ( ) ) ; } } } return null ; }
Get an Exception handler method .
9,573
public synchronized void alertSoftCopies ( ) throws IOException { NikeFS2LazyRandomAccessStorageImpl [ ] copies = softCopies . toArray ( new NikeFS2LazyRandomAccessStorageImpl [ softCopies . size ( ) ] ) ; for ( NikeFS2LazyRandomAccessStorageImpl copy : copies ) { if ( copy . isSoftCopy ) { copy . consolidateSoftCopy ( ) ; copy . alertSoftCopies ( ) ; } } }
This method alerts all child soft copies of this storage to consolidate ; called prior to modification of this instance . The child soft copies so alerted will detach from this instance consequently .
9,574
public synchronized void consolidateSoftCopy ( ) throws IOException { if ( isSoftCopy == true ) { ArrayList < NikeFS2Block > copyBlocks = new ArrayList < NikeFS2Block > ( ) ; if ( blocks . size ( ) > 0 ) { byte [ ] buffer = new byte [ blocks . get ( 0 ) . size ( ) ] ; for ( NikeFS2Block block : blocks ) { NikeFS2Block copyBlock = vfs . allocateBlock ( ) ; block . read ( 0 , buffer ) ; copyBlock . write ( 0 , buffer ) ; copyBlocks . add ( copyBlock ) ; } } blocks = copyBlocks ; isSoftCopy = false ; parent . deregisterSoftCopy ( this ) ; parent = null ; } }
Consolidates this soft copy prior to modification . This will detach this instance from its parent creating a true copy of its current data .
9,575
public boolean hasNext ( ) { if ( _primed ) { return true ; } try { _primed = _rs . next ( ) ; } catch ( SQLException sqle ) { return false ; } return _primed ; }
Does this iterater have more elements?
9,576
public Object next ( ) { try { if ( ! _primed ) { _primed = _rs . next ( ) ; if ( ! _primed ) { throw new NoSuchElementException ( ) ; } } _primed = false ; return _rowMapper . mapRowToReturnType ( ) ; } catch ( SQLException e ) { NoSuchElementException xNoSuch = new NoSuchElementException ( "ResultSet exception: " + e ) ; xNoSuch . initCause ( e ) ; throw xNoSuch ; } }
Get the next element in the iteration .
9,577
public static ControlContainerContext getContext ( ) { Stack < ControlContainerContext > contextStack = _threadContexts . get ( ) ; if ( contextStack == null || contextStack . size ( ) == 0 ) return null ; return contextStack . peek ( ) ; }
Returns the active ControlContainerContext for the current thread or null if no context is currently active .
9,578
public static void beginContext ( ControlContainerContext context ) { Stack < ControlContainerContext > contextStack = _threadContexts . get ( ) ; if ( contextStack == null ) { contextStack = new Stack < ControlContainerContext > ( ) ; _threadContexts . set ( contextStack ) ; } contextStack . push ( context ) ; }
Defines the beginning of a new control container execution context .
9,579
public static void endContext ( ControlContainerContext context ) { Stack < ControlContainerContext > contextStack = _threadContexts . get ( ) ; if ( contextStack == null || contextStack . size ( ) == 0 ) throw new IllegalStateException ( "No context started for current thread" ) ; if ( contextStack . peek ( ) != context ) throw new IllegalStateException ( "Context is not the current active context" ) ; contextStack . pop ( ) ; }
Ends the current control container execution context
9,580
public static synchronized DataUsageExtension instance ( ) { if ( SINGLETON == null ) { SINGLETON = new DataUsageExtension ( ) ; XFactory factory = XFactoryRegistry . instance ( ) . currentDefault ( ) ; ATTR_DATA = factory . createAttributeLiteral ( KEY_DATA , "" , SINGLETON ) ; SINGLETON . eventAttributes . add ( ( XAttribute ) ATTR_DATA . clone ( ) ) ; for ( Map . Entry < String , String > mapping : EXTENSION_DESCRIPTIONS . entrySet ( ) ) { XGlobalAttributeNameMap . instance ( ) . registerMapping ( mapping . getKey ( ) , KEY_DATA , mapping . getValue ( ) ) ; } } return SINGLETON ; }
Provides access to the singleton instance of this extension .
9,581
public String extractData ( XEvent event ) { XAttribute attribute = event . getAttributes ( ) . get ( KEY_DATA ) ; if ( attribute == null ) { return null ; } else { return ( ( XAttributeLiteral ) attribute ) . getValue ( ) ; } }
Extracts the data attribute string from an event .
9,582
public void assignData ( XEvent event , String data ) { if ( data != null && data . trim ( ) . length ( ) > 0 ) { XAttributeLiteral attr = ( XAttributeLiteral ) ATTR_DATA . clone ( ) ; attr . setValue ( data . trim ( ) ) ; event . getAttributes ( ) . put ( KEY_DATA , attr ) ; } }
Assigns the data attribute value for a given event .
9,583
protected AptControlInterface initControlInterface ( ) { TypeMirror fieldType = _fieldDecl . getType ( ) ; if ( ! ( fieldType instanceof InterfaceType ) ) { _ap . printError ( _fieldDecl , "context.field.badinterface" ) ; return null ; } return new AptControlInterface ( ( ( InterfaceType ) _fieldDecl . getType ( ) ) . getDeclaration ( ) , _ap ) ; }
Initializes a ControlInterface associated with this context field . Because contextual services can expose both APIs and events they are similar to controls .
9,584
public static String encode ( final String decoded , final String charset ) throws UnsupportedEncodingException { return s_codec . encode ( decoded , charset ) ; }
URL encodes a string .
9,585
public static String encode ( final String decoded ) { try { return s_codec . encode ( decoded ) ; } catch ( EncoderException e ) { throw new IllegalStateException ( Bundle . getErrorString ( "URLCodec_encodeException" , new String [ ] { e . getMessage ( ) } ) , e ) ; } }
URL encodes a string using the default character set
9,586
public static String decode ( final String encoded , final String charset ) throws UnsupportedEncodingException { try { return s_codec . decode ( encoded , charset ) ; } catch ( DecoderException e ) { throw new IllegalStateException ( Bundle . getErrorString ( "URLCodec_decodeException" , new String [ ] { e . getMessage ( ) } ) , e ) ; } }
URL decodes a string .
9,587
private NameGenerator getNameGenerator ( String namePrefix ) { synchronized ( this ) { if ( _nameGenerators == null ) _nameGenerators = new HashMap < String , NameGenerator > ( ) ; NameGenerator nameGenerator = _nameGenerators . get ( namePrefix ) ; if ( nameGenerator == null ) { nameGenerator = new NameGenerator ( namePrefix ) ; _nameGenerators . put ( namePrefix , nameGenerator ) ; } return nameGenerator ; } }
Returns a new NameGenerator instance based upon a particular naming prefix .
9,588
public String generateUniqueID ( Class clazz ) { String namePrefix = clazz . getName ( ) ; int dotIndex = namePrefix . lastIndexOf ( '.' ) ; if ( dotIndex > 0 ) namePrefix = namePrefix . substring ( dotIndex + 1 ) ; NameGenerator nameGenerator = getNameGenerator ( namePrefix ) ; return nameGenerator . next ( ) ; }
Generates a new unique control ID for an instance of the target class
9,589
public ControlBean getBean ( String id ) { int delim = id . indexOf ( org . apache . beehive . controls . api . bean . ControlBean . IDSeparator ) ; if ( delim < 0 ) return ( ControlBean ) _childMap . get ( id ) ; ControlBean bean = ( ControlBean ) _childMap . get ( id . substring ( 0 , delim ) ) ; if ( bean == null ) return bean ; return bean . getBeanContextProxy ( ) . getBean ( id . substring ( delim + 1 ) ) ; }
Returns a ControlBean instance nested the current BeanContext .
9,590
protected PropertyMap getBeanAnnotationMap ( ControlBean bean , AnnotatedElement annotElem ) { PropertyMap map = new AnnotatedElementMap ( annotElem ) ; if ( bean != null ) setDelegateMap ( map , bean , annotElem ) ; return map ; }
The default implementation of getBeanAnnotationMap . This returns a map based purely upon annotation reflection
9,591
public int doEndTag ( ) throws JspException { HttpServletRequest request = ( HttpServletRequest ) pageContext . getRequest ( ) ; HttpServletResponse response = ( HttpServletResponse ) pageContext . getResponse ( ) ; ServletContext context = pageContext . getServletContext ( ) ; try { boolean encoded = false ; UrlConfig urlConfig = ConfigUtil . getConfig ( ) . getUrlConfig ( ) ; if ( urlConfig != null ) { encoded = ! urlConfig . isUrlEncodeUrls ( ) ; } FreezableMutableURI uri = new FreezableMutableURI ( ) ; uri . setEncoding ( response . getCharacterEncoding ( ) ) ; uri . setURI ( url , encoded ) ; boolean needsToBeSecure = false ; if ( _params != null ) { uri . addParameters ( _params , false ) ; } if ( ! uri . isAbsolute ( ) && PageFlowUtils . needsToBeSecure ( context , request , url , true ) ) { needsToBeSecure = true ; } URLRewriterService . rewriteURL ( context , request , response , uri , URLType . ACTION , needsToBeSecure ) ; String key = PageFlowUtils . getURLTemplateKey ( URLType . ACTION , needsToBeSecure ) ; boolean forXML = TagRenderingBase . Factory . isXHTML ( request ) ; URIContext uriContext = URIContextFactory . getInstance ( forXML ) ; String uriString = URLRewriterService . getTemplatedURL ( context , request , uri , key , uriContext ) ; write ( response . encodeURL ( uriString ) ) ; } catch ( URISyntaxException e ) { String s = Bundle . getString ( "Tags_RewriteURL_URLException" , new Object [ ] { url , e . getMessage ( ) } ) ; registerTagError ( s , e ) ; reportErrors ( ) ; } localRelease ( ) ; return EVAL_PAGE ; }
Render the end of the rewriteURL tag .
9,592
private List getFormBeanNames ( TypeDeclaration beanType ) { List formBeans = _strutsApp . getMatchingFormBeans ( beanType , null ) ; List formBeanNames = new ArrayList ( ) ; for ( Iterator i = formBeans . iterator ( ) ; i . hasNext ( ) ; ) { FormBeanModel formBeanModel = ( FormBeanModel ) i . next ( ) ; formBeanNames . add ( formBeanModel . getName ( ) ) ; } return formBeanNames ; }
Returns a list of String names .
9,593
private void addFieldRules ( AnnotationInstance rulesContainerAnnotation , RuleInfo ruleInfo , boolean applyToAllLocales ) { Locale locale = null ; if ( ! applyToAllLocales ) { String language = CompilerUtils . getString ( rulesContainerAnnotation , LANGUAGE_ATTR , true ) ; if ( language != null ) { String country = CompilerUtils . getString ( rulesContainerAnnotation , COUNTRY_ATTR , true ) ; String variant = CompilerUtils . getString ( rulesContainerAnnotation , VARIANT_ATTR , true ) ; language = language . trim ( ) ; if ( country != null ) country = country . trim ( ) ; if ( variant != null ) variant = variant . trim ( ) ; if ( country != null && variant != null ) locale = new Locale ( language , country , variant ) ; else if ( country != null ) locale = new Locale ( language , country ) ; else locale = new Locale ( language ) ; } } Map valuesPresent = rulesContainerAnnotation . getElementValues ( ) ; for ( Iterator ii = valuesPresent . entrySet ( ) . iterator ( ) ; ii . hasNext ( ) ; ) { Map . Entry entry = ( Map . Entry ) ii . next ( ) ; AnnotationValue value = ( AnnotationValue ) entry . getValue ( ) ; Object val = value . getValue ( ) ; if ( val instanceof AnnotationInstance ) { addFieldRuleFromAnnotation ( ruleInfo , ( AnnotationInstance ) val , locale , applyToAllLocales ) ; } else if ( val instanceof List ) { List annotations = CompilerUtils . getAnnotationArray ( value ) ; for ( Iterator i3 = annotations . iterator ( ) ; i3 . hasNext ( ) ; ) { AnnotationInstance i = ( AnnotationInstance ) i3 . next ( ) ; addFieldRuleFromAnnotation ( ruleInfo , i , locale , applyToAllLocales ) ; } } } setEmpty ( false ) ; }
Add field rules from either a Jpf . ValidationField or a Jpf . ValidationLocaleRules annotation .
9,594
private final String prefix ( String style ) { InternalStringBuilder sb = new InternalStringBuilder ( 16 ) ; sb . append ( _stylePrefix ) ; if ( style != null ) { sb . append ( DELIM ) ; sb . append ( style ) ; } return sb . toString ( ) ; }
Utility method to concatenate the given style class name and the style prefix .
9,595
public void setDispatchMode ( DispatchMode argMode ) { if ( argMode == null ) { argMode = DispatchMode . SINGLE_THREAD ; } if ( argMode == DispatchMode . SINGLE_THREAD ) { startBackgroundThread ( ) ; } mode = argMode ; }
Sets the dispatch mode
9,596
public synchronized void makeCustomRequest ( AnalyticsRequestData argData ) { if ( ! enabled ) { logger . debug ( "Ignoring tracking request, enabled is false" ) ; return ; } if ( argData == null ) { throw new NullPointerException ( "Data cannot be null" ) ; } if ( builder == null ) { throw new NullPointerException ( "Class was not initialized" ) ; } final String url = builder . buildURL ( argData ) ; switch ( mode ) { case MULTI_THREAD : Thread t = new Thread ( asyncThreadGroup , "AnalyticsThread-" + asyncThreadGroup . activeCount ( ) ) { public void run ( ) { synchronized ( JGoogleAnalyticsTracker . class ) { asyncThreadsRunning ++ ; } try { dispatchRequest ( url ) ; } finally { synchronized ( JGoogleAnalyticsTracker . class ) { asyncThreadsRunning -- ; } } } } ; t . setDaemon ( true ) ; t . start ( ) ; break ; case SYNCHRONOUS : dispatchRequest ( url ) ; break ; default : synchronized ( fifo ) { fifo . addLast ( url ) ; fifo . notify ( ) ; } if ( ! backgroundThreadMayRun ) { logger . error ( "A tracker request has been added to the queue but the background thread isn't running." , url ) ; } break ; } }
Makes a custom tracking request based from the given data .
9,597
private synchronized static void startBackgroundThread ( ) { if ( backgroundThread == null ) { backgroundThreadMayRun = true ; backgroundThread = new Thread ( asyncThreadGroup , "AnalyticsBackgroundThread" ) { public void run ( ) { logger . debug ( "AnalyticsBackgroundThread started" ) ; while ( backgroundThreadMayRun ) { try { String url = null ; synchronized ( fifo ) { if ( fifo . isEmpty ( ) ) { fifo . wait ( ) ; } if ( ! fifo . isEmpty ( ) ) { url = fifo . getFirst ( ) ; } } if ( url != null ) { try { dispatchRequest ( url ) ; } finally { synchronized ( fifo ) { fifo . removeFirst ( ) ; } } } } catch ( Exception e ) { logger . error ( "Got exception from dispatch thread" , e ) ; } } } } ; backgroundThread . setDaemon ( true ) ; backgroundThread . start ( ) ; } }
If the background thread for queued mode is not running start it now .
9,598
public void lock ( ) { boolean wasInterrupted = false ; while ( true ) { try { impl . lockInterruptibly ( ) ; if ( wasInterrupted ) { Thread . currentThread ( ) . interrupt ( ) ; } return ; } catch ( InterruptedException e ) { wasInterrupted = true ; } } }
Acquires the lock .
9,599
public void setContext ( AdapterContext context ) { Object servletContext = context . getExternalContext ( ) ; assert servletContext instanceof ServletContext : servletContext ; _servletContext = ( ServletContext ) servletContext ; _eventReporter = createEventReporter ( ) ; }
Set the AdapterContext .