idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
9,800 | public static void validate ( Declaration d ) throws IllegalArgumentException { Collection < AnnotationMirror > mirrors = d . getAnnotationMirrors ( ) ; for ( AnnotationMirror m : mirrors ) { AnnotationTypeDeclaration decl = m . getAnnotationType ( ) . getDeclaration ( ) ; if ( decl == null ) { continue ; } else if ( decl . getAnnotation ( PropertySet . class ) != null ) { Iterator < Map . Entry < AnnotationTypeElementDeclaration , AnnotationValue > > i = m . getElementValues ( ) . entrySet ( ) . iterator ( ) ; while ( i . hasNext ( ) ) { Map . Entry < AnnotationTypeElementDeclaration , AnnotationValue > entry = i . next ( ) ; Collection < Annotation > annotations = getMemberTypeAnnotations ( entry . getKey ( ) ) ; if ( annotations . size ( ) > 0 ) { Annotation [ ] anArray = new Annotation [ annotations . size ( ) ] ; annotations . toArray ( anArray ) ; validate ( anArray , entry . getValue ( ) . getValue ( ) ) ; } } if ( decl . getAnnotation ( MembershipRule . class ) != null ) { try { String declClassName = decl . getQualifiedName ( ) ; TypeDeclaration owningClass = decl . getDeclaringType ( ) ; if ( owningClass != null ) declClassName = owningClass . getQualifiedName ( ) + "$" + decl . getSimpleName ( ) ; Class clazz = Class . forName ( declClassName ) ; Annotation a = d . getAnnotation ( clazz ) ; validateMembership ( a ) ; } catch ( ClassNotFoundException cnfe ) { } } } } if ( d instanceof TypeDeclaration ) { TypeDeclaration td = ( ( TypeDeclaration ) d ) ; for ( Declaration md : td . getMethods ( ) ) validate ( md ) ; for ( Declaration fd : td . getFields ( ) ) validate ( fd ) ; } else if ( d instanceof MethodDeclaration ) { for ( Declaration pd : ( ( MethodDeclaration ) d ) . getParameters ( ) ) validate ( pd ) ; } } | This method ensures that any control property value assignment satisfies all property constraints . This method should be called from an annotation processor to ensure declarative control property assignment using annotations are validated at build time . This method is currently called from ControlAnnotationProcessor and ControlClientAnnotationProcessor . |
9,801 | public AptEventSet initSuperEventSet ( ) { AptControlInterface superControl = _controlIntf . getSuperClass ( ) ; if ( superControl == null ) return null ; HashSet < String > extendNames = new HashSet < String > ( ) ; for ( InterfaceType superType : _eventSet . getSuperinterfaces ( ) ) { InterfaceDeclaration superDecl = superType . getDeclaration ( ) ; if ( superDecl != null ) extendNames . add ( superDecl . getQualifiedName ( ) ) ; } while ( superControl != null ) { Collection < AptEventSet > superEventSets = superControl . getEventSets ( ) ; for ( AptEventSet superEventSet : superEventSets ) { if ( extendNames . contains ( superEventSet . getClassName ( ) ) ) return superEventSet ; } superControl = superControl . getSuperClass ( ) ; } return null ; } | Checks to see if this EventSet extends an EventSet declared on a parent control interface . If found it will return the parent EventSet or return null if not found . |
9,802 | protected AptMethodSet < AptEvent > initEvents ( ) { AptMethodSet < AptEvent > events = new AptMethodSet < AptEvent > ( ) ; if ( _eventSet == null || _eventSet . getMethods ( ) == null ) return events ; ArrayList < InterfaceDeclaration > intfList = new ArrayList < InterfaceDeclaration > ( ) ; intfList . add ( _eventSet ) ; for ( int i = 0 ; i < intfList . size ( ) ; i ++ ) { InterfaceDeclaration intfDecl = intfList . get ( i ) ; if ( _superEventSet != null && _superEventSet . getClassName ( ) . equals ( intfDecl . getQualifiedName ( ) ) ) continue ; for ( MethodDeclaration methodDecl : intfDecl . getMethods ( ) ) if ( ! methodDecl . toString ( ) . equals ( "<clinit>()" ) ) events . add ( new AptEvent ( this , methodDecl , _ap ) ) ; for ( InterfaceType superType : intfDecl . getSuperinterfaces ( ) ) { InterfaceDeclaration superDecl = superType . getDeclaration ( ) ; if ( superDecl != null && ! intfList . contains ( superDecl ) ) intfList . add ( superDecl ) ; } } return events ; } | Initializes the list of Events associated with this EventSet |
9,803 | public int getEventCount ( ) { int count = _events . size ( ) ; if ( _superEventSet != null ) count += _superEventSet . getEventCount ( ) ; return count ; } | Returns the number of Events for this EventSet and any super event set |
9,804 | public String getDescriptorName ( ) { String name = getShortName ( ) ; return Character . toLowerCase ( name . charAt ( 0 ) ) + name . substring ( 1 ) ; } | Returns the programmatic descriptor name to be returned by the EventDescriptor for the event set . |
9,805 | public String getNotifierClass ( ) { StringBuffer sb = new StringBuffer ( getShortName ( ) ) ; sb . append ( "Notifier" ) ; sb . append ( getFormalTypeParameterNames ( ) ) ; return sb . toString ( ) ; } | Returns the name of the generated notifier class for this ControlEventSet |
9,806 | private AptMethodSet < AptOperation > initOperations ( ) { AptMethodSet < AptOperation > operList = new AptMethodSet < AptOperation > ( ) ; if ( _intfDecl == null ) return operList ; Vector < InterfaceDeclaration > checkIntfs = new Vector < InterfaceDeclaration > ( ) ; checkIntfs . add ( _intfDecl ) ; for ( int i = 0 ; i < checkIntfs . size ( ) ; i ++ ) { InterfaceDeclaration intfDecl = checkIntfs . elementAt ( i ) ; if ( intfDecl . equals ( _superDecl ) ) continue ; if ( intfDecl . getMethods ( ) == null ) continue ; for ( MethodDeclaration methodDecl : intfDecl . getMethods ( ) ) if ( ! methodDecl . toString ( ) . equals ( "<clinit>()" ) ) operList . add ( new AptOperation ( this , methodDecl , _ap ) ) ; if ( intfDecl . getSuperinterfaces ( ) == null ) continue ; for ( InterfaceType superType : intfDecl . getSuperinterfaces ( ) ) { InterfaceDeclaration superDecl = superType . getDeclaration ( ) ; if ( superDecl != null && ! checkIntfs . contains ( superDecl ) ) checkIntfs . add ( superDecl ) ; } } return operList ; } | Initializes the list of operations declared by this AptControlInterface |
9,807 | private ArrayList < AptPropertySet > initPropertySets ( ) { ArrayList < AptPropertySet > propSets = new ArrayList < AptPropertySet > ( ) ; if ( _intfDecl == null ) return propSets ; TypeDeclaration basePropsDecl = _ap . getAnnotationProcessorEnvironment ( ) . getTypeDeclaration ( "org.apache.beehive.controls.api.properties.BaseProperties" ) ; if ( basePropsDecl != null ) { propSets . add ( new AptPropertySet ( null , basePropsDecl , _ap ) ) ; } ExternalPropertySets extPropsAnnotation = _intfDecl . getAnnotation ( ExternalPropertySets . class ) ; if ( extPropsAnnotation != null ) { if ( isExtension ( ) ) { _ap . printError ( _intfDecl , "extpropertyset.illegal.usage" ) ; } try { Class [ ] extProps = extPropsAnnotation . value ( ) ; } catch ( MirroredTypesException mte ) { Collection < String > extProps = mte . getQualifiedNames ( ) ; for ( String extPropName : extProps ) { TypeDeclaration extPropDecl = _ap . getAnnotationProcessorEnvironment ( ) . getTypeDeclaration ( extPropName ) ; if ( extPropDecl != null ) { AptPropertySet extPropSet = new AptPropertySet ( null , extPropDecl , _ap ) ; propSets . add ( extPropSet ) ; } else { _ap . printError ( _intfDecl , "extpropertyset.type.not.found" , extPropName ) ; } } } } if ( _intfDecl . getNestedTypes ( ) == null ) return propSets ; for ( TypeDeclaration innerDecl : _intfDecl . getNestedTypes ( ) ) { boolean fError = false ; if ( innerDecl . getAnnotation ( PropertySet . class ) != null ) { if ( ! ( innerDecl instanceof AnnotationTypeDeclaration ) ) { _ap . printError ( innerDecl , "propertyset.not.annotation.type" ) ; fError = true ; } Retention ret = innerDecl . getAnnotation ( Retention . class ) ; if ( ret == null || ret . value ( ) != RetentionPolicy . RUNTIME ) { _ap . printError ( innerDecl , "propertyset.missing.retention" ) ; fError = true ; } if ( isExtension ( ) ) { _ap . printError ( innerDecl , "propertyset.illegal.usage.2" ) ; fError = true ; } if ( ! fError ) propSets . add ( new AptPropertySet ( this , ( AnnotationTypeDeclaration ) innerDecl , _ap ) ) ; } } Set < String > propertyNames = new HashSet < String > ( ) ; for ( AptPropertySet propSet : propSets ) { for ( AptProperty prop : propSet . getProperties ( ) ) { if ( prop . isBound ( ) ) _hasBoundProperties = true ; if ( prop . isConstrained ( ) ) _hasConstrainedProperties = true ; String propName = prop . getAccessorName ( ) ; if ( propertyNames . contains ( propName ) ) { _ap . printError ( _intfDecl , "propertyset.duplicate.property.names" , propName , propSet . getShortName ( ) ) ; } else { propertyNames . add ( propName ) ; } } } return propSets ; } | Initializes the list of PropertySets declared or referenced by this AptControlInterface |
9,808 | public int getPropertyCount ( ) { int count ; if ( _superClass == null ) count = 0 ; else count = _superClass . getPropertyCount ( ) ; for ( AptPropertySet propertySet : _propertySets ) { if ( propertySet . hasSetters ( ) || ! propertySet . isOptional ( ) ) { count += propertySet . getProperties ( ) . size ( ) ; } } count += _intfProps . size ( ) ; return count ; } | Returns the total number of properties for this control interface |
9,809 | private ArrayList < AptEventSet > initEventSets ( ) { ArrayList < AptEventSet > eventSets = new ArrayList < AptEventSet > ( ) ; if ( _intfDecl == null || _intfDecl . getNestedTypes ( ) == null ) return eventSets ; for ( TypeDeclaration innerDecl : _intfDecl . getNestedTypes ( ) ) { if ( ! ( innerDecl instanceof InterfaceDeclaration ) ) continue ; if ( innerDecl . getAnnotation ( EventSet . class ) != null ) { if ( ! ( innerDecl instanceof InterfaceDeclaration ) ) { _ap . printError ( innerDecl , "eventset.illegal.usage" ) ; } else { eventSets . add ( new AptEventSet ( this , ( InterfaceDeclaration ) innerDecl , _ap ) ) ; } } } return eventSets ; } | Initializes the list of EventSets declared by this AptControlInterface |
9,810 | public AptEventSet getEventSet ( String name ) { for ( AptEventSet eventSet : getEventSets ( ) ) if ( eventSet . getClassName ( ) . equals ( name ) ) return eventSet ; if ( _superClass != null ) return _superClass . getEventSet ( name ) ; return null ; } | Returns the AptEventSet with the specified name |
9,811 | public List < GeneratorOutput > getCheckOutput ( Filer filer ) throws IOException { HashMap < String , Object > map = new HashMap < String , Object > ( ) ; map . put ( "intf" , this ) ; map . put ( "bean" , _bean ) ; ArrayList < GeneratorOutput > genList = new ArrayList < GeneratorOutput > ( ) ; Writer beanWriter = new IndentingWriter ( filer . createSourceFile ( _bean . getClassName ( ) ) ) ; GeneratorOutput beanSource = new GeneratorOutput ( beanWriter , "org/apache/beehive/controls/runtime/generator/ControlBean.vm" , map ) ; genList . add ( beanSource ) ; Writer beanInfoWriter = new IndentingWriter ( filer . createSourceFile ( _bean . getBeanInfoName ( ) ) ) ; GeneratorOutput beanInfoSource = new GeneratorOutput ( beanInfoWriter , "org/apache/beehive/controls/runtime/generator/ControlBeanInfo.vm" , map ) ; genList . add ( beanInfoSource ) ; return genList ; } | Returns the information necessary to generate a ControlBean from this AptControlInterface |
9,812 | public List < GeneratorOutput > getGenerateOutput ( Filer filer ) throws IOException { HashMap < String , Object > map = new HashMap < String , Object > ( ) ; map . put ( "intf" , this ) ; map . put ( "bean" , _bean ) ; ArrayList < GeneratorOutput > genList = new ArrayList < GeneratorOutput > ( ) ; Writer manifestWriter = filer . createTextFile ( Filer . Location . CLASS_TREE , _bean . getPackage ( ) , new File ( _bean . getShortName ( ) + ".class.manifest" ) , null ) ; GeneratorOutput beanManifest = new GeneratorOutput ( manifestWriter , "org/apache/beehive/controls/runtime/generator/ControlManifest.vm" , map ) ; genList . add ( beanManifest ) ; return genList ; } | Returns the information necessary to generate a packaging information from this AptControlInterface . Since this information is not needed during type validation it can be delated until the generate phase . |
9,813 | public AptControlInterface getMostDerivedInterface ( ) { AptControlInterface ancestor = getSuperClass ( ) ; while ( ancestor != null ) { if ( ! ancestor . isExtension ( ) ) break ; ancestor = ancestor . getSuperClass ( ) ; } return ancestor ; } | Returns the most - derived interface in the inheritance chain that is annotated with |
9,814 | public ClassLoader getExternalClassLoader ( ) { Map < String , String > opts = _ap . getAnnotationProcessorEnvironment ( ) . getOptions ( ) ; String classpath = opts . get ( "-classpath" ) ; if ( classpath != null ) { String [ ] cpEntries = classpath . split ( File . pathSeparator ) ; ArrayList a = new ArrayList ( ) ; for ( String e : cpEntries ) { try { File f = ( new File ( e ) ) . getCanonicalFile ( ) ; URL u = f . toURL ( ) ; a . add ( u ) ; } catch ( Exception ex ) { System . err . println ( "getExternalClassLoader(): bad cp entry=" + e ) ; System . err . println ( "Exception processing e=" + ex ) ; } } URL [ ] urls = new URL [ a . size ( ) ] ; urls = ( URL [ ] ) a . toArray ( urls ) ; return new URLClassLoader ( urls , ControlChecker . class . getClassLoader ( ) ) ; } return null ; } | Returns a classloader that can be used to load external classes |
9,815 | private boolean isValidManifestAttribute ( ManifestAttribute attr ) { String name = attr . name ( ) ; String value = attr . value ( ) ; boolean isValid = true ; if ( name == null || name . length ( ) == 0 ) { _ap . printError ( _intfDecl , "manifestattribute.illegal.name.1" ) ; isValid = false ; } else { if ( alphaNum . indexOf ( name . charAt ( 0 ) ) < 0 ) { _ap . printError ( _intfDecl , "manifestattribute.illegal.name.2" ) ; isValid = false ; } for ( int i = 1 ; i < name . length ( ) ; i ++ ) { if ( headerChar . indexOf ( name . charAt ( i ) ) < 0 ) { _ap . printError ( _intfDecl , "manifestattribute.illegal.name.3" , name . charAt ( i ) ) ; isValid = false ; break ; } } } if ( value == null || value . length ( ) == 0 ) { _ap . printError ( _intfDecl , "manifestattribute.illegal.name.4" ) ; isValid = false ; } else { } return isValid ; } | Validates a manifest attribute . If the attribute is invalid it will generate appropriate APT messager entries and return false else return true . |
9,816 | public HashMap < String , String > getManifestAttributes ( ) { HashMap < String , String > attributes = new HashMap < String , String > ( ) ; if ( _intfDecl == null ) return attributes ; try { ManifestAttributes annotAttrs = _intfDecl . getAnnotation ( ManifestAttributes . class ) ; if ( annotAttrs != null ) { ManifestAttribute [ ] attrs = ( ManifestAttribute [ ] ) annotAttrs . value ( ) ; for ( int i = 0 ; i < attrs . length ; i ++ ) { if ( isValidManifestAttribute ( attrs [ i ] ) ) attributes . put ( attrs [ i ] . name ( ) , attrs [ i ] . value ( ) ) ; } } ManifestAttribute annotAttr = _intfDecl . getAnnotation ( ManifestAttribute . class ) ; if ( annotAttr != null ) { if ( isValidManifestAttribute ( annotAttr ) ) attributes . put ( annotAttr . name ( ) , annotAttr . value ( ) ) ; } return attributes ; } catch ( Exception e ) { e . printStackTrace ( ) ; return attributes ; } } | Returns the array of ManifestAttributes associated with the AptControlInterface |
9,817 | private String getIntfPropertyName ( AptMethod method ) { String opName = method . getName ( ) ; int prefixIdx = 3 ; if ( opName . startsWith ( "is" ) ) prefixIdx = 2 ; if ( opName . length ( ) == prefixIdx + 1 ) return "" + Character . toLowerCase ( opName . charAt ( prefixIdx ) ) ; return Character . toLowerCase ( opName . charAt ( prefixIdx ) ) + opName . substring ( prefixIdx + 1 ) ; } | Generate a property name from a method name . |
9,818 | protected int renderEndTag ( int state ) throws JspException { if ( _padText == null && bodyContent != null ) { _padText = bodyContent . getString ( ) ; } if ( hasErrors ( ) ) { reportErrors ( ) ; localRelease ( ) ; return EVAL_PAGE ; } PadContext pc = new PadContext ( _padText , ( _minRepeat != null ? _minRepeat . intValue ( ) : PadContext . DEFAULT_VALUE ) , ( _maxRepeat != null ? _maxRepeat . intValue ( ) : PadContext . DEFAULT_VALUE ) ) ; getRepeater ( ) . setPadContext ( pc ) ; return EVAL_PAGE ; } | Complete rendering the body of this tag . If the padText property was unset the body of the tag is used as the pad text . |
9,819 | public synchronized JSONArray loadPage ( int i ) { if ( pages == null || pages . get ( i ) == null ) { String url ; if ( path . contains ( "?" ) ) { url = path + "&" ; } else { url = path + "?" ; } JSONObject result = client . get ( url + "per_page=" + perPage + "&page=" + i ) ; if ( result != null && result . names ( ) . size ( ) == 2 && ! result . getJSONObject ( "response_data" ) . isNullObject ( ) ) { responseData = result . getJSONObject ( "response_data" ) ; for ( Object name : result . names ( ) ) { if ( ! "response_data" . equals ( name ) ) { pages . put ( i , result . getJSONArray ( name . toString ( ) ) ) ; } } pages . put ( i , pages . get ( i ) ) ; } else { throw new NotFound ( "The resource you requested is not a collection." ) ; } } return pages . get ( i ) ; } | Requests i th page from UserVoice . Thread - safe and makes one HTTP connection . |
9,820 | public static String formatDuration ( long millis ) { StringBuilder sb = new StringBuilder ( ) ; if ( millis > DAY_MILLIS ) { sb . append ( millis / DAY_MILLIS ) ; sb . append ( " days, " ) ; millis %= DAY_MILLIS ; } if ( millis > HOUR_MILLIS ) { sb . append ( millis / HOUR_MILLIS ) ; sb . append ( " hours, " ) ; millis %= HOUR_MILLIS ; } if ( millis > MINUTE_MILLIS ) { sb . append ( millis / MINUTE_MILLIS ) ; sb . append ( " minutes, " ) ; millis %= MINUTE_MILLIS ; } if ( millis > SECOND_MILLIS ) { sb . append ( millis / SECOND_MILLIS ) ; sb . append ( " seconds, " ) ; millis %= SECOND_MILLIS ; } sb . append ( millis ) ; sb . append ( " milliseconds" ) ; return sb . toString ( ) ; } | Formats a duration in milliseconds as a pretty - print string . |
9,821 | public List < XLog > parse ( InputStream is ) throws Exception { BufferedInputStream bis = new BufferedInputStream ( is ) ; MxmlHandler handler = new MxmlHandler ( ) ; SAXParserFactory parserFactory = SAXParserFactory . newInstance ( ) ; SAXParser parser = parserFactory . newSAXParser ( ) ; parser . parse ( bis , handler ) ; bis . close ( ) ; return handler . getLogs ( ) ; } | Parses a set of logs from the given input stream which is supposed to deliver an MXML serialization . |
9,822 | synchronized public void removeListener ( Object listener ) { if ( ! _listeners . contains ( listener ) ) throw new IllegalStateException ( "Invalid listener, not currently registered" ) ; _listeners . remove ( listener ) ; } | Remove an existing callback event listener for this EventNotifier |
9,823 | protected void firePropertyChange ( String name , Object oldValue , Object newValue ) { _propertyChangeSupport . firePropertyChange ( name , oldValue , newValue ) ; } | Fire a property change event . |
9,824 | SqlFragment [ ] getChildren ( ) { SqlFragment [ ] fragments = new SqlFragment [ _children . size ( ) ] ; return _children . toArray ( fragments ) ; } | Return the array of children . |
9,825 | String getPreparedStatementText ( ControlBeanContext context , Method m , Object [ ] args ) { StringBuilder sb = new StringBuilder ( ) ; for ( SqlFragment sf : _children ) { sb . append ( sf . getPreparedStatementText ( context , m , args ) ) ; } return sb . toString ( ) ; } | builds the text of the prepared statement |
9,826 | public int doEndTag ( ) throws JspException { ServletRequest req = pageContext . getRequest ( ) ; String scriptId = null ; if ( hasErrors ( ) ) return reportAndExit ( EVAL_PAGE ) ; String uri = null ; if ( _state . src != null ) { try { uri = PageFlowTagUtils . rewriteResourceURL ( pageContext , _state . src , _params , _location ) ; } catch ( URISyntaxException e ) { String s = Bundle . getString ( "Tags_Image_URLException" , new Object [ ] { _state . src , e . getMessage ( ) } ) ; registerTagError ( s , e ) ; } } if ( uri != null ) { _state . src = ( ( HttpServletResponse ) pageContext . getResponse ( ) ) . encodeURL ( uri ) ; } if ( _state . id != null ) { scriptId = renderNameAndId ( ( HttpServletRequest ) req , _state , null ) ; } WriteRenderAppender writer = new WriteRenderAppender ( pageContext ) ; TagRenderingBase br = TagRenderingBase . Factory . getRendering ( TagRenderingBase . IMAGE_TAG , req ) ; br . doStartTag ( writer , _state ) ; br . doEndTag ( writer ) ; if ( scriptId != null ) write ( scriptId ) ; localRelease ( ) ; return EVAL_PAGE ; } | Render the end of the IMG tag . |
9,827 | private static void continueChainNoWrapper ( ServletRequest request , ServletResponse response , FilterChain chain ) throws IOException , ServletException { if ( request instanceof PageFlowRequestWrapper ) request = ( ( PageFlowRequestWrapper ) request ) . getHttpRequest ( ) ; chain . doFilter ( request , response ) ; } | Internal method used to handle cases where the filter should continue without processing the request by rendering a page associated with a page flow . |
9,828 | public void setStyle ( String style ) { if ( "" . equals ( style ) ) return ; AbstractHtmlState tsh = getState ( ) ; tsh . style = style ; } | Sets the style of the rendered html tag . |
9,829 | public void setStyleClass ( String styleClass ) { if ( "" . equals ( styleClass ) ) return ; AbstractHtmlState tsh = getState ( ) ; tsh . styleClass = styleClass ; } | Sets the style class of the rendered html tag . |
9,830 | public void setTitle ( String title ) { AbstractHtmlState tsh = getState ( ) ; tsh . registerAttribute ( AbstractHtmlState . ATTR_GENERAL , TITLE , title ) ; } | Sets the value of the title attribute . |
9,831 | public void setLang ( String lang ) { AbstractHtmlState tsh = getState ( ) ; tsh . registerAttribute ( AbstractHtmlState . ATTR_GENERAL , LANG , lang ) ; } | Sets the lang attribute for the HTML element . |
9,832 | public void setDir ( String dir ) { AbstractHtmlState tsh = getState ( ) ; tsh . registerAttribute ( AbstractHtmlState . ATTR_GENERAL , DIR , dir ) ; } | Sets the dir attribute for the HTML element . |
9,833 | public String getOnClick ( ) { AbstractHtmlState tsh = getState ( ) ; return tsh . getAttribute ( AbstractHtmlState . ATTR_JAVASCRIPT , ONCLICK ) ; } | Gets the onClick javascript event . |
9,834 | public void setOnDblClick ( String ondblclick ) { AbstractHtmlState tsh = getState ( ) ; tsh . registerAttribute ( AbstractHtmlState . ATTR_JAVASCRIPT , ONDBLCLICK , ondblclick ) ; } | Sets the onDblClick javascript event . |
9,835 | public void setOnKeyDown ( String onkeydown ) { AbstractHtmlState tsh = getState ( ) ; tsh . registerAttribute ( AbstractHtmlState . ATTR_JAVASCRIPT , ONKEYDOWN , onkeydown ) ; } | Sets the onKeyDown javascript event . |
9,836 | public void setOnKeyPress ( String onkeypress ) { AbstractHtmlState tsh = getState ( ) ; tsh . registerAttribute ( AbstractHtmlState . ATTR_JAVASCRIPT , ONKEYPRESS , onkeypress ) ; } | Sets the onKeyPress javascript event . |
9,837 | public void setOnKeyUp ( String onkeyup ) { AbstractHtmlState tsh = getState ( ) ; tsh . registerAttribute ( AbstractHtmlState . ATTR_JAVASCRIPT , ONKEYUP , onkeyup ) ; } | Sets the onKeyUp javascript event . |
9,838 | public void setOnMouseDown ( String onmousedown ) { AbstractHtmlState tsh = getState ( ) ; tsh . registerAttribute ( AbstractHtmlState . ATTR_JAVASCRIPT , ONMOUSEDOWN , onmousedown ) ; } | Sets the onMouseDown javascript event . |
9,839 | public void setOnMouseMove ( String onmousemove ) { AbstractHtmlState tsh = getState ( ) ; tsh . registerAttribute ( AbstractHtmlState . ATTR_JAVASCRIPT , ONMOUSEMOVE , onmousemove ) ; } | Sets the onMouseMove javascript event . |
9,840 | public void setOnMouseOut ( String onmouseout ) { AbstractHtmlState tsh = getState ( ) ; tsh . registerAttribute ( AbstractHtmlState . ATTR_JAVASCRIPT , ONMOUSEOUT , onmouseout ) ; } | Sets the onMouseOut javascript event . |
9,841 | public void setOnMouseOver ( String onmouseover ) { AbstractHtmlState tsh = getState ( ) ; tsh . registerAttribute ( AbstractHtmlState . ATTR_JAVASCRIPT , ONMOUSEOVER , onmouseover ) ; } | Sets the onMouseOver javascript event . |
9,842 | public void setOnMouseUp ( String onmouseup ) { AbstractHtmlState tsh = getState ( ) ; tsh . registerAttribute ( AbstractHtmlState . ATTR_JAVASCRIPT , ONMOUSEUP , onmouseup ) ; } | Sets the onMouseUp javascript event . |
9,843 | protected void setStateAttribute ( String name , String value , AbstractHtmlState tsh ) throws JspException { boolean error = false ; if ( name == null || name . length ( ) <= 0 ) { String s = Bundle . getString ( "Tags_AttributeNameNotSet" ) ; registerTagError ( s , null ) ; error = true ; } if ( name != null && ( name . equals ( ID ) || name . equals ( NAME ) ) ) { String s = Bundle . getString ( "Tags_AttributeMayNotBeSet" , new Object [ ] { name } ) ; registerTagError ( s , null ) ; } if ( error ) return ; if ( name . equals ( CLASS ) ) { tsh . styleClass = value ; return ; } else if ( name . equals ( STYLE ) ) { tsh . style = value ; return ; } tsh . registerAttribute ( AbstractHtmlState . ATTR_GENERAL , name , value ) ; } | Attribute implementation . |
9,844 | public static Logger getInstance ( Class loggerClient ) { return new Logger ( org . apache . commons . logging . LogFactory . getLog ( loggerClient . getName ( ) ) ) ; } | Factory method for creating NetUI Logger instances . |
9,845 | public void addCommand ( Command command ) { if ( command == null ) throw new IllegalArgumentException ( ) ; if ( _frozen ) throw new IllegalStateException ( ) ; Command [ ] results = new Command [ _commands . length + 1 ] ; System . arraycopy ( _commands , 0 , results , 0 , _commands . length ) ; results [ _commands . length ] = command ; _commands = results ; } | Add a command to the chian . |
9,846 | public final String rewriteName ( String name , Tag currentTag ) throws ExpressionEvaluationException { if ( _logger . isDebugEnabled ( ) ) _logger . debug ( "rewrite expression \"" + name + "\"" ) ; IDataAccessProvider dap = getCurrentProvider ( currentTag ) ; if ( dap == null ) return name ; Expression parsed = getExpressionEvaluator ( ) . parseExpression ( name ) ; assert parsed != null ; int containerCount = 0 ; List tokens = parsed . getTokens ( ) ; for ( int i = 0 ; i < tokens . size ( ) ; i ++ ) { String tok = tokens . get ( i ) . toString ( ) ; if ( i == 0 ) { if ( ! tok . equals ( "container" ) ) break ; else continue ; } else if ( tok . equals ( "container" ) ) containerCount ++ ; else if ( tok . equals ( "item" ) ) break ; } if ( _logger . isDebugEnabled ( ) ) _logger . debug ( "container parent count: " + containerCount ) ; for ( int i = 0 ; i < containerCount ; i ++ ) { dap = dap . getProviderParent ( ) ; } assert dap != null ; if ( containerCount > 0 ) { name = parsed . getExpression ( containerCount ) ; } String parentNames = rewriteNameInternal ( dap ) ; if ( _logger . isDebugEnabled ( ) ) _logger . debug ( "name hierarchy: " + parentNames + " name: " + name ) ; String newName = changeContext ( name , "container.item" , parentNames , dap . getCurrentIndex ( ) ) ; if ( _logger . isDebugEnabled ( ) ) _logger . debug ( "rewrittenName: " + newName ) ; return newName ; } | Rewrite an expression into a fully - qualified reference to a specific JavaBean property on an object . |
9,847 | private final String rewriteNameInternal ( IDataAccessProvider dap ) throws ExpressionEvaluationException { if ( _logger . isDebugEnabled ( ) ) _logger . debug ( "assign index to name: " + dap . getDataSource ( ) ) ; Expression parsedDataSource = getExpressionEvaluator ( ) . parseExpression ( dap . getDataSource ( ) ) ; assert parsedDataSource != null ; boolean isContainerBound = ( parsedDataSource . getTokens ( ) . get ( 0 ) ) . toString ( ) . equals ( "container" ) ; String parentName = null ; if ( dap . getProviderParent ( ) != null ) parentName = rewriteNameInternal ( dap . getProviderParent ( ) ) ; else if ( dap . getProviderParent ( ) == null || ( dap . getProviderParent ( ) != null && ! isContainerBound ) ) { return dap . getDataSource ( ) ; } if ( _logger . isDebugEnabled ( ) ) { _logger . debug ( "changeContext: DAP.dataSource=" + dap . getDataSource ( ) + " oldContext=container newContext=" + parentName + " currentIndex=" + dap . getProviderParent ( ) . getCurrentIndex ( ) + " parentName is container: " + isContainerBound ) ; } String retVal = null ; String ds = dap . getDataSource ( ) ; boolean isContainerItemBound = false ; if ( isContainerBound && ( parsedDataSource . getTokens ( ) . get ( 1 ) ) . toString ( ) . equals ( "item" ) ) isContainerItemBound = true ; if ( isContainerItemBound ) retVal = changeContext ( ds , "container.item" , parentName , dap . getProviderParent ( ) . getCurrentIndex ( ) ) ; else retVal = changeContext ( ds , "container" , parentName , dap . getProviderParent ( ) . getCurrentIndex ( ) ) ; if ( _logger . isDebugEnabled ( ) ) _logger . debug ( "fully-qualified binding expression: \"" + retVal + "\"" ) ; return retVal ; } | Rewrite a parent IDataAccessProvider s dataSource to be fully qualified . |
9,848 | public Object invoke ( FacesContext context , Object params [ ] ) throws EvaluationException , MethodNotFoundException { Object result = _delegate . invoke ( context , params ) ; if ( result instanceof String ) { String action = ( String ) result ; ExternalContext externalContext = context . getExternalContext ( ) ; Object request = externalContext . getRequest ( ) ; Object servletContextObject = externalContext . getContext ( ) ; assert request != null ; if ( request instanceof HttpServletRequest && servletContextObject instanceof ServletContext ) { ServletContext servletContext = ( ServletContext ) servletContextObject ; HttpServletRequest httpRequest = ( HttpServletRequest ) request ; Object backingBean = InternalUtils . getFacesBackingBean ( httpRequest , servletContext ) ; if ( backingBean != null ) { Class backingClass = backingBean . getClass ( ) ; Method method = _methodCache . getMethod ( backingClass , _methodName , _params ) ; if ( method == null ) { throw new MethodNotFoundException ( _methodName ) ; } AnnotationReader annReader = AnnotationReader . getAnnotationReader ( backingClass , servletContext ) ; ProcessedAnnotation ann = annReader . getJpfAnnotation ( method , "CommandHandler" ) ; if ( ann != null ) { ProcessedAnnotation [ ] raiseActions = AnnotationReader . getAnnotationArrayAttribute ( ann , "raiseActions" ) ; if ( raiseActions != null ) { setOutputFormBeans ( raiseActions , backingClass , backingBean , action , httpRequest ) ; } } } } } return result ; } | Before returning the result from the base MethodBinding see if the bound method is annotated with Jpf . CommandHandler . If it is look through the raiseActions annotation array for a form bean member variable associated with the action being raised . If one is found set it in the request so it gets passed to the action . |
9,849 | public void emit ( Filer f , String pkg , File mf , String csn ) throws IOException { PrintWriter pw = f . createTextFile ( Filer . Location . CLASS_TREE , pkg , mf , csn ) ; pw . println ( "# Apache Beehive Controls client manifest (auto-generated, do not edit!)" ) ; Set props = _properties . keySet ( ) ; for ( Object p : props ) { String name = ( String ) p ; String value = _properties . getProperty ( name ) ; name = escapeJava ( name ) ; if ( value != null ) value = escapeJava ( value ) ; pw . println ( name + "=" + value ) ; } pw . flush ( ) ; pw . close ( ) ; } | Emits the manifest via an apt Filer implementation |
9,850 | protected AptControlInterface initControlInterface ( ) { TypeMirror controlType = _fieldDecl . getType ( ) ; if ( ! ( controlType instanceof DeclaredType ) ) { _ap . printError ( _fieldDecl , "control.field.bad.type" ) ; return null ; } TypeDeclaration typeDecl = ( ( DeclaredType ) controlType ) . getDeclaration ( ) ; InterfaceDeclaration controlIntf = null ; if ( typeDecl == null ) { String className = controlType . toString ( ) ; String intfName = className . substring ( 0 , className . length ( ) - 4 ) ; String interfaceHint = getControlInterfaceHint ( ) ; controlIntf = ( InterfaceDeclaration ) _ap . getAnnotationProcessorEnvironment ( ) . getTypeDeclaration ( intfName ) ; if ( controlIntf == null ) { for ( TypeDeclaration td : _ap . getAnnotationProcessorEnvironment ( ) . getSpecifiedTypeDeclarations ( ) ) { if ( interfaceHint != null ) { if ( td instanceof InterfaceDeclaration && td . getQualifiedName ( ) . equals ( interfaceHint ) ) { controlIntf = ( InterfaceDeclaration ) td ; break ; } } else { if ( td instanceof InterfaceDeclaration && td . getSimpleName ( ) . equals ( intfName ) ) { controlIntf = ( InterfaceDeclaration ) td ; break ; } } } } } else if ( typeDecl instanceof ClassDeclaration ) { Collection < InterfaceType > implIntfs = ( ( ClassDeclaration ) typeDecl ) . getSuperinterfaces ( ) ; for ( InterfaceType intfType : implIntfs ) { InterfaceDeclaration intfDecl = intfType . getDeclaration ( ) ; if ( intfDecl == null ) return null ; if ( intfDecl . getAnnotation ( ControlInterface . class ) != null || intfDecl . getAnnotation ( ControlExtension . class ) != null ) { controlIntf = intfDecl ; break ; } } } else if ( typeDecl instanceof InterfaceDeclaration ) { controlIntf = ( InterfaceDeclaration ) typeDecl ; } if ( controlIntf == null ) { _ap . printError ( _fieldDecl , "control.field.bad.type.2" ) ; return null ; } return new AptControlInterface ( controlIntf , _ap ) ; } | Initializes the ControlInterface associated with this ControlField |
9,851 | public static void processTreeRequest ( String treeId , TreeElement treeRoot , HttpServletRequest request , HttpServletResponse response ) { assert ( treeId != null ) : "parameter treeId must not be null." ; assert ( treeRoot != null ) : "parameter treeRoot must not be null." ; assert ( request != null ) : "paramater request must not be null." ; String selectNode = request . getParameter ( TreeElement . SELECTED_NODE ) ; if ( selectNode != null ) { if ( treeRoot instanceof ITreeRootElement ) { ITreeRootElement root = ( ITreeRootElement ) treeRoot ; root . changeSelected ( selectNode , request ) ; } else { setSelected ( treeRoot , selectNode , request ) ; } } String expandNode = null ; expandNode = request . getParameter ( TreeElement . EXPAND_NODE ) ; if ( expandNode != null ) { TreeElement n = treeRoot . findNode ( expandNode ) ; if ( n != null ) { n . onExpand ( request , response ) ; n . setExpanded ( ! n . isExpanded ( ) ) ; } } } | If this tree was selected or expanded this will handle that processing . |
9,852 | protected static void setSelected ( TreeElement node , String selected , ServletRequest request ) { assert ( node != null ) : "parameter 'node' must not be null" ; assert ( selected != null ) : "parameter 'selected' must not be null" ; assert ( request != null ) : "parameter 'requested' must not be null" ; if ( node . getName ( ) . equals ( selected ) ) { node . onSelect ( request ) ; node . setSelected ( true ) ; } else { if ( node . isSelected ( ) ) { node . onSelect ( request ) ; node . setSelected ( false ) ; } } TreeElement children [ ] = node . getChildren ( ) ; assert ( children != null ) ; for ( int i = 0 ; i < children . length ; i ++ ) { setSelected ( children [ i ] , selected , request ) ; } } | Recursive routine to set the selected node . This will set the selected node and clear the selection on all other nodes . It will walk the full tree . |
9,853 | public static TreeElement findSelected ( TreeElement root ) { assert ( root != null ) : "parameter 'root' must not be null" ; if ( root instanceof ITreeRootElement ) { return ( ( ITreeRootElement ) root ) . getSelectedNode ( ) ; } return recursiveFindSelected ( root ) ; } | This will return the currently selected node from a tree . |
9,854 | private static TreeElement recursiveFindSelected ( TreeElement elem ) { assert ( elem != null ) ; if ( elem . isSelected ( ) ) return elem ; TreeElement children [ ] = elem . getChildren ( ) ; assert ( children != null ) ; for ( int i = 0 ; i < children . length ; i ++ ) { TreeElement e = recursiveFindSelected ( children [ i ] ) ; if ( e != null ) return e ; } return null ; } | Recursive method that will find the currently selected element in the tree . |
9,855 | public String getEventDescriptor ( Class controlInterface ) { if ( _descriptor == null ) _descriptor = computeEventDescriptor ( _method ) ; return _descriptor ; } | Returns the event descriptor string associated with the EventRef . |
9,856 | private String computeEventDescriptor ( Method method ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( method . getDeclaringClass ( ) . getName ( ) ) ; sb . append ( "." ) ; sb . append ( method . getName ( ) ) ; Class [ ] parms = method . getParameterTypes ( ) ; sb . append ( "(" ) ; for ( int i = 0 ; i < parms . length ; i ++ ) appendTypeDescriptor ( sb , parms [ i ] ) ; sb . append ( ")" ) ; appendTypeDescriptor ( sb , method . getReturnType ( ) ) ; return sb . toString ( ) ; } | Helper method that computes the event descriptor sting for a method |
9,857 | private void appendTypeDescriptor ( StringBuilder sb , Class clazz ) { if ( clazz . isPrimitive ( ) ) sb . append ( _primToType . get ( clazz ) ) ; else if ( clazz . isArray ( ) ) sb . append ( clazz . getName ( ) . replace ( '.' , '/' ) ) ; else { sb . append ( "L" ) ; sb . append ( clazz . getName ( ) . replace ( '.' , '/' ) ) ; sb . append ( ";" ) ; } } | Helper method that appends a type descriptor to a StringBuilder . Used while accumulating an event descriptor string . |
9,858 | public Method getEventMethod ( Class controlInterface ) { if ( _method != null && _method . getDeclaringClass ( ) . getClassLoader ( ) . equals ( controlInterface . getClassLoader ( ) ) ) return _method ; String eventDescriptor = getEventDescriptor ( controlInterface ) ; HashMap < String , Method > descriptorMap = getDescriptorMap ( controlInterface ) ; if ( ! descriptorMap . containsKey ( eventDescriptor ) ) { throw new IllegalArgumentException ( "Control interface " + controlInterface + " does not contain an event method that " + " corresponds to " + eventDescriptor ) ; } return descriptorMap . get ( eventDescriptor ) ; } | Returns the event Method associated with this EventRef . |
9,859 | protected void scanDir ( File srcDir , File destDir , String [ ] files , String ext ) { if ( ! _hasSourcepath ) { Path srcPath = new Path ( getProject ( ) ) ; srcPath . setLocation ( srcDir ) ; setSourcepath ( srcPath ) ; } GlobPatternMapper m = new GlobPatternMapper ( ) ; m . setFrom ( ext ) ; m . setTo ( "*.class" ) ; SourceFileScanner sfs = new SourceFileScanner ( this ) ; if ( ext . equals ( "*.java" ) ) { File [ ] newFiles = sfs . restrictAsFiles ( files , srcDir , destDir , m ) ; if ( newFiles . length > 0 ) { File [ ] newCompileList = new File [ compileList . length + newFiles . length ] ; System . arraycopy ( compileList , 0 , newCompileList , 0 , compileList . length ) ; System . arraycopy ( newFiles , 0 , newCompileList , compileList . length , newFiles . length ) ; compileList = newCompileList ; } } else { String [ ] newSources = sfs . restrict ( files , srcDir , destDir , m ) ; int extLen = ext . length ( ) - 1 ; if ( newSources . length > 0 ) { File [ ] newCompileList = new File [ compileList . length + newSources . length ] ; System . arraycopy ( compileList , 0 , newCompileList , 0 , compileList . length ) ; try { FileUtils fileUtils = FileUtils . newFileUtils ( ) ; for ( int j = 0 ; j < newSources . length ; j ++ ) { String toName = newSources [ j ] . substring ( 0 , newSources [ j ] . length ( ) - extLen ) + ".java" ; File srcFile = new File ( srcDir , newSources [ j ] ) ; File dstFile = new File ( _genDir , toName ) ; fileUtils . copyFile ( srcFile , dstFile , null , true , true ) ; newCompileList [ compileList . length + j ] = dstFile ; } } catch ( IOException ioe ) { throw new BuildException ( "Unable to copy " + ext + " file" , ioe , getLocation ( ) ) ; } compileList = newCompileList ; } } } | Override the implementation of scanDir to look for additional files based upon any specified source extensions |
9,860 | public static void loadImplicitObjects ( HttpServletRequest request , HttpServletResponse response , ServletContext servletContext , PageFlowController currentPageFlow ) { loadPageFlow ( request , currentPageFlow ) ; BundleMap bundleMap = new BundleMap ( request , servletContext ) ; loadBundleMap ( request , bundleMap ) ; } | Load the NetUI framework s implicit objects into the request . |
9,861 | public static void loadPageFlow ( ServletRequest request , PageFlowController pageFlow ) { if ( pageFlow != null ) request . setAttribute ( PAGE_FLOW_IMPLICIT_OBJECT_KEY , pageFlow ) ; Map map = InternalUtils . getPageInputMap ( request ) ; request . setAttribute ( PAGE_INPUT_IMPLICIT_OBJECT_KEY , map != null ? map : Collections . EMPTY_MAP ) ; } | Load Page Flow related implicit objects into the request . This method will set the Page Flow itself and any available page inputs into the request . |
9,862 | public static void loadFacesBackingBean ( ServletRequest request , FacesBackingBean facesBackingBean ) { if ( facesBackingBean != null ) request . setAttribute ( BACKING_IMPLICIT_OBJECT_KEY , facesBackingBean ) ; } | Load the JSF backing bean into the request . |
9,863 | public static void loadSharedFlow ( ServletRequest request , Map sharedFlows ) { if ( sharedFlows != null ) request . setAttribute ( SHARED_FLOW_IMPLICIT_OBJECT_KEY , sharedFlows ) ; } | Load the shared flow into the request . |
9,864 | public static void loadGlobalApp ( ServletRequest request , GlobalApp globalApp ) { if ( globalApp != null ) request . setAttribute ( GLOBAL_APP_IMPLICIT_OBJECT_KEY , globalApp ) ; } | Load the global app into the request |
9,865 | public static void loadOutputFormBean ( ServletRequest request , Object bean ) { if ( bean != null ) request . setAttribute ( OUTPUT_FORM_BEAN_OBJECT_KEY , bean ) ; } | Load the output form bean into the request . |
9,866 | protected boolean isSetterMethod ( Method method ) { Matcher matcher = _setterRegex . matcher ( method . getName ( ) ) ; if ( matcher . matches ( ) ) { if ( Modifier . isStatic ( method . getModifiers ( ) ) ) return false ; if ( ! Modifier . isPublic ( method . getModifiers ( ) ) ) return false ; if ( ! Void . TYPE . equals ( method . getReturnType ( ) ) ) return false ; Class [ ] params = method . getParameterTypes ( ) ; if ( params . length != 1 ) return false ; if ( TypeMappingsFactory . TYPE_UNKNOWN == _tmf . getTypeId ( params [ 0 ] ) ) return false ; return true ; } return false ; } | Determine if the given method is a java bean setter method . |
9,867 | public static Method lookupMethod ( Class parentClass , String methodName , Class [ ] signature ) { try { return parentClass . getDeclaredMethod ( methodName , signature ) ; } catch ( NoSuchMethodException e ) { Class superClass = parentClass . getSuperclass ( ) ; return superClass != null ? lookupMethod ( superClass , methodName , signature ) : null ; } } | Get a Method in a Class . |
9,868 | public static Field lookupField ( Class parentClass , String fieldName ) { try { return parentClass . getDeclaredField ( fieldName ) ; } catch ( NoSuchFieldException e ) { Class superClass = parentClass . getSuperclass ( ) ; return superClass != null ? lookupField ( superClass , fieldName ) : null ; } } | Get a Field in a Class . |
9,869 | public static boolean isLongLived ( ModuleConfig moduleConfig ) { ControllerConfig cc = moduleConfig . getControllerConfig ( ) ; if ( cc instanceof PageFlowControllerConfig ) { return ( ( PageFlowControllerConfig ) cc ) . isLongLivedPageFlow ( ) ; } else { return false ; } } | Tell whether the given module is a long - lived page flow . |
9,870 | public static boolean isNestable ( ModuleConfig moduleConfig ) { ControllerConfig cc = moduleConfig . getControllerConfig ( ) ; return cc instanceof PageFlowControllerConfig && ( ( PageFlowControllerConfig ) cc ) . isNestedPageFlow ( ) ; } | Tell whether the given module is a nested page flow . |
9,871 | public static ModuleConfig getModuleConfig ( String modulePath , ServletContext context ) { return ( ModuleConfig ) context . getAttribute ( Globals . MODULE_KEY + modulePath ) ; } | Get the Struts ModuleConfig for the given module path . |
9,872 | public static ModuleConfig ensureModuleConfig ( String modulePath , ServletContext context ) { try { ModuleConfig ret = getModuleConfig ( modulePath , context ) ; if ( ret != null ) { return ret ; } else { ActionServlet as = getActionServlet ( context ) ; if ( as instanceof AutoRegisterActionServlet ) { return ( ( AutoRegisterActionServlet ) as ) . ensureModuleRegistered ( modulePath ) ; } } } catch ( IOException e ) { _log . error ( "Error while registering Struts module " + modulePath , e ) ; } catch ( ServletException e ) { _log . error ( "Error while registering Struts module " + modulePath , e ) ; } return null ; } | Get the Struts ModuleConfig for the given module path . If there is none registered and if it is possible to register one automatically do so . |
9,873 | public static void initDelegatingConfigs ( ModuleConfig moduleConfig , ServletContext servletContext ) { ActionConfig [ ] actionConfigs = moduleConfig . findActionConfigs ( ) ; for ( int i = 0 ; i < actionConfigs . length ; i ++ ) { ActionConfig actionConfig = actionConfigs [ i ] ; if ( actionConfig instanceof DelegatingActionMapping ) { ( ( DelegatingActionMapping ) actionConfig ) . init ( servletContext ) ; } else { ExceptionConfig [ ] exceptionConfigs = actionConfig . findExceptionConfigs ( ) ; for ( int j = 0 ; j < exceptionConfigs . length ; j ++ ) { ExceptionConfig exceptionConfig = exceptionConfigs [ j ] ; if ( exceptionConfig instanceof DelegatingExceptionConfig ) { ( ( DelegatingExceptionConfig ) exceptionConfig ) . init ( servletContext ) ; } } } } ExceptionConfig [ ] exceptionConfigs = moduleConfig . findExceptionConfigs ( ) ; for ( int i = 0 ; i < exceptionConfigs . length ; i ++ ) { ExceptionConfig exceptionConfig = exceptionConfigs [ i ] ; if ( exceptionConfig instanceof DelegatingExceptionConfig ) { ( ( DelegatingExceptionConfig ) exceptionConfig ) . init ( servletContext ) ; } } } | Initialize delegating action configs and exception configs for a Struts module that should delegate to one generated from a superclass . |
9,874 | public static ActionServlet getActionServlet ( ServletContext context ) { if ( context == null ) return null ; return ( ActionServlet ) context . getAttribute ( Globals . ACTION_SERVLET_KEY ) ; } | Get the current ActionServlet . |
9,875 | public static void addBindingUpdateError ( ServletRequest request , String expression , String message , Throwable cause ) { Map errors = ( Map ) request . getAttribute ( BINDING_UPDATE_ERRORS_ATTR ) ; if ( errors == null ) { errors = new LinkedHashMap ( ) ; request . setAttribute ( BINDING_UPDATE_ERRORS_ATTR , errors ) ; } errors . put ( expression , new BindingUpdateError ( expression , message , cause ) ) ; } | Add a BindingUpdateError to the request . |
9,876 | public static ActionConfig findActionConfig ( String actionConfigPath , String modulePath , ServletContext context ) { ModuleConfig moduleConfig = getModuleConfig ( modulePath , context ) ; assert moduleConfig != null ; return moduleConfig . findActionConfig ( actionConfigPath ) ; } | Get the Struts ActionConfig for the given action config path and module path . |
9,877 | public static String getActionMappingPath ( ServletRequest request ) { ActionMapping actionMapping = ( ActionMapping ) request . getAttribute ( Globals . MAPPING_KEY ) ; return actionMapping != null ? actionMapping . getPath ( ) : null ; } | Get the Struts ActionMapping path from the ActionMapping that is in the request under the key Globals . MAPPING_KEY . |
9,878 | public static String getModulePathFromReqAttr ( HttpServletRequest request ) { ModuleConfig config = ( ModuleConfig ) request . getAttribute ( Globals . MODULE_KEY ) ; return config != null ? config . getPrefix ( ) : PageFlowUtils . getModulePath ( request ) ; } | Gets the Struts module path from the input request . If a ModuleConfig object has been populated into the request it is used to get the module prefix otherwise getModulePath is called which derives the module path from the request URI . |
9,879 | public static ModuleConfig selectModule ( String prefix , HttpServletRequest request , ServletContext servletContext ) { ModuleConfig moduleConfig = getModuleConfig ( prefix , servletContext ) ; if ( moduleConfig == null ) { request . removeAttribute ( Globals . MODULE_KEY ) ; return null ; } ControllerConfig cc = moduleConfig . getControllerConfig ( ) ; if ( cc instanceof PageFlowControllerConfig && ( ( PageFlowControllerConfig ) cc ) . isAbstract ( ) ) { return moduleConfig ; } if ( request . getAttribute ( Globals . MODULE_KEY ) == moduleConfig ) return moduleConfig ; request . setAttribute ( Globals . MODULE_KEY , moduleConfig ) ; MessageResourcesConfig [ ] mrConfig = moduleConfig . findMessageResourcesConfigs ( ) ; Object formBean = unwrapFormBean ( getCurrentActionForm ( request ) ) ; for ( int i = 0 ; i < mrConfig . length ; i ++ ) { String key = mrConfig [ i ] . getKey ( ) ; MessageResources resources = ( MessageResources ) servletContext . getAttribute ( key + prefix ) ; if ( resources != null ) { if ( ! ( resources instanceof ExpressionAwareMessageResources ) ) { resources = new ExpressionAwareMessageResources ( resources , formBean , request , servletContext ) ; } request . setAttribute ( key , resources ) ; } else { request . removeAttribute ( key ) ; } } return moduleConfig ; } | Set the given Struts module in the request and expose its set of MessageResources as request attributes . |
9,880 | public static String getQualifiedBundleName ( String bundleName , ServletRequest request ) { if ( bundleName != null ) { if ( bundleName . indexOf ( '/' ) == - 1 ) { ModuleConfig mc = ( ModuleConfig ) request . getAttribute ( Globals . MODULE_KEY ) ; if ( mc != null && mc . getPrefix ( ) != null && mc . getPrefix ( ) . length ( ) > 1 ) { bundleName += mc . getPrefix ( ) ; } } else if ( bundleName . endsWith ( "/" ) ) { bundleName = bundleName . substring ( 0 , bundleName . length ( ) - 1 ) ; } } return bundleName ; } | Qualify the given bundle name with the current module path to return a full bundle name . |
9,881 | public String getType ( ) { if ( _fieldDecl == null || _fieldDecl . getType ( ) == null ) return "" ; return _fieldDecl . getType ( ) . toString ( ) ; } | Returns the type of the field |
9,882 | public String getClassName ( ) { if ( _fieldDecl == null || _fieldDecl . getType ( ) == null ) return "" ; String typeName = _fieldDecl . getType ( ) . toString ( ) ; int formalIndex = typeName . indexOf ( '<' ) ; if ( formalIndex > 0 ) return typeName . substring ( 0 , formalIndex ) ; return typeName ; } | Returns the class name of the field ( does not include any formal type parameters |
9,883 | public String getAccessModifier ( ) { if ( _fieldDecl == null ) return "" ; Collection < Modifier > modifiers = _fieldDecl . getModifiers ( ) ; if ( modifiers . contains ( Modifier . PRIVATE ) ) return "private" ; if ( modifiers . contains ( Modifier . PROTECTED ) ) return "protected" ; if ( modifiers . contains ( Modifier . PUBLIC ) ) return "public" ; return "" ; } | Returns the access modifier associated with the field |
9,884 | public String rewriteName ( String name , Tag currentTag ) throws ExpressionEvaluationException { ExpressionEvaluator eval = ExpressionEvaluatorFactory . getInstance ( ) ; try { if ( ! eval . isExpression ( name ) ) return eval . qualify ( "actionForm" , name ) ; return name ; } catch ( Exception e ) { if ( logger . isErrorEnabled ( ) ) logger . error ( "Could not qualify name \"" + name + "\" into the actionForm binding context." , e ) ; return name ; } } | Qualify the name of a NetUI JSP tag into the actionForm data binding context . This feature is used to convert non - expression tag names as those used in Struts into actionForm expressions that NetUI consumes . |
9,885 | public static RibbonColumn getRibbonColumn ( String key , List < ClientToolInfo > tools , List < Parameter > parameters , MapWidget mapWidget ) { RibbonColumnCreator ribbonColumnCreator = REGISTRY . get ( key ) ; if ( ribbonColumnCreator == null ) { Log . logWarn ( "Could not find RibbonColumn with ID: " + key ) ; return null ; } else { RibbonColumn column = ribbonColumnCreator . create ( tools , mapWidget ) ; if ( parameters != null ) { for ( Parameter parameter : parameters ) { column . configure ( parameter . getName ( ) , parameter . getValue ( ) ) ; } } return column ; } } | Get the ribbon column which matches the given key . |
9,886 | public boolean isClosed ( ) { if ( isEmpty ( ) ) { return false ; } if ( getNumPoints ( ) == 1 ) { return false ; } Coordinate [ ] coordinates = getCoordinates ( ) ; return coordinates [ 0 ] . equals ( coordinates [ coordinates . length - 1 ] ) ; } | Checks to see if the last coordinate equals the first . Should always be the case! |
9,887 | public boolean isValid ( ) { if ( isEmpty ( ) ) { return true ; } if ( ! isClosed ( ) ) { return false ; } Coordinate [ ] coordinates = getCoordinates ( ) ; if ( coordinates . length < 4 ) { return false ; } for ( int i = 0 ; i < coordinates . length - 1 ; i ++ ) { for ( int j = 0 ; j < coordinates . length - 1 ; j ++ ) { if ( Mathlib . lineIntersects ( coordinates [ i ] , coordinates [ i + 1 ] , coordinates [ j ] , coordinates [ j + 1 ] ) ) { return false ; } } } return true ; } | An empty LinearRing is valid . Furthermore this object must be closed and must not self - intersect . |
9,888 | public double distance ( Vector2D vector2d ) { double a = vector2d . x - x ; double b = vector2d . y - y ; return Math . sqrt ( a * a + b * b ) ; } | Calculate the distance between 2 vector by using Pythagoras formula . |
9,889 | public static String asMapLength ( MapWidget map , double length ) { double unitLength = map . getUnitLength ( ) ; double distance = length * unitLength ; String unit = "m" ; if ( map . getMapModel ( ) . getMapInfo ( ) . getDisplayUnitType ( ) == UnitType . METRIC ) { if ( distance > 10000 ) { distance /= METERS_IN_KM ; unit = "km" ; } } else if ( map . getMapModel ( ) . getMapInfo ( ) . getDisplayUnitType ( ) == UnitType . ENGLISH ) { if ( distance / METERS_IN_YARD > 10000 ) { distance = distance / METERS_IN_MILE ; unit = "mi" ; } else { distance /= METERS_IN_YARD ; unit = "yd" ; } } else if ( map . getMapModel ( ) . getMapInfo ( ) . getDisplayUnitType ( ) == UnitType . ENGLISH_FOOT ) { if ( distance * FEET_IN_METER > FEET_IN_MILE ) { distance = distance / METERS_IN_MILE ; unit = "mi" ; } else { distance *= FEET_IN_METER ; unit = "ft" ; } } else if ( map . getMapModel ( ) . getMapInfo ( ) . getDisplayUnitType ( ) == UnitType . CRS ) { unit = "u" ; } String formatted = NumberFormat . getDecimalFormat ( ) . format ( distance ) ; return formatted + unit ; } | Distance formatting method . Requires a length as parameter expressed in the CRS units of the given map . |
9,890 | public static String asMapArea ( MapWidget map , double area ) { double unitLength = map . getUnitLength ( ) ; double distance = area * unitLength * unitLength ; String unit = "m" ; if ( map . getMapModel ( ) . getMapInfo ( ) . getDisplayUnitType ( ) == UnitType . METRIC ) { if ( distance > ( METERS_IN_KM * METERS_IN_KM ) ) { distance /= ( METERS_IN_KM * METERS_IN_KM ) ; unit = "km" ; } } else if ( map . getMapModel ( ) . getMapInfo ( ) . getDisplayUnitType ( ) == UnitType . ENGLISH ) { if ( distance > ( METERS_IN_MILE * METERS_IN_MILE ) ) { distance = distance / ( METERS_IN_MILE * METERS_IN_MILE ) ; unit = "mi" ; } else { distance /= ( METERS_IN_YARD * METERS_IN_YARD ) ; unit = "yd" ; } } else if ( map . getMapModel ( ) . getMapInfo ( ) . getDisplayUnitType ( ) == UnitType . CRS ) { unit = "u" ; } String formatted = NumberFormat . getDecimalFormat ( ) . format ( distance ) ; return formatted + unit + "²" ; } | Area formatting method . Requires an area as parameter expressed in the CRS units of the given map . |
9,891 | public void setMap ( Map map ) { this . map = ( MapImpl ) map ; mapWidget = this . map . getMapWidget ( ) ; delegate = new GeometryEditorImpl ( mapWidget ) ; editingService = new JsGeometryEditService ( delegate . getEditService ( ) ) ; splitService = new JsGeometrySplitService ( delegate . getEditService ( ) ) ; mergeService = new JsGeometryMergeService ( ) ; renderer = new JsGeometryRenderer ( delegate . getRenderer ( ) ) ; styleService = new JsStyleService ( delegate . getStyleService ( ) ) ; snapService = new JsSnapService ( this ) ; } | Set the map . |
9,892 | public void addLayerSnappingRules ( String layerId ) { Layer < ? > layer = mapWidget . getMapModel ( ) . getLayer ( layerId ) ; if ( layer != null && layer instanceof VectorLayer ) { VectorLayer vLayer = ( VectorLayer ) layer ; for ( SnappingRuleInfo snappingRuleInfo : vLayer . getLayerInfo ( ) . getSnappingRules ( ) ) { SnapRuleUtil . addRule ( delegate . getSnappingService ( ) , mapWidget , snappingRuleInfo ) ; } } } | Add the list of snapping rules as they are configured for a specific layer within the XML configuration . |
9,893 | public static void keepWindowInScreen ( Window window ) { window . setKeepInParentRect ( true ) ; if ( null != window . getHeightAsString ( ) ) { int screenHeight = com . google . gwt . user . client . Window . getClientHeight ( ) ; int windowHeight = window . getViewportHeight ( ) ; window . setMaxHeight ( screenHeight - WidgetLayout . windowOffset * 2 ) ; if ( windowHeight + window . getAbsoluteTop ( ) > screenHeight ) { int top = screenHeight - windowHeight ; if ( top >= 0 ) { window . setPageTop ( top ) ; } else { window . setHeight ( screenHeight - WidgetLayout . windowOffset ) ; window . setPageTop ( WidgetLayout . windowOffset ) ; } } } if ( null != window . getWidthAsString ( ) ) { int screenWidth = com . google . gwt . user . client . Window . getClientWidth ( ) ; int windowWidth = window . getViewportWidth ( ) ; window . setMaxWidth ( screenWidth - WidgetLayout . windowOffset * 2 ) ; if ( windowWidth + window . getAbsoluteLeft ( ) > screenWidth ) { int left = screenWidth - windowWidth ; if ( left >= 0 ) { window . setPageLeft ( left ) ; } else { window . setWidth ( screenWidth - WidgetLayout . windowOffset ) ; window . setPageLeft ( WidgetLayout . windowOffset ) ; } } } } | Try to force a window to stay within the screen bounds . |
9,894 | public Geometry execute ( Geometry geometry ) { if ( geometry instanceof Polygon ) { Polygon polygon = ( Polygon ) geometry ; if ( polygon . getNumInteriorRing ( ) == 0 ) { return null ; } if ( ringIndex < 0 ) { ringIndex = 0 ; } else if ( ringIndex >= polygon . getNumInteriorRing ( ) ) { ringIndex = polygon . getNumInteriorRing ( ) - 1 ; } LinearRing [ ] interiorRings = new LinearRing [ polygon . getNumInteriorRing ( ) - 1 ] ; int count = 0 ; for ( int n = 0 ; n < polygon . getNumInteriorRing ( ) ; n ++ ) { if ( n != ringIndex ) { interiorRings [ count ++ ] = polygon . getInteriorRingN ( n ) ; } } return geometry . getGeometryFactory ( ) . createPolygon ( polygon . getExteriorRing ( ) , interiorRings ) ; } return null ; } | Execute the operation! When the geometry is not a Polygon null is returned . When the polygon does not have any interior rings null is returned . |
9,895 | public void onFolderClick ( FolderClickEvent event ) { try { if ( isIconTargetClicked ( ) ) { onIconClick ( event . getFolder ( ) ) ; } else { if ( event . getFolder ( ) instanceof LayerTreeTreeNode ) { mapModel . selectLayer ( ( ( LayerTreeTreeNode ) event . getFolder ( ) ) . getLayer ( ) ) ; } else { mapModel . selectLayer ( null ) ; } } } catch ( Exception e ) { Log . logError ( e . getMessage ( ) ) ; } } | When the user clicks on a folder nothing gets selected . |
9,896 | public void onLeafClick ( LeafClickEvent event ) { try { if ( isIconTargetClicked ( ) ) { onIconClick ( event . getLeaf ( ) ) ; } else { LayerTreeTreeNode layerTreeNode = ( LayerTreeTreeNode ) event . getLeaf ( ) ; mapModel . selectLayer ( layerTreeNode . getLayer ( ) ) ; } } catch ( Exception e ) { Log . logError ( e . getMessage ( ) ) ; } } | When the user clicks on a leaf the headertext of the treetable is changed to the selected leaf and the toolbar buttons are updated to represent the correct state of the buttons . |
9,897 | private boolean isIconTargetClicked ( ) { String targetHtml = EventHandler . getNativeMouseTarget ( ) . getString ( ) ; if ( targetHtml . indexOf ( ICON_EXTENSION ) != - 1 ) { return true ; } return false ; } | Method that checks if the target html tag of mouse event contains given icon extension . Should be backwards compatible with smartgwt 3 . 1 where the source html tag is IMG . !Will probably not work on touch devices . |
9,898 | protected void buildTree ( ) { treeGrid . setWidth100 ( ) ; treeGrid . setHeight100 ( ) ; treeGrid . setShowHeader ( false ) ; treeGrid . setOverflow ( Overflow . AUTO ) ; tree = new RefreshableTree ( ) ; final TreeNode nodeRoot = new TreeNode ( "ROOT" ) ; tree . setRoot ( nodeRoot ) ; ClientLayerTreeInfo layerTreeInfo = ( ClientLayerTreeInfo ) mapModel . getMapInfo ( ) . getWidgetInfo ( ClientLayerTreeInfo . IDENTIFIER ) ; tree . setRoot ( nodeRoot ) ; if ( layerTreeInfo != null ) { for ( ClientAbstractNodeInfo node : layerTreeInfo . getTreeNode ( ) . getTreeNodes ( ) ) { processNode ( node , nodeRoot , false ) ; } } treeGrid . setData ( tree ) ; treeGrid . addLeafClickHandler ( this ) ; treeGrid . addFolderClickHandler ( this ) ; treeGrid . addFolderClickHandler ( new FolderClickHandler ( ) { public void onFolderClick ( FolderClickEvent folderClickEvent ) { folderClickEvent . getSource ( ) ; } } ) ; treeGrid . addFolderOpenedHandler ( new FolderOpenedHandler ( ) { public void onFolderOpened ( FolderOpenedEvent folderOpenedEvent ) { folderOpenedEvent . getSource ( ) ; } } ) ; tree . openFolder ( nodeRoot ) ; syncNodeState ( false ) ; } | Builds up the tree showing the layers . |
9,899 | public String getAlgorithm ( ) { if ( cipher == null ) { return null ; } String transformation = cipher . getAlgorithm ( ) ; if ( transformation == null ) { return null ; } int pos = transformation . indexOf ( '/' ) ; if ( pos < 0 ) { return transformation ; } return transformation . substring ( 0 , pos ) ; } | Get the cipher algorithm name . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.