idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
38,200
public static Ellipsoid of ( final String name , final double a , final double b , final double f ) { return new Ellipsoid ( name , a , b , f ) ; }
Create a new earth ellipsoid with the given parameters .
38,201
public static Builder builder ( final String version , final String creator ) { return new Builder ( Version . of ( version ) , creator ) ; }
Create a new GPX builder with the given GPX version and creator string .
38,202
public static Reader reader ( final Version version , final Mode mode ) { return new Reader ( GPX . xmlReader ( version ) , mode ) ; }
Return a GPX reader reading GPX files with the given version and in the given reading mode .
38,203
public static Reader reader ( final Version version ) { return new Reader ( GPX . xmlReader ( version ) , Mode . STRICT ) ; }
Return a GPX reader reading GPX files with the given version and in strict reading mode .
38,204
public static Reader reader ( final Mode mode ) { return new Reader ( GPX . xmlReader ( Version . V11 ) , mode ) ; }
Return a GPX reader reading GPX files with version 1 . 1 and in the given reading mode .
38,205
public String toPattern ( ) { return _formats . stream ( ) . map ( Objects :: toString ) . collect ( Collectors . joining ( ) ) ; }
Return the pattern string represented by this formatter .
38,206
static String readString ( final DataInput in ) throws IOException { final byte [ ] bytes = new byte [ readInt ( in ) ] ; in . readFully ( bytes ) ; return new String ( bytes , "UTF-8" ) ; }
Reads a string value from the given data input .
38,207
static < T > void writes ( final Collection < ? extends T > elements , final Writer < ? super T > writer , final DataOutput out ) throws IOException { writeInt ( elements . size ( ) , out ) ; for ( T element : elements ) { writer . write ( element , out ) ; } }
Write the given elements to the data output .
38,208
static < T > List < T > reads ( final Reader < ? extends T > reader , final DataInput in ) throws IOException { final int length = readInt ( in ) ; final List < T > elements = new ArrayList < > ( length ) ; for ( int i = 0 ; i < length ; ++ i ) { elements . add ( reader . read ( in ) ) ; } return elements ; }
Reads a list of elements from the given data input .
38,209
public double to ( final Unit unit ) { requireNonNull ( unit ) ; return unit . convert ( _value , Unit . METERS_PER_SECOND ) ; }
Return the GPS speed value in the desired unit .
38,210
public static < T extends Serializable > Flowable < T > write ( final Flowable < T > source , final File file ) { return write ( source , file , false , DEFAULT_BUFFER_SIZE ) ; }
Writes the source stream to the given file in given append mode and using the a buffer size of 8192 bytes .
38,211
static Method getMethod ( Class < ? > cls , String name , Class < ? > ... params ) { Method m ; try { m = cls . getDeclaredMethod ( name , params ) ; } catch ( Exception e ) { throw new RuntimeException ( e ) ; } m . setAccessible ( true ) ; return m ; }
Bundle reflection calls to get access to the given method
38,212
private void mapAndSetOffset ( ) { try { final RandomAccessFile backingFile = new RandomAccessFile ( this . file , "rw" ) ; backingFile . setLength ( this . size ) ; final FileChannel ch = backingFile . getChannel ( ) ; this . addr = ( Long ) mmap . invoke ( ch , 1 , 0L , this . size ) ; ch . close ( ) ; backingFile . ...
for the given length and set this . addr to the returned offset
38,213
public void getBytes ( long pos , byte [ ] data , long offset , long length ) { unsafe . copyMemory ( null , pos + addr , data , BYTE_ARRAY_OFFSET + offset , length ) ; }
May want to have offset & length within data as well for both of these
38,214
public Phrase put ( String key , CharSequence value ) { if ( ! keys . contains ( key ) ) { throw new IllegalArgumentException ( "Invalid key: " + key ) ; } if ( value == null ) { throw new IllegalArgumentException ( "Null value for '" + key + "'" ) ; } keysToValues . put ( key , value ) ; formatted = null ; return this...
Replaces the given key with a non - null value . You may reuse Phrase instances and replace keys with new values .
38,215
public Phrase putOptional ( String key , CharSequence value ) { return keys . contains ( key ) ? put ( key , value ) : this ; }
Silently ignored if the key is not in the pattern .
38,216
public CharSequence format ( ) { if ( formatted == null ) { if ( ! keysToValues . keySet ( ) . containsAll ( keys ) ) { Set < String > missingKeys = new HashSet < String > ( keys ) ; missingKeys . removeAll ( keysToValues . keySet ( ) ) ; throw new IllegalArgumentException ( "Missing keys: " + missingKeys ) ; } Spannab...
Returns the text after replacing all keys with values .
38,217
private Token token ( Token prev ) { if ( curChar == EOF ) { return null ; } if ( curChar == '{' ) { char nextChar = lookahead ( ) ; if ( nextChar == '{' ) { return leftCurlyBracket ( prev ) ; } else if ( nextChar >= 'a' && nextChar <= 'z' ) { return key ( prev ) ; } else { throw new IllegalArgumentException ( "Unexpec...
Returns the next token from the input pattern or null when finished parsing .
38,218
private TextToken text ( Token prev ) { int startIndex = curCharIndex ; while ( curChar != '{' && curChar != EOF ) { consume ( ) ; } return new TextToken ( prev , curCharIndex - startIndex ) ; }
Consumes and returns a token for a sequence of text .
38,219
private void consume ( ) { curCharIndex ++ ; curChar = ( curCharIndex == pattern . length ( ) ) ? EOF : pattern . charAt ( curCharIndex ) ; }
Advances the current character position without any error checking . Consuming beyond the end of the string can only happen if this parser contains a bug .
38,220
private String determineLanguage ( FacesContext fc , DataTable dataTable ) { final List < String > availableLanguages = Arrays . asList ( "de" , "en" , "es" , "fr" , "hu" , "it" , "nl" , "pl" , "pt" , "ru" ) ; if ( BsfUtils . isStringValued ( dataTable . getCustomLangUrl ( ) ) ) { return dataTable . getCustomLangUrl ( ...
Determine if the user specify a lang Otherwise return null to avoid language settings .
38,221
public String getType ( ) { String mode = A . asString ( getAttributes ( ) . get ( "mode" ) , "badge" ) ; return mode . equals ( "edit" ) ? "text" : "hidden" ; }
Method added to prevent AngularFaces from setting the type
38,222
protected void renderPassThruAttributes ( FacesContext context , UIComponent component , String [ ] attrs , boolean shouldRenderDataAttributes ) throws IOException { ResponseWriter writer = context . getResponseWriter ( ) ; if ( ( attrs == null || attrs . length <= 0 ) && shouldRenderDataAttributes == false ) return ; ...
Method that provide ability to render pass through attributes .
38,223
protected void generateErrorAndRequiredClass ( UIInput input , ResponseWriter rw , String clientId , String additionalClass1 , String additionalClass2 , String additionalClass3 ) throws IOException { String styleClass = getErrorAndRequiredClass ( input , clientId ) ; if ( null != additionalClass1 ) { additionalClass1 =...
Renders the CSS pseudo classes for required fields and for the error levels .
38,224
public static Converter getConverter ( FacesContext fc , ValueHolder vh ) { Converter converter = vh . getConverter ( ) ; if ( converter == null ) { ValueExpression expr = ( ( UIComponent ) vh ) . getValueExpression ( "value" ) ; if ( expr != null ) { Class < ? > valueType = expr . getType ( fc . getELContext ( ) ) ; i...
Finds the appropriate converter for a given value holder
38,225
public static String getRequestParameter ( FacesContext context , String name ) { return context . getExternalContext ( ) . getRequestParameterMap ( ) . get ( name ) ; }
Returns request parameter value for the provided parameter name .
38,226
public static boolean beginDisabledFieldset ( IContentDisabled component , ResponseWriter rw ) throws IOException { if ( component . isContentDisabled ( ) ) { rw . startElement ( "fieldset" , ( UIComponent ) component ) ; rw . writeAttribute ( "disabled" , "disabled" , "null" ) ; return true ; } return false ; }
Renders the code disabling every input field and every button within a container .
38,227
protected String getFormGroupWithFeedback ( String additionalClass , String clientId ) { if ( BsfUtils . isLegacyFeedbackClassesEnabled ( ) ) { return additionalClass ; } return additionalClass + " " + FacesMessages . getErrorSeverityClass ( clientId ) ; }
Get the main field container
38,228
public static String getValueAsString ( Object value , FacesContext ctx , DateTimePicker dtp ) { if ( value == null ) { return null ; } Locale sloc = BsfUtils . selectLocale ( ctx . getViewRoot ( ) . getLocale ( ) , dtp . getLocale ( ) , dtp ) ; String javaFormatString = BsfUtils . selectJavaDateTimeFormatFromMomentJSF...
Yields the value which is displayed in the input field of the date picker .
38,229
public static String getDateAsString ( FacesContext fc , DateTimePicker dtp , Object value , String javaFormatString , Locale locale ) { if ( value == null ) { return null ; } Converter converter = dtp . getConverter ( ) ; return converter == null ? getInternalDateAsString ( value , javaFormatString , locale ) : conver...
Get date in string format
38,230
private void encodeSeverityMessage ( FacesContext facesContext , Growl uiGrowl , FacesMessage msg ) throws IOException { ResponseWriter writer = facesContext . getResponseWriter ( ) ; String summary = msg . getSummary ( ) != null ? msg . getSummary ( ) : "" ; String detail = msg . getDetail ( ) != null ? msg . getDetai...
Encode single faces message as growl
38,231
private String getSeverityIcon ( FacesMessage message ) { if ( message . getSeverity ( ) . equals ( FacesMessage . SEVERITY_WARN ) ) return "fa fa-exclamation-triangle" ; else if ( message . getSeverity ( ) . equals ( FacesMessage . SEVERITY_ERROR ) ) return "fa fa-times-circle" ; else if ( message . getSeverity ( ) . ...
Get severity related icons . We use FA icons because future version of Bootstrap does not support glyphicons anymore
38,232
private String getMessageType ( FacesMessage message ) { if ( message . getSeverity ( ) . equals ( FacesMessage . SEVERITY_WARN ) ) return "warning" ; else if ( message . getSeverity ( ) . equals ( FacesMessage . SEVERITY_ERROR ) ) return "danger" ; else if ( message . getSeverity ( ) . equals ( FacesMessage . SEVERITY...
Translate severity type to growl style class
38,233
public static void printNodeData ( Node rootNode , String tab ) { tab = tab == null ? "" : tab + " " ; for ( Node n : rootNode . getChilds ( ) ) { printNodeData ( n , tab ) ; } }
Debug method to print tree node structure
38,234
public static Node searchNodeById ( Node rootNode , int nodeId ) { if ( rootNode . getNodeId ( ) == nodeId ) { return rootNode ; } Node foundNode = null ; for ( Node n : rootNode . getChilds ( ) ) { foundNode = searchNodeById ( n , nodeId ) ; if ( foundNode != null ) { break ; } } return foundNode ; }
Basic implementation of recursive node search by id It works only on a DefaultNodeImpl
38,235
public static String renderModelAsJson ( Node rootNode , boolean renderRoot ) { if ( renderRoot ) { return renderSubnodes ( rootNode == null ? new ArrayList < Node > ( ) : new ArrayList < Node > ( Arrays . asList ( rootNode ) ) ) ; } else if ( rootNode != null && rootNode . hasChild ( ) ) { return renderSubnodes ( root...
Render the node model as JSON
38,236
public static void encodeDropMenuStart ( DropMenu c , ResponseWriter rw , String l ) throws IOException { rw . startElement ( "ul" , c ) ; if ( c . getContentClass ( ) != null ) rw . writeAttribute ( "class" , "dropdown-menu " + c . getContentClass ( ) , "class" ) ; else rw . writeAttribute ( "class" , "dropdown-menu" ...
Renders the Drop Menu .
38,237
private static void drawClearDiv ( ResponseWriter writer , UIComponent tabView ) throws IOException { writer . startElement ( "div" , tabView ) ; writer . writeAttribute ( "style" , "clear:both;" , "style" ) ; writer . endElement ( "div" ) ; }
Draw a clear div
38,238
private static void encodeTabLinks ( FacesContext context , ResponseWriter writer , TabView tabView , int currentlyActiveIndex , List < UIComponent > tabs , String clientId , String hiddenInputFieldID ) throws IOException { writer . startElement ( "ul" , tabView ) ; writer . writeAttribute ( "id" , clientId , "id" ) ; ...
Encode the list of links that render the tabs
38,239
private static void encodeTabContentPanes ( final FacesContext context , final ResponseWriter writer , final TabView tabView , final int currentlyActiveIndex , final List < UIComponent > tabs ) throws IOException { writer . startElement ( "div" , tabView ) ; String classes = "tab-content" ; if ( tabView . getContentCla...
Generates the HTML of the tab panes .
38,240
private static void encodeTabs ( final FacesContext context , final ResponseWriter writer , final List < UIComponent > children , final int currentlyActiveIndex , final String hiddenInputFieldID , final boolean disabled ) throws IOException { if ( null != children ) { int tabIndex = 0 ; for ( int index = 0 ; index < ch...
Generates the HTML of the tabs .
38,241
private static void encodeTabAnchorTag ( FacesContext context , ResponseWriter writer , Tab tab , String hiddenInputFieldID , int tabindex , boolean disabled ) throws IOException { writer . startElement ( "a" , tab ) ; writer . writeAttribute ( "id" , tab . getClientId ( ) . replace ( ":" , "_" ) + "_tab" , "id" ) ; wr...
Generate the clickable entity of the tab .
38,242
public static int toInt ( Object val ) { if ( val == null ) { return 0 ; } if ( val instanceof Number ) { return ( ( Number ) val ) . intValue ( ) ; } if ( val instanceof String ) { return Integer . parseInt ( ( String ) val ) ; } throw new IllegalArgumentException ( "Cannot convert " + val ) ; }
Converts the parameter to an integer value if possible . Throws an IllegalArgumentException if the parameter cannot be converted to an integer .
38,243
private String encodeClick ( FacesContext context , Button button ) { String js ; String userClick = button . getOnclick ( ) ; if ( userClick != null ) { js = userClick ; } else { js = "" ; } String fragment = button . getFragment ( ) ; String outcome = button . getOutcome ( ) ; if ( null != outcome && outcome . contai...
Renders the Javascript code dealing with the click event . If the developer provides their own onclick handler is precedes the generated Javascript code .
38,244
private boolean canOutcomeBeRendered ( Button button , String fragment , String outcome ) { boolean renderOutcome = true ; if ( null == outcome && button . getAttributes ( ) != null && button . getAttributes ( ) . containsKey ( "ng-click" ) ) { String ngClick = ( String ) button . getAttributes ( ) . get ( "ng-click" )...
Do we have to suppress the target URL?
38,245
private String determineTargetURL ( FacesContext context , Button button , String outcome ) { ConfigurableNavigationHandler cnh = ( ConfigurableNavigationHandler ) context . getApplication ( ) . getNavigationHandler ( ) ; NavigationCase navCase = cnh . getNavigationCase ( context , null , outcome ) ; if ( navCase == nu...
Translate the outcome attribute value to the target URL .
38,246
private static String getStyleClasses ( Button button , boolean isResponsive ) { StringBuilder sb ; sb = new StringBuilder ( 40 ) ; sb . append ( "btn" ) ; String size = button . getSize ( ) ; if ( size != null ) { sb . append ( " btn-" ) . append ( size ) ; } String look = button . getLook ( ) ; if ( look != null ) { ...
Collects the CSS classes of the button .
38,247
public List < UIComponent > resolve ( UIComponent component , List < UIComponent > parentComponents , String currentId , String originalExpression , String [ ] parameters ) { List < UIComponent > result = new ArrayList < UIComponent > ( ) ; for ( UIComponent parent : parentComponents ) { UIComponent grandparent = compo...
Collects everything preceding the current JSF node within the same branch of the tree . It s like
38,248
public void encodeEnd ( FacesContext context , UIComponent component ) throws IOException { if ( ! component . isRendered ( ) ) { return ; } PanelGrid panelGrid = ( PanelGrid ) component ; ResponseWriter writer = context . getResponseWriter ( ) ; boolean idHasBeenRendered = false ; String responsiveStyle = Responsive ....
Renders the grid component and its children .
38,249
protected String [ ] getRowClasses ( PanelGrid grid ) { String rowClasses = grid . getRowClasses ( ) ; if ( null == rowClasses || rowClasses . trim ( ) . length ( ) == 0 ) return null ; String [ ] rows = rowClasses . split ( "," ) ; return rows ; }
Extract the option row classes from the JSF file .
38,250
protected int [ ] getColSpanArray ( PanelGrid panelGrid ) { String columnsCSV = panelGrid . getColSpans ( ) ; if ( null == columnsCSV || columnsCSV . trim ( ) . length ( ) == 0 ) { columnsCSV = panelGrid . getColumns ( ) ; if ( "1" . equals ( columnsCSV ) ) { columnsCSV = "12" ; } else if ( "2" . equals ( columnsCSV ) ...
Read the colSpans attribute .
38,251
protected String [ ] getColumnClasses ( PanelGrid panelGrid , int [ ] colSpans ) { String columnsCSV = panelGrid . getColumnClasses ( ) ; String [ ] columnClasses ; if ( null == columnsCSV || columnsCSV . trim ( ) . length ( ) == 0 ) columnClasses = null ; else { columnClasses = columnsCSV . split ( "," ) ; if ( column...
Merge the column span information and the optional columnClasses attribute .
38,252
protected void generateColumnStart ( UIComponent child , String colStyleClass , ResponseWriter writer ) throws IOException { writer . startElement ( "div" , child ) ; writer . writeAttribute ( "class" , colStyleClass , "class" ) ; }
Generates the start of each Bootstrap column .
38,253
protected void generateRowStart ( ResponseWriter writer , int row , String [ ] rowClasses , PanelGrid panelGrid ) throws IOException { writer . startElement ( "div" , panelGrid ) ; if ( null == rowClasses ) writer . writeAttribute ( "class" , "row" , "class" ) ; else writer . writeAttribute ( "class" , "row " + rowClas...
Generates the start of each Bootstrap row .
38,254
protected void generateContainerStart ( ResponseWriter writer , PanelGrid panelGrid , boolean idHasBeenRendered ) throws IOException { writer . startElement ( "div" , panelGrid ) ; if ( ! idHasBeenRendered ) { String clientId = panelGrid . getClientId ( ) ; writer . writeAttribute ( "id" , clientId , "id" ) ; } writeAt...
Generates the start of the entire Bootstrap container .
38,255
protected void renderInputTag ( FacesContext context , ResponseWriter rw , String clientId , SelectBooleanCheckbox selectBooleanCheckbox ) throws IOException { int numberOfDivs = 0 ; String responsiveStyleClass = Responsive . getResponsiveStyleClass ( selectBooleanCheckbox , false ) . trim ( ) ; if ( responsiveStyleCla...
Renders the input tag .
38,256
protected void renderInputTagEnd ( ResponseWriter rw , SelectBooleanCheckbox selectBooleanCheckbox ) throws IOException { rw . endElement ( "input" ) ; String caption = selectBooleanCheckbox . getCaption ( ) ; if ( null != caption ) { if ( selectBooleanCheckbox . isEscape ( ) ) { rw . writeText ( " " + caption , null )...
Closes the input tag . This method is protected in order to allow third - party frameworks to derive from it .
38,257
protected void renderInputTagValue ( FacesContext context , ResponseWriter rw , SelectBooleanCheckbox selectBooleanCheckbox ) throws IOException { String v = getValue2Render ( context , selectBooleanCheckbox ) ; if ( v != null && "true" . equals ( v ) ) { rw . writeAttribute ( "checked" , v , null ) ; } }
Renders the value of the input tag . This method is protected in order to allow third - party frameworks to derive from it .
38,258
public void setMask ( String mask ) { if ( mask != null && ! mask . isEmpty ( ) ) { AddResourcesListener . addResourceToHeadButAfterJQuery ( C . BSF_LIBRARY , "js/jquery.inputmask.bundle.min.js" ) ; } getStateHelper ( ) . put ( PropertyKeys . mask , mask ) ; }
Sets input mask and triggers JavaScript to be loaded .
38,259
private static String getStyleClasses ( AbstractNavLink link , boolean isResponsive ) { StringBuilder sb ; sb = new StringBuilder ( 20 ) ; String look = null ; if ( link instanceof Link ) { look = ( ( Link ) link ) . getLook ( ) ; } else if ( link instanceof CommandLink ) { look = ( ( CommandLink ) link ) . getLook ( )...
Collects the CSS classes of the link .
38,260
public static boolean isValued ( Object obj ) { if ( obj == null ) return false ; if ( obj instanceof String ) return isStringValued ( ( String ) obj ) ; return true ; }
Check if a generic object is valued
38,261
public static String stringOrDefault ( String str , String defaultValue ) { if ( isStringValued ( str ) ) return str ; return defaultValue ; }
Get the string if is not null or empty otherwise return the default value
38,262
public static String snakeCaseToCamelCase ( String snakeCase ) { if ( snakeCase . contains ( "-" ) ) { StringBuilder camelCaseStr = new StringBuilder ( snakeCase . length ( ) ) ; boolean toUpperCase = false ; for ( char c : snakeCase . toCharArray ( ) ) { if ( c == '-' ) toUpperCase = true ; else { if ( toUpperCase ) {...
Transform a snake - case string to a camel - case one .
38,263
public static String camelCaseToSnakeCase ( String camelCase ) { if ( null == camelCase || camelCase . length ( ) == 0 ) return camelCase ; StringBuilder snakeCase = new StringBuilder ( camelCase . length ( ) + 3 ) ; snakeCase . append ( camelCase . charAt ( 0 ) ) ; boolean hasCamelCase = false ; for ( int i = 1 ; i < ...
Transform a snake - case string to a camelCase one .
38,264
public static String escapeHtml ( String htmlString ) { StringBuffer sb = new StringBuffer ( htmlString . length ( ) ) ; boolean lastWasBlankChar = false ; int len = htmlString . length ( ) ; char c ; for ( int i = 0 ; i < len ; i ++ ) { c = htmlString . charAt ( i ) ; if ( c == ' ' ) { if ( lastWasBlankChar ) { lastWa...
Escape html special chars from string
38,265
public static String escapeJQuerySpecialCharsInSelector ( String selector ) { String jQuerySpecialChars = "!\"#$%&'()*+,./:;<=>?@[]^`{|}~;" ; String [ ] jsc = jQuerySpecialChars . split ( "(?!^)" ) ; for ( String c : jsc ) { selector = selector . replace ( c , "\\\\" + c ) ; } return selector ; }
Escape special jQuery chars in selector query
38,266
public static UIForm getClosestForm ( UIComponent component ) { while ( component != null ) { if ( component instanceof UIForm ) { return ( UIForm ) component ; } component = component . getParent ( ) ; } return null ; }
Get the related form
38,267
public static String getComponentClientId ( final String componentId ) { FacesContext context = FacesContext . getCurrentInstance ( ) ; UIViewRoot root = context . getViewRoot ( ) ; UIComponent c = findComponent ( root , componentId ) ; if ( c == null ) { return null ; } return c . getClientId ( context ) ; }
Returns the clientId for a component with id = foo .
38,268
public static UIComponent findComponent ( UIComponent c , String id ) { if ( id . equals ( c . getId ( ) ) ) { return c ; } Iterator < UIComponent > kids = c . getFacetsAndChildren ( ) ; while ( kids . hasNext ( ) ) { UIComponent found = findComponent ( kids . next ( ) , id ) ; if ( found != null ) { return found ; } }...
Finds component with the given id
38,269
public static String getInitParam ( String param , FacesContext context ) { return context . getExternalContext ( ) . getInitParameter ( param ) ; }
Shortcut for getting context parameters using an already obtained FacesContext .
38,270
public static String resolveSearchExpressions ( String refItem ) { if ( refItem != null ) { if ( refItem . contains ( "@" ) || refItem . contains ( "*" ) ) { refItem = ExpressionResolver . getComponentIDs ( FacesContext . getCurrentInstance ( ) , FacesContext . getCurrentInstance ( ) . getViewRoot ( ) , refItem ) ; } }...
Resolve the search expression
38,271
public static boolean isLegacyFeedbackClassesEnabled ( ) { String legacyErrorClasses = getInitParam ( "net.bootsfaces.legacy_error_classes" ) ; legacyErrorClasses = evalELIfPossible ( legacyErrorClasses ) ; return legacyErrorClasses . equalsIgnoreCase ( "true" ) || legacyErrorClasses . equalsIgnoreCase ( "yes" ) ; }
It checks where the framework should place BS feedback classes .
38,272
private void encodeDefaultLanguageJS ( FacesContext fc ) throws IOException { ResponseWriter rw = fc . getResponseWriter ( ) ; rw . startElement ( "script" , null ) ; rw . write ( "$.datepicker.setDefaults($.datepicker.regional['" + fc . getViewRoot ( ) . getLocale ( ) . getLanguage ( ) + "']);" ) ; rw . endElement ( "...
Generates the default language for the date picker . Originally implemented in the HeadRenderer this code has been moved here to provide better compatibility to PrimeFaces . If multiple date pickers are on the page the script is generated redundantly but this shouldn t do no harm .
38,273
public static String convertFormat ( String format ) { if ( format == null ) return null ; else { format = format . replaceAll ( "EEE" , "D" ) ; format = format . replaceAll ( "yy" , "y" ) ; if ( format . indexOf ( "MMM" ) != - 1 ) { format = format . replaceAll ( "MMM" , "M" ) ; } else { format = format . replaceAll (...
Converts a java Date format to a jQuery date format
38,274
private static String encodeVisibility ( IResponsive r , String value , String prefix ) { if ( value == null ) return "" ; if ( "true" . equals ( value ) || "false" . equals ( value ) ) { throw new FacesException ( "The attributes 'visible' and 'hidden' don't accept boolean values. If you want to show or hide the eleme...
Encode the visible field
38,275
private static String getSize ( IResponsiveLabel r , Sizes size ) { String colSize = "-1" ; switch ( size ) { case xs : colSize = r . getLabelColXs ( ) ; if ( colSize . equals ( "-1" ) ) colSize = r . getLabelTinyScreen ( ) ; break ; case sm : colSize = r . getLabelColSm ( ) ; if ( colSize . equals ( "-1" ) ) colSize =...
Decode col sizes between two way of definition
38,276
private static int sizeToInt ( String size ) { if ( size == null ) return - 1 ; if ( "full" . equals ( size ) ) return 12 ; if ( "full-size" . equals ( size ) ) return 12 ; if ( "fullSize" . equals ( size ) ) return 12 ; if ( "full-width" . equals ( size ) ) return 12 ; if ( "fullWidth" . equals ( size ) ) return 12 ; ...
Convert the specified size to int value
38,277
private static List < String > getSizeRange ( String operation , String size ) { return getSizeRange ( operation , size , null ) ; }
Get the size ranges
38,278
public static List < String > wonderfulTokenizer ( String tokenString , String [ ] delimiters ) { List < String > tokens = new ArrayList < String > ( ) ; String currentToken = "" ; for ( int i = 0 ; i < tokenString . length ( ) ; i ++ ) { String _currItem = String . valueOf ( tokenString . charAt ( i ) ) ; if ( _currIt...
Tokenize string based on rules
38,279
public static String getResponsiveLabelClass ( IResponsiveLabel r ) { if ( ! shouldRenderResponsiveClasses ( r ) ) { return "" ; } int colxs = sizeToInt ( getSize ( r , Sizes . xs ) ) ; int colsm = sizeToInt ( getSize ( r , Sizes . sm ) ) ; int colmd = sizeToInt ( getSize ( r , Sizes . md ) ) ; int collg = sizeToInt ( ...
Create the responsive class combination
38,280
private static boolean shouldRenderResponsiveClasses ( Object r ) { if ( r instanceof UIComponent && r instanceof IResponsiveLabel ) { UIForm form = AJAXRenderer . getSurroundingForm ( ( UIComponent ) r , true ) ; if ( form instanceof Form ) { if ( ( ( Form ) form ) . isInline ( ) ) { return false ; } } } return true ;...
Temporal and ugly hack to prevent responsive classes to be applied to inputs inside inline forms .
38,281
public String getSeverityName ( Severity severity ) { if ( severity . equals ( FacesMessage . SEVERITY_INFO ) ) { return "info" ; } else if ( severity . equals ( FacesMessage . SEVERITY_WARN ) ) { return "warn" ; } else if ( severity . equals ( FacesMessage . SEVERITY_ERROR ) ) { return "error" ; } else if ( severity ....
Returns name of the given severity in lower case .
38,282
public static ValueExpression createValueExpression ( String p_expression ) { FacesContext context = FacesContext . getCurrentInstance ( ) ; ExpressionFactory expressionFactory = context . getApplication ( ) . getExpressionFactory ( ) ; ELContext elContext = context . getELContext ( ) ; ValueExpression vex = expression...
Utility method to create a JSF Value expression from the p_expression string
38,283
public static ValueExpression createValueExpression ( String p_expression , Class < ? > expectedType ) { FacesContext context = FacesContext . getCurrentInstance ( ) ; ExpressionFactory expressionFactory = context . getApplication ( ) . getExpressionFactory ( ) ; ELContext elContext = context . getELContext ( ) ; if ( ...
Utility method to create a JSF Value expression from p_expression with exprectedType class as return
38,284
public static MethodExpression createMethodExpression ( String p_expression , Class < ? > returnType , Class < ? > ... parameterTypes ) { FacesContext context = FacesContext . getCurrentInstance ( ) ; ExpressionFactory expressionFactory = context . getApplication ( ) . getExpressionFactory ( ) ; ELContext elContext = c...
Utility method to create a JSF Method expression
38,285
public static NGBeanAttributeInfo getBeanAttributeInfos ( UIComponent c ) { String core = getCoreValueExpression ( c ) ; synchronized ( beanAttributeInfos ) { if ( beanAttributeInfos . containsKey ( c ) ) { return beanAttributeInfos . get ( c ) ; } } NGBeanAttributeInfo info = new NGBeanAttributeInfo ( c ) ; synchroniz...
Get the bean attributes info
38,286
public static String getCoreValueExpression ( UIComponent component ) { ValueExpression valueExpression = component . getValueExpression ( "value" ) ; if ( null != valueExpression ) { String v = valueExpression . getExpressionString ( ) ; if ( null != v ) { Matcher matcher = EL_EXPRESSION . matcher ( v ) ; if ( matcher...
Return the core value expression of a specified component
38,287
public static Annotation [ ] readAnnotations ( UIComponent p_component ) { ValueExpression valueExpression = p_component . getValueExpression ( "value" ) ; if ( valueExpression != null && valueExpression . getExpressionString ( ) != null && valueExpression . getExpressionString ( ) . length ( ) > 0 ) { return readAnnot...
Which annotations are given to an object displayed by a JSF component?
38,288
public void processEvent ( SystemEvent event ) throws AbortProcessingException { FacesContext context = FacesContext . getCurrentInstance ( ) ; UIViewRoot root = context . getViewRoot ( ) ; if ( ensureExistBootsfacesComponent ( root , context ) ) { addCSS ( root , context ) ; addJavascript ( root , context ) ; addMetaT...
Trigger adding the resources if and only if the event has been fired by UIViewRoot .
38,289
private boolean ensureExistBootsfacesComponent ( UIViewRoot root , FacesContext context ) { Map < String , Object > viewMap = root . getViewMap ( ) ; if ( viewMap . get ( RESOURCE_KEY ) != null ) return true ; if ( viewMap . get ( THEME_RESOURCE_KEY ) != null ) return true ; if ( viewMap . get ( EXT_RESOURCE_KEY ) != n...
Check if there is almost one bootsfaces component in page . If yes load the correct items .
38,290
public static UIComponent findBsfComponent ( UIComponent parent , String targetLib ) { if ( targetLib . equalsIgnoreCase ( ( String ) parent . getAttributes ( ) . get ( "library" ) ) ) { return parent ; } Iterator < UIComponent > kids = parent . getFacetsAndChildren ( ) ; while ( kids . hasNext ( ) ) { UIComponent foun...
Check all components in page to find one that has as resource library the target library . I use this method to check existence of a BsF component because at this level the getComponentResource returns always null
38,291
private void addMetaTags ( UIViewRoot root , FacesContext context ) { String viewportParam = BsfUtils . getInitParam ( C . P_VIEWPORT , context ) ; viewportParam = evalELIfPossible ( viewportParam ) ; String content = "width=device-width, initial-scale=1" ; if ( ! viewportParam . isEmpty ( ) && isFalseOrNo ( viewportPa...
Add the viewport meta tag if not disabled from context - param
38,292
private void addCSS ( UIViewRoot root , FacesContext context ) { String theme = loadTheme ( root , context ) ; UIComponent header = findHeader ( root ) ; boolean useCDNImportForFontAwesome = ( null == header ) || ( null == header . getFacet ( "no-fa" ) ) ; if ( useCDNImportForFontAwesome ) { String useCDN = BsfUtils . ...
Add the required CSS files and the FontAwesome CDN link .
38,293
private void addJavascript ( UIViewRoot root , FacesContext context ) { boolean loadJQuery = shouldLibraryBeLoaded ( P_GET_JQUERY_FROM_CDN , true ) ; boolean loadJQueryUI = shouldLibraryBeLoaded ( P_GET_JQUERYUI_FROM_CDN , true ) ; List < UIComponent > availableResources = root . getComponentResources ( context , "head...
Add the required Javascript files and the FontAwesome CDN link .
38,294
private void removeDuplicateResources ( UIViewRoot root , FacesContext context ) { List < UIComponent > resourcesToRemove = new ArrayList < UIComponent > ( ) ; Map < String , UIComponent > alreadyThere = new HashMap < String , UIComponent > ( ) ; List < UIComponent > components = new ArrayList < UIComponent > ( root . ...
Remove duplicate resource files . For some reason many resource files are added more than once especially when AJAX is used . The method removes the duplicate files .
38,295
private void enforceCorrectLoadOrder ( UIViewRoot root , FacesContext context ) { List < UIComponent > resources = new ArrayList < UIComponent > ( ) ; List < UIComponent > first = new ArrayList < UIComponent > ( ) ; List < UIComponent > middle = new ArrayList < UIComponent > ( ) ; List < UIComponent > last = new ArrayL...
Make sure jQuery is loaded before jQueryUI and that every other Javascript is loaded later . Also make sure that the BootsFaces resource files are loaded prior to other resource files giving the developer the opportunity to overwrite a CSS or JS file .
38,296
private UIComponent findHeader ( UIViewRoot root ) { for ( UIComponent c : root . getChildren ( ) ) { if ( c instanceof HtmlHead ) return c ; } for ( UIComponent c : root . getChildren ( ) ) { if ( c instanceof HtmlBody ) return null ; if ( c instanceof UIOutput ) if ( c . getFacets ( ) != null ) return c ; } return nu...
Looks for the header in the JSF tree .
38,297
public static void addResourceToHeadButAfterJQuery ( String library , String resource ) { addResource ( resource , library , library + "#" + resource , RESOURCE_KEY ) ; }
Registers a JS file that needs to be included in the header of the HTML file but after jQuery and AngularJS .
38,298
public static void addBasicJSResource ( String library , String resource ) { addResource ( resource , library , resource , BASIC_JS_RESOURCE_KEY ) ; }
Registers a core JS file that needs to be included in the header of the HTML file but after jQuery and AngularJS .
38,299
public static void addThemedCSSResource ( String resource ) { Map < String , Object > viewMap = FacesContext . getCurrentInstance ( ) . getViewRoot ( ) . getViewMap ( ) ; @ SuppressWarnings ( "unchecked" ) List < String > resourceList = ( List < String > ) viewMap . get ( THEME_RESOURCE_KEY ) ; if ( null == resourceLis...
Registers a themed CSS file that needs to be included in the header of the HTML file .