idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
32,500
public String encode ( ) throws IOException { FastStringWriter fsw = new FastStringWriter ( ) ; try { ChartUtils . writeDataValue ( fsw , "borderWidth" , this . borderWidth , false ) ; ChartUtils . writeDataValue ( fsw , "backgroundColor" , this . backgroundColor , true ) ; ChartUtils . writeDataValue ( fsw , "borderColor" , this . borderColor , true ) ; } finally { fsw . close ( ) ; } return fsw . toString ( ) ; }
Write the arc options of Elements
32,501
public TreeNode setSibling ( int index , TreeNode node ) { if ( node == null ) { throw new NullPointerException ( ) ; } else if ( ( index < 0 ) || ( index >= size ( ) ) ) { throw new IndexOutOfBoundsException ( ) ; } else { if ( ! parent . equals ( node . getParent ( ) ) ) { eraseParent ( node ) ; } TreeNode previous = get ( index ) ; super . set ( index , node ) ; node . setParent ( parent ) ; updateRowKeys ( parent ) ; updateSelectionState ( parent ) ; return previous ; } }
Optimized set implementation to be used in sorting
32,502
public static long toLocalDate ( TimeZone browserTZ , TimeZone targetTZ , Date utcDate ) { long utc = utcDate . getTime ( ) ; int targetOffsetFromUTC = targetTZ . getOffset ( utc ) ; int browserOffsetFromUTC = browserTZ . getOffset ( utc ) ; return utc + targetOffsetFromUTC - browserOffsetFromUTC ; }
convert from UTC to local date
32,503
protected void renderARIARequired ( FacesContext context , UIInput component ) throws IOException { if ( component . isRequired ( ) ) { ResponseWriter writer = context . getResponseWriter ( ) ; writer . writeAttribute ( HTML . ARIA_REQUIRED , "true" , null ) ; } }
Adds aria - required if the component is required .
32,504
protected void renderARIAInvalid ( FacesContext context , UIInput component ) throws IOException { if ( ! component . isValid ( ) ) { ResponseWriter writer = context . getResponseWriter ( ) ; writer . writeAttribute ( HTML . ARIA_INVALID , "true" , null ) ; } }
Adds aria - invalid if the component is invalid .
32,505
protected void renderARIACombobox ( FacesContext context , UIInput component ) throws IOException { ResponseWriter writer = context . getResponseWriter ( ) ; writer . writeAttribute ( "role" , "combobox" , null ) ; writer . writeAttribute ( HTML . ARIA_HASPOPUP , "true" , null ) ; writer . writeAttribute ( HTML . ARIA_EXPANDED , "false" , null ) ; }
Adds ARIA attributes if the component is role = combobox .
32,506
public void focus ( String expression , UIComponent base ) { if ( LangUtils . isValueBlank ( expression ) ) { return ; } FacesContext facesContext = getFacesContext ( ) ; String clientId = SearchExpressionFacade . resolveClientId ( facesContext , base , expression ) ; executeScript ( "PrimeFaces.focus('" + clientId + "');" ) ; }
Resolves the search expression and focus the resolved component .
32,507
public void clearTableState ( String key ) { Map < String , Object > sessionMap = getFacesContext ( ) . getExternalContext ( ) . getSessionMap ( ) ; Map < String , TableState > dtState = ( Map ) sessionMap . get ( Constants . TABLE_STATE ) ; if ( dtState != null ) { dtState . remove ( key ) ; } }
Removes the multiViewState for one specific DataTable within the current session .
32,508
public void clearDataListState ( String key ) { Map < String , Object > sessionMap = getFacesContext ( ) . getExternalContext ( ) . getSessionMap ( ) ; Map < String , TableState > dtState = ( Map ) sessionMap . get ( Constants . DATALIST_STATE ) ; if ( dtState != null ) { dtState . remove ( key ) ; } }
Removes the multiViewState for one specific DataList within the current session .
32,509
public String encode ( ) throws IOException { FastStringWriter fsw = new FastStringWriter ( ) ; try { ChartUtils . writeDataValue ( fsw , "enabled" , this . enabled , false ) ; ChartUtils . writeDataValue ( fsw , "mode" , this . mode , true ) ; ChartUtils . writeDataValue ( fsw , "intersect" , this . intersect , true ) ; ChartUtils . writeDataValue ( fsw , "position" , this . position , true ) ; ChartUtils . writeDataValue ( fsw , "backgroundColor" , this . backgroundColor , true ) ; ChartUtils . writeDataValue ( fsw , "titleFontFamily" , this . titleFontFamily , true ) ; ChartUtils . writeDataValue ( fsw , "titleFontSize" , this . titleFontSize , true ) ; ChartUtils . writeDataValue ( fsw , "titleFontStyle" , this . titleFontStyle , true ) ; ChartUtils . writeDataValue ( fsw , "titleFontColor" , this . titleFontColor , true ) ; ChartUtils . writeDataValue ( fsw , "titleSpacing" , this . titleSpacing , true ) ; ChartUtils . writeDataValue ( fsw , "titleMarginBottom" , this . titleMarginBottom , true ) ; ChartUtils . writeDataValue ( fsw , "bodyFontFamily" , this . bodyFontFamily , true ) ; ChartUtils . writeDataValue ( fsw , "bodyFontSize" , this . bodyFontSize , true ) ; ChartUtils . writeDataValue ( fsw , "bodyFontStyle" , this . bodyFontStyle , true ) ; ChartUtils . writeDataValue ( fsw , "bodyFontColor" , this . bodyFontColor , true ) ; ChartUtils . writeDataValue ( fsw , "bodySpacing" , this . bodySpacing , true ) ; ChartUtils . writeDataValue ( fsw , "footerFontFamily" , this . footerFontFamily , true ) ; ChartUtils . writeDataValue ( fsw , "footerFontSize" , this . footerFontSize , true ) ; ChartUtils . writeDataValue ( fsw , "footerFontStyle" , this . footerFontStyle , true ) ; ChartUtils . writeDataValue ( fsw , "footerFontColor" , this . footerFontColor , true ) ; ChartUtils . writeDataValue ( fsw , "footerSpacing" , this . footerSpacing , true ) ; ChartUtils . writeDataValue ( fsw , "footerMarginTop" , this . footerMarginTop , true ) ; ChartUtils . writeDataValue ( fsw , "xPadding" , this . xpadding , true ) ; ChartUtils . writeDataValue ( fsw , "yPadding" , this . ypadding , true ) ; ChartUtils . writeDataValue ( fsw , "caretPadding" , this . caretPadding , true ) ; ChartUtils . writeDataValue ( fsw , "caretSize" , this . caretSize , true ) ; ChartUtils . writeDataValue ( fsw , "cornerRadius" , this . cornerRadius , true ) ; ChartUtils . writeDataValue ( fsw , "multiKeyBackground" , this . multiKeyBackground , true ) ; ChartUtils . writeDataValue ( fsw , "displayColors" , this . displayColors , true ) ; ChartUtils . writeDataValue ( fsw , "borderColor" , this . borderColor , true ) ; ChartUtils . writeDataValue ( fsw , "borderWidth" , this . borderWidth , true ) ; } finally { fsw . close ( ) ; } return fsw . toString ( ) ; }
Write the options of Tooltip
32,510
public static Converter getConverter ( FacesContext context , UIComponent component ) { if ( ! ( component instanceof ValueHolder ) ) { return null ; } Converter converter = ( ( ValueHolder ) component ) . getConverter ( ) ; if ( converter != null ) { return converter ; } ValueExpression valueExpression = component . getValueExpression ( "value" ) ; if ( valueExpression == null ) { return null ; } Class < ? > converterType = valueExpression . getType ( context . getELContext ( ) ) ; if ( converterType == null || converterType == Object . class ) { return null ; } if ( converterType == String . class && ! PrimeApplicationContext . getCurrentInstance ( context ) . getConfig ( ) . isStringConverterAvailable ( ) ) { return null ; } return context . getApplication ( ) . createConverter ( converterType ) ; }
Finds appropriate converter for a given value holder
32,511
public static String calculateViewId ( FacesContext context ) { Map < String , Object > requestMap = context . getExternalContext ( ) . getRequestMap ( ) ; String viewId = ( String ) requestMap . get ( "javax.servlet.include.path_info" ) ; if ( viewId == null ) { viewId = context . getExternalContext ( ) . getRequestPathInfo ( ) ; } if ( viewId == null ) { viewId = ( String ) requestMap . get ( "javax.servlet.include.servlet_path" ) ; } if ( viewId == null ) { viewId = context . getExternalContext ( ) . getRequestServletPath ( ) ; } return viewId ; }
Calculates the current viewId - we can t get it from the ViewRoot if it s not available .
32,512
public static boolean shouldRenderFacet ( UIComponent facet ) { if ( facet == null || ! facet . isRendered ( ) ) { return false ; } if ( facet . getChildren ( ) . isEmpty ( ) ) { return true ; } return shouldRenderChildren ( facet ) ; }
Checks if the facet and one of the first level child s is rendered .
32,513
public static boolean shouldRenderChildren ( UIComponent component ) { for ( int i = 0 ; i < component . getChildren ( ) . size ( ) ; i ++ ) { if ( component . getChildren ( ) . get ( i ) . isRendered ( ) ) { return true ; } } return false ; }
Checks if the component s children are rendered
32,514
private void setRowIndexRowStatePreserved ( int rowIndex ) { if ( rowIndex < - 1 ) { throw new IllegalArgumentException ( "rowIndex is less than -1" ) ; } if ( getRowIndex ( ) == rowIndex ) { return ; } FacesContext facesContext = getFacesContext ( ) ; if ( _initialDescendantFullComponentState != null ) { Map < String , Object > sm = saveFullDescendantComponentStates ( facesContext , null , getChildren ( ) . iterator ( ) , false ) ; if ( sm != null && ! sm . isEmpty ( ) ) { _rowDeltaStates . put ( getContainerClientId ( facesContext ) , sm ) ; } if ( getRowIndex ( ) != - 1 ) { _rowTransientStates . put ( getContainerClientId ( facesContext ) , saveTransientDescendantComponentStates ( facesContext , null , getChildren ( ) . iterator ( ) , false ) ) ; } } getStateHelper ( ) . put ( PropertyKeys . rowIndex , rowIndex ) ; DataModel localModel = getDataModel ( ) ; localModel . setRowIndex ( rowIndex ) ; if ( rowIndex == - 1 ) { setDataModel ( null ) ; } String var = getVar ( ) ; if ( var != null ) { Map < String , Object > requestMap = getFacesContext ( ) . getExternalContext ( ) . getRequestMap ( ) ; if ( rowIndex == - 1 ) { oldVar = requestMap . remove ( var ) ; } else if ( isRowAvailable ( ) ) { requestMap . put ( var , getRowData ( ) ) ; } else { requestMap . remove ( var ) ; if ( null != oldVar ) { requestMap . put ( var , oldVar ) ; oldVar = null ; } } } if ( _initialDescendantFullComponentState != null ) { Object rowState = _rowDeltaStates . get ( getContainerClientId ( facesContext ) ) ; if ( rowState == null ) { restoreFullDescendantComponentStates ( facesContext , getChildren ( ) . iterator ( ) , _initialDescendantFullComponentState , false ) ; } else { restoreFullDescendantComponentDeltaStates ( facesContext , getChildren ( ) . iterator ( ) , rowState , _initialDescendantFullComponentState , false ) ; } if ( getRowIndex ( ) == - 1 ) { restoreTransientDescendantComponentStates ( facesContext , getChildren ( ) . iterator ( ) , null , false ) ; } else { rowState = _rowTransientStates . get ( getContainerClientId ( facesContext ) ) ; if ( rowState == null ) { restoreTransientDescendantComponentStates ( facesContext , getChildren ( ) . iterator ( ) , null , false ) ; } else { restoreTransientDescendantComponentStates ( facesContext , getChildren ( ) . iterator ( ) , ( Map < String , Object > ) rowState , false ) ; } } } }
Row State preserved implementation is taken from Mojarra
32,515
public static void sortNode ( TreeNode node , Comparator comparator ) { TreeNodeList children = ( TreeNodeList ) node . getChildren ( ) ; if ( children != null && ! children . isEmpty ( ) ) { Object [ ] childrenArray = children . toArray ( ) ; Arrays . sort ( childrenArray , comparator ) ; for ( int i = 0 ; i < childrenArray . length ; i ++ ) { children . setSibling ( i , ( TreeNode ) childrenArray [ i ] ) ; } for ( int i = 0 ; i < children . size ( ) ; i ++ ) { sortNode ( children . get ( i ) , comparator ) ; } } }
Sorts children of a node using a comparator
32,516
public static void firstById ( String id , UIComponent base , char separatorChar , FacesContext context , ContextCallback callback ) { UIComponent component = base . findComponent ( id ) ; if ( component == null ) { String tempExpression = id ; if ( tempExpression . charAt ( 0 ) == separatorChar ) { tempExpression = tempExpression . substring ( 1 ) ; } context . getViewRoot ( ) . invokeOnComponent ( context , tempExpression , callback ) ; } else { callback . invokeContextCallback ( context , component ) ; } }
Finds the first component by the given id expression or client id .
32,517
public static String [ ] split ( FacesContext context , String value , char ... separators ) { if ( LangUtils . isValueBlank ( value ) ) { return null ; } List < String > tokens = new ArrayList < > ( 5 ) ; StringBuilder buffer = SharedStringBuilder . get ( context , SHARED_SPLIT_BUFFER_KEY ) ; int parenthesesCounter = 0 ; int length = value . length ( ) ; for ( int i = 0 ; i < length ; i ++ ) { char c = value . charAt ( i ) ; if ( c == '(' ) { parenthesesCounter ++ ; } if ( c == ')' ) { parenthesesCounter -- ; } if ( parenthesesCounter == 0 ) { boolean isSeparator = false ; for ( char separator : separators ) { if ( c == separator ) { isSeparator = true ; } } if ( isSeparator ) { tokens . add ( buffer . toString ( ) ) ; buffer . delete ( 0 , buffer . length ( ) ) ; } else { buffer . append ( c ) ; } } else { buffer . append ( c ) ; } } tokens . add ( buffer . toString ( ) ) ; return tokens . toArray ( new String [ tokens . size ( ) ] ) ; }
Splits the given string by the given separator but ignoring separators inside parentheses .
32,518
public String encode ( ) throws IOException { FastStringWriter fsw = new FastStringWriter ( ) ; boolean hasComma = false ; String preString ; try { if ( this . point != null ) { fsw . write ( "\"point\":{" ) ; fsw . write ( this . point . encode ( ) ) ; fsw . write ( "}" ) ; hasComma = true ; } if ( this . line != null ) { preString = hasComma ? "," : "" ; fsw . write ( preString + "\"line\":{" ) ; fsw . write ( this . line . encode ( ) ) ; fsw . write ( "}" ) ; hasComma = true ; } if ( this . rectangle != null ) { preString = hasComma ? "," : "" ; fsw . write ( preString + "\"rectangle\":{" ) ; fsw . write ( this . rectangle . encode ( ) ) ; fsw . write ( "}" ) ; hasComma = true ; } if ( this . arc != null ) { preString = hasComma ? "," : "" ; fsw . write ( preString + "\"arc\":{" ) ; fsw . write ( this . arc . encode ( ) ) ; fsw . write ( "}" ) ; } } finally { fsw . close ( ) ; } return fsw . toString ( ) ; }
Write the options of Elements
32,519
private void saveInitialChildState ( FacesContext facesContext , UIComponent component ) { if ( component instanceof EditableValueHolder && ! component . isTransient ( ) ) { String clientId = component . getClientId ( facesContext ) ; SavedState state = new SavedState ( ) ; initialChildState . put ( clientId , state ) ; state . populate ( ( EditableValueHolder ) component ) ; } Iterator < UIComponent > iterator = component . getFacetsAndChildren ( ) ; while ( iterator . hasNext ( ) ) { saveChildState ( facesContext , iterator . next ( ) ) ; } }
Recursively create the initial state for the given component .
32,520
public String encode ( ) throws IOException { FastStringWriter fsw = new FastStringWriter ( ) ; try { fsw . write ( super . encode ( ) ) ; ChartUtils . writeDataValue ( fsw , "beginAtZero" , this . beginAtZero , true ) ; ChartUtils . writeDataValue ( fsw , "min" , this . min , true ) ; ChartUtils . writeDataValue ( fsw , "max" , this . max , true ) ; ChartUtils . writeDataValue ( fsw , "maxTicksLimit" , this . maxTicksLimit , true ) ; ChartUtils . writeDataValue ( fsw , "precision" , this . precision , true ) ; ChartUtils . writeDataValue ( fsw , "stepSize" , this . stepSize , true ) ; ChartUtils . writeDataValue ( fsw , "suggestedMax" , this . suggestedMax , true ) ; ChartUtils . writeDataValue ( fsw , "suggestedMin" , this . suggestedMin , true ) ; } finally { fsw . close ( ) ; } return fsw . toString ( ) ; }
Write the options of cartesian linear ticks
32,521
public String encode ( ) throws IOException { FastStringWriter fsw = new FastStringWriter ( ) ; try { fsw . write ( "{" ) ; ChartUtils . writeDataValue ( fsw , "fontSize" , this . fontSize , false ) ; ChartUtils . writeDataValue ( fsw , "fontColor" , this . fontColor , true ) ; ChartUtils . writeDataValue ( fsw , "fontFamily" , this . fontFamily , true ) ; ChartUtils . writeDataValue ( fsw , "fontStyle" , this . fontStyle , true ) ; fsw . write ( "}" ) ; } finally { fsw . close ( ) ; } return fsw . toString ( ) ; }
Write the options of point labels on radial linear type
32,522
public String encode ( ) throws IOException { FastStringWriter fsw = new FastStringWriter ( ) ; try { ChartUtils . writeDataValue ( fsw , "autoSkip" , this . autoSkip , false ) ; ChartUtils . writeDataValue ( fsw , "autoSkipPadding" , this . autoSkipPadding , true ) ; ChartUtils . writeDataValue ( fsw , "labelOffset" , this . labelOffset , true ) ; ChartUtils . writeDataValue ( fsw , "maxRotation" , this . maxRotation , true ) ; ChartUtils . writeDataValue ( fsw , "minRotation" , this . minRotation , true ) ; ChartUtils . writeDataValue ( fsw , "mirror" , this . mirror , true ) ; ChartUtils . writeDataValue ( fsw , "padding" , this . padding , true ) ; } finally { fsw . close ( ) ; } return fsw . toString ( ) ; }
Write the common ticks options
32,523
public boolean isSecure ( ) { Object request = context . getExternalContext ( ) . getRequest ( ) ; if ( request instanceof HttpServletRequest ) { return ( ( HttpServletRequest ) request ) . isSecure ( ) ; } else { try { Method method = request . getClass ( ) . getDeclaredMethod ( "isSecure" , new Class [ 0 ] ) ; return ( Boolean ) method . invoke ( request , ( Object [ ] ) null ) ; } catch ( Exception e ) { return false ; } } }
Returns a boolean indicating whether this request was made using a secure channel such as HTTPS .
32,524
public String encode ( ) throws IOException { FastStringWriter fsw = new FastStringWriter ( ) ; try { ChartUtils . writeDataValue ( fsw , "radius" , this . radius , false ) ; ChartUtils . writeDataValue ( fsw , "pointStyle" , this . pointStyle , true ) ; ChartUtils . writeDataValue ( fsw , "backgroundColor" , this . backgroundColor , true ) ; ChartUtils . writeDataValue ( fsw , "borderWidth" , this . borderWidth , true ) ; ChartUtils . writeDataValue ( fsw , "borderColor" , this . borderColor , true ) ; ChartUtils . writeDataValue ( fsw , "hitRadius" , this . hitRadius , true ) ; ChartUtils . writeDataValue ( fsw , "hoverRadius" , this . hoverRadius , true ) ; ChartUtils . writeDataValue ( fsw , "hoverBorderWidth" , this . hoverBorderWidth , true ) ; } finally { fsw . close ( ) ; } return fsw . toString ( ) ; }
Write the point options of Elements
32,525
public static TimelineUpdater getCurrentInstance ( String id ) { FacesContext fc = FacesContext . getCurrentInstance ( ) ; @ SuppressWarnings ( "unchecked" ) Map < String , TimelineUpdater > map = ( Map < String , TimelineUpdater > ) fc . getAttributes ( ) . get ( TimelineUpdater . class . getName ( ) ) ; if ( map == null ) { return null ; } UIComponent timeline = fc . getViewRoot ( ) . findComponent ( id ) ; if ( timeline == null || ! ( timeline instanceof Timeline ) ) { throw new FacesException ( "Timeline component with Id " + id + " was not found" ) ; } TimelineUpdater timelineUpdater = map . get ( ( ( Timeline ) timeline ) . resolveWidgetVar ( ) ) ; if ( timelineUpdater != null ) { timelineUpdater . id = id ; } return timelineUpdater ; }
Gets the current thread - safe TimelineUpdater instance by Id .
32,526
public String encode ( ) throws IOException { FastStringWriter fsw = new FastStringWriter ( ) ; try { fsw . write ( super . encode ( ) ) ; ChartUtils . writeDataValue ( fsw , "labels" , this . labels , true ) ; ChartUtils . writeDataValue ( fsw , "min" , this . min , true ) ; ChartUtils . writeDataValue ( fsw , "max" , this . max , true ) ; } finally { fsw . close ( ) ; } return fsw . toString ( ) ; }
Write the options of cartesian category ticks
32,527
private String encodeDate ( TimeZone browserTZ , TimeZone targetTZ , Date utcDate ) { return "new Date(" + DateUtils . toLocalDate ( browserTZ , targetTZ , utcDate ) + ")" ; }
convert from UTC to locale date
32,528
protected Throwable buildView ( FacesContext context , Throwable throwable , Throwable rootCause ) throws IOException { if ( context . getViewRoot ( ) == null ) { ViewHandler viewHandler = context . getApplication ( ) . getViewHandler ( ) ; String viewId = viewHandler . deriveViewId ( context , ComponentUtils . calculateViewId ( context ) ) ; ViewDeclarationLanguage vdl = viewHandler . getViewDeclarationLanguage ( context , viewId ) ; UIViewRoot viewRoot = vdl . createView ( context , viewId ) ; context . setViewRoot ( viewRoot ) ; vdl . buildView ( context , viewRoot ) ; if ( rootCause == null && throwable instanceof IllegalArgumentException ) { rootCause = new javax . faces . application . ViewExpiredException ( viewId ) ; } } return rootCause ; }
Builds the view if not already available . This is mostly required for ViewExpiredException s .
32,529
public void addGroup ( TimelineGroup group ) { if ( groups == null ) { groups = new ArrayList < > ( ) ; } groups . add ( group ) ; }
Adds a given group to the model .
32,530
public void add ( TimelineEvent event , TimelineUpdater timelineUpdater ) { events . add ( event ) ; if ( timelineUpdater != null ) { timelineUpdater . add ( event ) ; } }
Adds a given event to the model with UI update .
32,531
public void addAllGroups ( Collection < TimelineGroup > groups ) { if ( groups == null ) { groups = new ArrayList < > ( ) ; } groups . addAll ( groups ) ; }
Adds all given groups to the model .
32,532
public void addAll ( Collection < TimelineEvent > events , TimelineUpdater timelineUpdater ) { if ( events != null && ! events . isEmpty ( ) ) { for ( TimelineEvent event : events ) { add ( event , timelineUpdater ) ; } } }
Adds all given events to the model with UI update .
32,533
public void update ( TimelineEvent event , TimelineUpdater timelineUpdater ) { int index = getIndex ( event ) ; if ( index >= 0 ) { events . set ( index , event ) ; if ( timelineUpdater != null ) { timelineUpdater . update ( event , index ) ; } } }
Updates a given event in the model with UI update .
32,534
public void updateAll ( Collection < TimelineEvent > events , TimelineUpdater timelineUpdater ) { if ( events != null && ! events . isEmpty ( ) ) { for ( TimelineEvent event : events ) { update ( event , timelineUpdater ) ; } } }
Updates all given events in the model with UI update .
32,535
public void delete ( TimelineEvent event , TimelineUpdater timelineUpdater ) { int index = getIndex ( event ) ; if ( index >= 0 ) { events . remove ( event ) ; if ( timelineUpdater != null ) { timelineUpdater . delete ( index ) ; } } }
Deletes a given event in the model with UI update .
32,536
public void deleteAll ( Collection < TimelineEvent > events , TimelineUpdater timelineUpdater ) { if ( events != null && ! events . isEmpty ( ) ) { for ( TimelineEvent event : events ) { delete ( event , timelineUpdater ) ; } } }
Deletes all given events in the model with UI update .
32,537
public void select ( TimelineEvent event , TimelineUpdater timelineUpdater ) { int index = getIndex ( event ) ; if ( timelineUpdater != null ) { timelineUpdater . select ( index ) ; } }
Selects a given event in UI visually . To unselect all events pass a null as event .
32,538
public TreeSet < TimelineEvent > getOverlappedEvents ( TimelineEvent event ) { if ( event == null ) { return null ; } List < TimelineEvent > overlappedEvents = null ; for ( TimelineEvent e : events ) { if ( e . equals ( event ) ) { continue ; } if ( event . getGroup ( ) == null && e . getGroup ( ) != null || ( event . getGroup ( ) != null && ! event . getGroup ( ) . equals ( e . getGroup ( ) ) ) ) { continue ; } if ( isOverlapping ( event , e ) ) { if ( overlappedEvents == null ) { overlappedEvents = new ArrayList < > ( ) ; } overlappedEvents . add ( e ) ; } } if ( overlappedEvents == null ) { return null ; } TreeSet < TimelineEvent > orderedOverlappedEvents = new TreeSet < > ( new TimelineEventComparator ( ) ) ; orderedOverlappedEvents . addAll ( overlappedEvents ) ; return orderedOverlappedEvents ; }
Gets all overlapped events to the given one . The given and overlapped events belong to the same group . Events are ordered by their start dates - first events with more recent start dates and then events with older start dates . If start dates are equal events will be ordered by their end dates . In this case if an event has a null end date it is ordered before the event with a not null end date .
32,539
public TimelineEvent getEvent ( String index ) { return getEvent ( index != null ? Integer . valueOf ( index ) : - 1 ) ; }
Gets event by its index as String
32,540
public int getIndex ( TimelineEvent event ) { int index = - 1 ; if ( event != null ) { for ( int i = 0 ; i < events . size ( ) ; i ++ ) { if ( events . get ( i ) . equals ( event ) ) { index = i ; break ; } } } return index ; }
Gets index of the given timeline event
32,541
public void setValue ( ELContext context , Object base , Object property , Object value ) { if ( base != null && property != null ) { context . setPropertyResolved ( true ) ; valueReference = new ValueReference ( base , property . toString ( ) ) ; } }
Capture the base and property rather than write the value
32,542
public String encode ( ) throws IOException { FastStringWriter fsw = new FastStringWriter ( ) ; try { ChartUtils . writeDataValue ( fsw , "tension" , this . tension , false ) ; ChartUtils . writeDataValue ( fsw , "backgroundColor" , this . backgroundColor , true ) ; ChartUtils . writeDataValue ( fsw , "borderWidth" , this . borderWidth , true ) ; ChartUtils . writeDataValue ( fsw , "borderColor" , this . borderColor , true ) ; ChartUtils . writeDataValue ( fsw , "borderCapStyle" , this . borderCapStyle , true ) ; ChartUtils . writeDataValue ( fsw , "borderDash" , this . borderDash , true ) ; ChartUtils . writeDataValue ( fsw , "borderDashOffset" , this . borderDashOffset , true ) ; ChartUtils . writeDataValue ( fsw , "borderJoinStyle" , this . borderJoinStyle , true ) ; ChartUtils . writeDataValue ( fsw , "capBezierPoints" , this . capBezierPoints , true ) ; ChartUtils . writeDataValue ( fsw , "fill" , this . fill , true ) ; ChartUtils . writeDataValue ( fsw , "stepped" , this . stepped , true ) ; } finally { fsw . close ( ) ; } return fsw . toString ( ) ; }
Write the line options of Elements
32,543
public static final String convertPattern ( String pattern ) { if ( pattern == null ) { return null ; } else { String convertedPattern = pattern ; for ( PatternConverter converter : PATTERN_CONVERTERS ) { convertedPattern = converter . convert ( convertedPattern ) ; } return convertedPattern ; } }
Converts a java date pattern to a jquery date pattern
32,544
public static void encodeListValue ( FacesContext context , UICalendar uicalendar , String optionName , List < Object > values ) throws IOException { if ( values == null ) { return ; } ResponseWriter writer = context . getResponseWriter ( ) ; writer . write ( "," + optionName + ":[" ) ; for ( int i = 0 ; i < values . size ( ) ; i ++ ) { Object item = values . get ( i ) ; Object preText = ( i == 0 ) ? "" : "," ; if ( item instanceof Date ) { writer . write ( preText + "\"" + EscapeUtils . forJavaScript ( getValueAsString ( context , uicalendar , item ) ) + "\"" ) ; } else { writer . write ( preText + "" + item ) ; } } writer . write ( "]" ) ; }
Write the value of Calendar options
32,545
public String encode ( ) throws IOException { FastStringWriter fsw = new FastStringWriter ( ) ; try { fsw . write ( "{" ) ; ChartUtils . writeDataValue ( fsw , "display" , this . display , false ) ; ChartUtils . writeDataValue ( fsw , "color" , this . color , true ) ; ChartUtils . writeDataValue ( fsw , "borderDash" , this . borderDash , true ) ; ChartUtils . writeDataValue ( fsw , "borderDashOffset" , this . borderDashOffset , true ) ; ChartUtils . writeDataValue ( fsw , "lineWidth" , this . lineWidth , true ) ; ChartUtils . writeDataValue ( fsw , "drawBorder" , this . drawBorder , true ) ; ChartUtils . writeDataValue ( fsw , "drawOnChartArea" , this . drawOnChartArea , true ) ; ChartUtils . writeDataValue ( fsw , "drawTicks" , this . drawTicks , true ) ; ChartUtils . writeDataValue ( fsw , "tickMarkLength" , this . tickMarkLength , true ) ; ChartUtils . writeDataValue ( fsw , "zeroLineWidth" , this . zeroLineWidth , true ) ; ChartUtils . writeDataValue ( fsw , "zeroLineColor" , this . zeroLineColor , true ) ; ChartUtils . writeDataValue ( fsw , "zeroLineBorderDash" , this . zeroLineBorderDash , true ) ; ChartUtils . writeDataValue ( fsw , "zeroLineBorderDashOffset" , this . zeroLineBorderDashOffset , true ) ; ChartUtils . writeDataValue ( fsw , "offsetGridLines" , this . offsetGridLines , true ) ; fsw . write ( "}" ) ; } finally { fsw . close ( ) ; } return fsw . toString ( ) ; }
Write the common ticks options of axes
32,546
public static Builder build ( String name , String help ) { return new Builder ( ) . name ( name ) . help ( help ) ; }
Return a Builder to allow configuration of a new Histogram . Ensures required fields are provided .
32,547
private void initializePattern ( final String pattern ) { final String [ ] split = pattern . split ( Pattern . quote ( "*" ) , - 1 ) ; final StringBuilder escapedPattern = new StringBuilder ( Pattern . quote ( split [ 0 ] ) ) ; for ( int i = 1 ; i < split . length ; i ++ ) { String quoted = Pattern . quote ( split [ i ] ) ; escapedPattern . append ( "([^.]*)" ) . append ( quoted ) ; } final String regex = "^" + escapedPattern . toString ( ) + "$" ; this . patternStr = regex ; this . pattern = Pattern . compile ( regex ) ; }
Turns the GLOB pattern into a REGEX .
32,548
public void push ( CollectorRegistry registry ) throws IOException { Socket s = new Socket ( host , port ) ; BufferedWriter writer = new BufferedWriter ( new PrintWriter ( s . getOutputStream ( ) ) ) ; Matcher m = INVALID_GRAPHITE_CHARS . matcher ( "" ) ; long now = System . currentTimeMillis ( ) / 1000 ; for ( Collector . MetricFamilySamples metricFamilySamples : Collections . list ( registry . metricFamilySamples ( ) ) ) { for ( Collector . MetricFamilySamples . Sample sample : metricFamilySamples . samples ) { m . reset ( sample . name ) ; writer . write ( m . replaceAll ( "_" ) ) ; for ( int i = 0 ; i < sample . labelNames . size ( ) ; ++ i ) { m . reset ( sample . labelValues . get ( i ) ) ; writer . write ( "." + sample . labelNames . get ( i ) + "." + m . replaceAll ( "_" ) ) ; } writer . write ( " " + sample . value + " " + now + "\n" ) ; } } writer . close ( ) ; s . close ( ) ; }
Push samples from the given registry to Graphite .
32,549
public Thread start ( CollectorRegistry registry , int intervalSeconds ) { Thread thread = new PushThread ( registry , intervalSeconds ) ; thread . setDaemon ( true ) ; thread . start ( ) ; return thread ; }
Push samples from the given registry to Graphite at the given interval .
32,550
public synchronized void insert ( double value ) { buffer [ bufferCount ] = value ; bufferCount ++ ; if ( bufferCount == buffer . length ) { insertBatch ( ) ; compress ( ) ; } }
Add a new value from the stream .
32,551
public synchronized double get ( double q ) { insertBatch ( ) ; compress ( ) ; if ( sample . size ( ) == 0 ) { return Double . NaN ; } int rankMin = 0 ; int desired = ( int ) ( q * count ) ; ListIterator < Item > it = sample . listIterator ( ) ; Item prev , cur ; cur = it . next ( ) ; while ( it . hasNext ( ) ) { prev = cur ; cur = it . next ( ) ; rankMin += prev . g ; if ( rankMin + cur . g + cur . delta > desired + ( allowableError ( desired ) / 2 ) ) { return prev . value ; } } return sample . getLast ( ) . value ; }
Get the estimated value at the specified quantile .
32,552
private double allowableError ( int rank ) { int size = sample . size ( ) ; double minError = size + 1 ; for ( Quantile q : quantiles ) { double error ; if ( rank <= q . quantile * size ) { error = q . u * ( size - rank ) ; } else { error = q . v * rank ; } if ( error < minError ) { minError = error ; } } return minError ; }
Specifies the allowable error for this rank depending on which quantiles are being targeted .
32,553
private void compress ( ) { if ( sample . size ( ) < 2 ) { return ; } ListIterator < Item > it = sample . listIterator ( ) ; int removed = 0 ; Item prev = null ; Item next = it . next ( ) ; while ( it . hasNext ( ) ) { prev = next ; next = it . next ( ) ; if ( prev . g + next . g + next . delta <= allowableError ( it . previousIndex ( ) ) ) { next . g += prev . g ; it . previous ( ) ; it . previous ( ) ; it . remove ( ) ; it . next ( ) ; removed ++ ; } } }
Try to remove extraneous items from the set of sampled items . This checks if an item is unnecessary based on the desired error bounds and merges it with the adjacent item if it is .
32,554
public static void register ( CollectorRegistry registry ) { new StandardExports ( ) . register ( registry ) ; new MemoryPoolsExports ( ) . register ( registry ) ; new MemoryAllocationExports ( ) . register ( registry ) ; new BufferPoolsExports ( ) . register ( registry ) ; new GarbageCollectorExports ( ) . register ( registry ) ; new ThreadExports ( ) . register ( registry ) ; new ClassLoadingExports ( ) . register ( registry ) ; new VersionInfoExports ( ) . register ( registry ) ; }
Register the default Hotspot collectors with the given registry .
32,555
public static void write004 ( Writer writer , Enumeration < Collector . MetricFamilySamples > mfs ) throws IOException { while ( mfs . hasMoreElements ( ) ) { Collector . MetricFamilySamples metricFamilySamples = mfs . nextElement ( ) ; writer . write ( "# HELP " ) ; writer . write ( metricFamilySamples . name ) ; writer . write ( ' ' ) ; writeEscapedHelp ( writer , metricFamilySamples . help ) ; writer . write ( '\n' ) ; writer . write ( "# TYPE " ) ; writer . write ( metricFamilySamples . name ) ; writer . write ( ' ' ) ; writer . write ( typeString ( metricFamilySamples . type ) ) ; writer . write ( '\n' ) ; for ( Collector . MetricFamilySamples . Sample sample : metricFamilySamples . samples ) { writer . write ( sample . name ) ; if ( sample . labelNames . size ( ) > 0 ) { writer . write ( '{' ) ; for ( int i = 0 ; i < sample . labelNames . size ( ) ; ++ i ) { writer . write ( sample . labelNames . get ( i ) ) ; writer . write ( "=\"" ) ; writeEscapedLabelValue ( writer , sample . labelValues . get ( i ) ) ; writer . write ( "\"," ) ; } writer . write ( '}' ) ; } writer . write ( ' ' ) ; writer . write ( Collector . doubleToGoString ( sample . value ) ) ; if ( sample . timestampMs != null ) { writer . write ( ' ' ) ; writer . write ( sample . timestampMs . toString ( ) ) ; } writer . write ( '\n' ) ; } } }
Write out the text version 0 . 0 . 4 of the given MetricFamilySamples .
32,556
public static String sanitizeMetricName ( String metricName ) { return SANITIZE_BODY_PATTERN . matcher ( SANITIZE_PREFIX_PATTERN . matcher ( metricName ) . replaceFirst ( "_" ) ) . replaceAll ( "_" ) ; }
Sanitize metric name
32,557
protected static void checkMetricLabelName ( String name ) { if ( ! METRIC_LABEL_NAME_RE . matcher ( name ) . matches ( ) ) { throw new IllegalArgumentException ( "Invalid metric label name: " + name ) ; } if ( RESERVED_METRIC_LABEL_NAME_RE . matcher ( name ) . matches ( ) ) { throw new IllegalArgumentException ( "Invalid metric label name, reserved for internal use: " + name ) ; } }
Throw an exception if the metric label name is invalid .
32,558
public static String doubleToGoString ( double d ) { if ( d == Double . POSITIVE_INFINITY ) { return "+Inf" ; } if ( d == Double . NEGATIVE_INFINITY ) { return "-Inf" ; } if ( Double . isNaN ( d ) ) { return "NaN" ; } return Double . toString ( d ) ; }
Convert a double to its string representation in Go .
32,559
private void start ( boolean daemon ) { if ( daemon == Thread . currentThread ( ) . isDaemon ( ) ) { server . start ( ) ; } else { FutureTask < Void > startTask = new FutureTask < Void > ( new Runnable ( ) { public void run ( ) { server . start ( ) ; } } , null ) ; NamedDaemonThreadFactory . defaultThreadFactory ( daemon ) . newThread ( startTask ) . start ( ) ; try { startTask . get ( ) ; } catch ( ExecutionException e ) { throw new RuntimeException ( "Unexpected exception on starting HTTPSever" , e ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; } } }
Start a HTTP server by making sure that its background thread inherit proper daemon flag .
32,560
public void unregister ( Collector m ) { synchronized ( collectorsToNames ) { List < String > names = collectorsToNames . remove ( m ) ; for ( String name : names ) { namesToCollectors . remove ( name ) ; } } }
Unregister a Collector .
32,561
private static URL createURLSneakily ( final String urlString ) { try { return new URL ( urlString ) ; } catch ( MalformedURLException e ) { throw new RuntimeException ( e ) ; } }
Creates a URL instance from a String representation of a URL without throwing a checked exception . Required because you can t wrap a call to another constructor in a try statement .
32,562
public void add ( double x ) { Cell [ ] as ; long b , v ; int [ ] hc ; Cell a ; int n ; if ( ( as = cells ) != null || ! casBase ( b = base , Double . doubleToRawLongBits ( Double . longBitsToDouble ( b ) + x ) ) ) { boolean uncontended = true ; if ( ( hc = threadHashCode . get ( ) ) == null || as == null || ( n = as . length ) < 1 || ( a = as [ ( n - 1 ) & hc [ 0 ] ] ) == null || ! ( uncontended = a . cas ( v = a . value , Double . doubleToRawLongBits ( Double . longBitsToDouble ( v ) + x ) ) ) ) retryUpdate ( Double . doubleToRawLongBits ( x ) , hc , uncontended ) ; } }
Adds the given value .
32,563
MetricFamilySamples fromSnapshotAndCount ( String dropwizardName , Snapshot snapshot , long count , double factor , String helpMessage ) { List < MetricFamilySamples . Sample > samples = Arrays . asList ( sampleBuilder . createSample ( dropwizardName , "" , Arrays . asList ( "quantile" ) , Arrays . asList ( "0.5" ) , snapshot . getMedian ( ) * factor ) , sampleBuilder . createSample ( dropwizardName , "" , Arrays . asList ( "quantile" ) , Arrays . asList ( "0.75" ) , snapshot . get75thPercentile ( ) * factor ) , sampleBuilder . createSample ( dropwizardName , "" , Arrays . asList ( "quantile" ) , Arrays . asList ( "0.95" ) , snapshot . get95thPercentile ( ) * factor ) , sampleBuilder . createSample ( dropwizardName , "" , Arrays . asList ( "quantile" ) , Arrays . asList ( "0.98" ) , snapshot . get98thPercentile ( ) * factor ) , sampleBuilder . createSample ( dropwizardName , "" , Arrays . asList ( "quantile" ) , Arrays . asList ( "0.99" ) , snapshot . get99thPercentile ( ) * factor ) , sampleBuilder . createSample ( dropwizardName , "" , Arrays . asList ( "quantile" ) , Arrays . asList ( "0.999" ) , snapshot . get999thPercentile ( ) * factor ) , sampleBuilder . createSample ( dropwizardName , "_count" , new ArrayList < String > ( ) , new ArrayList < String > ( ) , count ) ) ; return new MetricFamilySamples ( samples . get ( 0 ) . name , Type . SUMMARY , helpMessage , samples ) ; }
Export a histogram snapshot as a prometheus SUMMARY .
32,564
MetricFamilySamples fromTimer ( String dropwizardName , Timer timer ) { return fromSnapshotAndCount ( dropwizardName , timer . getSnapshot ( ) , timer . getCount ( ) , 1.0D / TimeUnit . SECONDS . toNanos ( 1L ) , getHelpMessage ( dropwizardName , timer ) ) ; }
Export Dropwizard Timer as a histogram . Use TIME_UNIT as time unit .
32,565
MetricFamilySamples fromMeter ( String dropwizardName , Meter meter ) { final MetricFamilySamples . Sample sample = sampleBuilder . createSample ( dropwizardName , "_total" , new ArrayList < String > ( ) , new ArrayList < String > ( ) , meter . getCount ( ) ) ; return new MetricFamilySamples ( sample . name , Type . COUNTER , getHelpMessage ( dropwizardName , meter ) , Arrays . asList ( sample ) ) ; }
Export a Meter as as prometheus COUNTER .
32,566
public void saveField ( DateTimeFieldType fieldType , int value ) { obtainSaveField ( ) . init ( fieldType . getField ( iChrono ) , value ) ; }
Saves a datetime field value .
32,567
public void saveField ( DateTimeFieldType fieldType , String text , Locale locale ) { obtainSaveField ( ) . init ( fieldType . getField ( iChrono ) , text , locale ) ; }
Saves a datetime field text value .
32,568
public boolean restoreState ( Object savedState ) { if ( savedState instanceof SavedState ) { if ( ( ( SavedState ) savedState ) . restoreState ( this ) ) { iSavedState = savedState ; return true ; } } return false ; }
Restores the state of this bucket from a previously saved state . The state object passed into this method is not consumed and it can be used later to restore to that state again .
32,569
public long computeMillis ( boolean resetFields , CharSequence text ) { SavedField [ ] savedFields = iSavedFields ; int count = iSavedFieldsCount ; if ( iSavedFieldsShared ) { iSavedFields = savedFields = ( SavedField [ ] ) iSavedFields . clone ( ) ; iSavedFieldsShared = false ; } sort ( savedFields , count ) ; if ( count > 0 ) { DurationField months = DurationFieldType . months ( ) . getField ( iChrono ) ; DurationField days = DurationFieldType . days ( ) . getField ( iChrono ) ; DurationField first = savedFields [ 0 ] . iField . getDurationField ( ) ; if ( compareReverse ( first , months ) >= 0 && compareReverse ( first , days ) <= 0 ) { saveField ( DateTimeFieldType . year ( ) , iDefaultYear ) ; return computeMillis ( resetFields , text ) ; } } long millis = iMillis ; try { for ( int i = 0 ; i < count ; i ++ ) { millis = savedFields [ i ] . set ( millis , resetFields ) ; } if ( resetFields ) { for ( int i = 0 ; i < count ; i ++ ) { if ( ! savedFields [ i ] . iField . isLenient ( ) ) { millis = savedFields [ i ] . set ( millis , i == ( count - 1 ) ) ; } } } } catch ( IllegalFieldValueException e ) { if ( text != null ) { e . prependMessage ( "Cannot parse \"" + text + '"' ) ; } throw e ; } if ( iOffset != null ) { millis -= iOffset ; } else if ( iZone != null ) { int offset = iZone . getOffsetFromLocal ( millis ) ; millis -= offset ; if ( offset != iZone . getOffset ( millis ) ) { String message = "Illegal instant due to time zone offset transition (" + iZone + ')' ; if ( text != null ) { message = "Cannot parse \"" + text + "\": " + message ; } throw new IllegalInstantException ( message ) ; } } return millis ; }
Computes the parsed datetime by setting the saved fields . This method is idempotent but it is not thread - safe .
32,570
public static ISOChronology getInstance ( DateTimeZone zone ) { if ( zone == null ) { zone = DateTimeZone . getDefault ( ) ; } ISOChronology chrono = cCache . get ( zone ) ; if ( chrono == null ) { chrono = new ISOChronology ( ZonedChronology . getInstance ( INSTANCE_UTC , zone ) ) ; ISOChronology oldChrono = cCache . putIfAbsent ( zone , chrono ) ; if ( oldChrono != null ) { chrono = oldChrono ; } } return chrono ; }
Gets an instance of the ISOChronology in the given time zone .
32,571
public static IslamicChronology getInstance ( DateTimeZone zone , LeapYearPatternType leapYears ) { if ( zone == null ) { zone = DateTimeZone . getDefault ( ) ; } IslamicChronology chrono ; IslamicChronology [ ] chronos = cCache . get ( zone ) ; if ( chronos == null ) { chronos = new IslamicChronology [ 4 ] ; IslamicChronology [ ] oldChronos = cCache . putIfAbsent ( zone , chronos ) ; if ( oldChronos != null ) { chronos = oldChronos ; } } chrono = chronos [ leapYears . index ] ; if ( chrono == null ) { synchronized ( chronos ) { chrono = chronos [ leapYears . index ] ; if ( chrono == null ) { if ( zone == DateTimeZone . UTC ) { chrono = new IslamicChronology ( null , null , leapYears ) ; DateTime lowerLimit = new DateTime ( 1 , 1 , 1 , 0 , 0 , 0 , 0 , chrono ) ; chrono = new IslamicChronology ( LimitChronology . getInstance ( chrono , lowerLimit , null ) , null , leapYears ) ; } else { chrono = getInstance ( DateTimeZone . UTC , leapYears ) ; chrono = new IslamicChronology ( ZonedChronology . getInstance ( chrono , zone ) , null , leapYears ) ; } chronos [ leapYears . index ] = chrono ; } } } return chrono ; }
Gets an instance of the IslamicChronology in the given time zone .
32,572
public static DateTimeField getInstance ( DateTimeField field ) { if ( field == null ) { return null ; } if ( field instanceof LenientDateTimeField ) { field = ( ( LenientDateTimeField ) field ) . getWrappedField ( ) ; } if ( ! field . isLenient ( ) ) { return field ; } return new StrictDateTimeField ( field ) ; }
Returns a strict version of the given field . If it is already strict then it is returned as - is . Otherwise a new StrictDateTimeField is returned .
32,573
public long set ( long instant , int value ) { FieldUtils . verifyValueBounds ( this , value , getMinimumValue ( instant ) , getMaximumValue ( instant ) ) ; return super . set ( instant , value ) ; }
Does a bounds check before setting the value .
32,574
public long set ( long instant , int value ) { FieldUtils . verifyValueBounds ( this , value , getMinimumValue ( ) , getMaximumValueForSet ( instant , value ) ) ; return instant + ( value - get ( instant ) ) * iUnitMillis ; }
Set the specified amount of units to the specified time instant .
32,575
public void set ( DateTimeFieldType type , int value ) { if ( type == null ) { throw new IllegalArgumentException ( "Field must not be null" ) ; } setMillis ( type . getField ( getChronology ( ) ) . set ( getMillis ( ) , value ) ) ; }
Sets the value of one of the fields of the instant such as hourOfDay .
32,576
public void add ( DurationFieldType type , int amount ) { if ( type == null ) { throw new IllegalArgumentException ( "Field must not be null" ) ; } if ( amount != 0 ) { setMillis ( type . getField ( getChronology ( ) ) . add ( getMillis ( ) , amount ) ) ; } }
Adds to the instant specifying the duration and multiple to add .
32,577
public void setDate ( final int year , final int monthOfYear , final int dayOfMonth ) { Chronology c = getChronology ( ) ; long instantMidnight = c . getDateTimeMillis ( year , monthOfYear , dayOfMonth , 0 ) ; setDate ( instantMidnight ) ; }
Set the date from fields . The time part of this object will be unaffected .
32,578
public void setTime ( final long millis ) { int millisOfDay = ISOChronology . getInstanceUTC ( ) . millisOfDay ( ) . get ( millis ) ; setMillis ( getChronology ( ) . millisOfDay ( ) . set ( getMillis ( ) , millisOfDay ) ) ; }
Set the time from milliseconds . The date part of this object will be unaffected .
32,579
public void setTime ( final ReadableInstant instant ) { long instantMillis = DateTimeUtils . getInstantMillis ( instant ) ; Chronology instantChrono = DateTimeUtils . getInstantChronology ( instant ) ; DateTimeZone zone = instantChrono . getZone ( ) ; if ( zone != null ) { instantMillis = zone . getMillisKeepLocal ( DateTimeZone . UTC , instantMillis ) ; } setTime ( instantMillis ) ; }
Set the time from another instant . The date part of this object will be unaffected .
32,580
public void setTime ( final int hour , final int minuteOfHour , final int secondOfMinute , final int millisOfSecond ) { long instant = getChronology ( ) . getDateTimeMillis ( getMillis ( ) , hour , minuteOfHour , secondOfMinute , millisOfSecond ) ; setMillis ( instant ) ; }
Set the time from fields . The date part of this object will be unaffected .
32,581
public void setDateTime ( final int year , final int monthOfYear , final int dayOfMonth , final int hourOfDay , final int minuteOfHour , final int secondOfMinute , final int millisOfSecond ) { long instant = getChronology ( ) . getDateTimeMillis ( year , monthOfYear , dayOfMonth , hourOfDay , minuteOfHour , secondOfMinute , millisOfSecond ) ; setMillis ( instant ) ; }
Set the date and time from fields .
32,582
Converter select ( Class < ? > type ) throws IllegalStateException { Entry [ ] entries = iSelectEntries ; int length = entries . length ; int index = type == null ? 0 : type . hashCode ( ) & ( length - 1 ) ; Entry e ; while ( ( e = entries [ index ] ) != null ) { if ( e . iType == type ) { return e . iConverter ; } if ( ++ index >= length ) { index = 0 ; } } Converter converter = selectSlow ( this , type ) ; e = new Entry ( type , converter ) ; entries = ( Entry [ ] ) entries . clone ( ) ; entries [ index ] = e ; for ( int i = 0 ; i < length ; i ++ ) { if ( entries [ i ] == null ) { iSelectEntries = entries ; return converter ; } } int newLength = length << 1 ; Entry [ ] newEntries = new Entry [ newLength ] ; for ( int i = 0 ; i < length ; i ++ ) { e = entries [ i ] ; type = e . iType ; index = type == null ? 0 : type . hashCode ( ) & ( newLength - 1 ) ; while ( newEntries [ index ] != null ) { if ( ++ index >= newLength ) { index = 0 ; } } newEntries [ index ] = e ; } iSelectEntries = newEntries ; return converter ; }
Returns the closest matching converter for the given type or null if none found .
32,583
ConverterSet add ( Converter converter , Converter [ ] removed ) { Converter [ ] converters = iConverters ; int length = converters . length ; for ( int i = 0 ; i < length ; i ++ ) { Converter existing = converters [ i ] ; if ( converter . equals ( existing ) ) { if ( removed != null ) { removed [ 0 ] = null ; } return this ; } if ( converter . getSupportedType ( ) == existing . getSupportedType ( ) ) { Converter [ ] copy = new Converter [ length ] ; for ( int j = 0 ; j < length ; j ++ ) { if ( j != i ) { copy [ j ] = converters [ j ] ; } else { copy [ j ] = converter ; } } if ( removed != null ) { removed [ 0 ] = existing ; } return new ConverterSet ( copy ) ; } } Converter [ ] copy = new Converter [ length + 1 ] ; System . arraycopy ( converters , 0 , copy , 0 , length ) ; copy [ length ] = converter ; if ( removed != null ) { removed [ 0 ] = null ; } return new ConverterSet ( copy ) ; }
Returns a copy of this set with the given converter added . If a matching converter is already in the set the given converter replaces it . If the converter is exactly the same as one already in the set the original set is returned .
32,584
ConverterSet remove ( Converter converter , Converter [ ] removed ) { Converter [ ] converters = iConverters ; int length = converters . length ; for ( int i = 0 ; i < length ; i ++ ) { if ( converter . equals ( converters [ i ] ) ) { return remove ( i , removed ) ; } } if ( removed != null ) { removed [ 0 ] = null ; } return this ; }
Returns a copy of this set with the given converter removed . If the converter was not in the set the original set is returned .
32,585
ConverterSet remove ( final int index , Converter [ ] removed ) { Converter [ ] converters = iConverters ; int length = converters . length ; if ( index >= length ) { throw new IndexOutOfBoundsException ( ) ; } if ( removed != null ) { removed [ 0 ] = converters [ index ] ; } Converter [ ] copy = new Converter [ length - 1 ] ; int j = 0 ; for ( int i = 0 ; i < length ; i ++ ) { if ( i != index ) { copy [ j ++ ] = converters [ i ] ; } } return new ConverterSet ( copy ) ; }
Returns a copy of this set with the converter at the given index removed .
32,586
private static Converter selectSlow ( ConverterSet set , Class < ? > type ) { Converter [ ] converters = set . iConverters ; int length = converters . length ; Converter converter ; for ( int i = length ; -- i >= 0 ; ) { converter = converters [ i ] ; Class < ? > supportedType = converter . getSupportedType ( ) ; if ( supportedType == type ) { return converter ; } if ( supportedType == null || ( type != null && ! supportedType . isAssignableFrom ( type ) ) ) { set = set . remove ( i , null ) ; converters = set . iConverters ; length = converters . length ; } } if ( type == null || length == 0 ) { return null ; } if ( length == 1 ) { return converters [ 0 ] ; } for ( int i = length ; -- i >= 0 ; ) { converter = converters [ i ] ; Class < ? > supportedType = converter . getSupportedType ( ) ; for ( int j = length ; -- j >= 0 ; ) { if ( j != i && converters [ j ] . getSupportedType ( ) . isAssignableFrom ( supportedType ) ) { set = set . remove ( j , null ) ; converters = set . iConverters ; length = converters . length ; i = length - 1 ; } } } if ( length == 1 ) { return converters [ 0 ] ; } StringBuilder msg = new StringBuilder ( ) ; msg . append ( "Unable to find best converter for type \"" ) ; msg . append ( type . getName ( ) ) ; msg . append ( "\" from remaining set: " ) ; for ( int i = 0 ; i < length ; i ++ ) { converter = converters [ i ] ; Class < ? > supportedType = converter . getSupportedType ( ) ; msg . append ( converter . getClass ( ) . getName ( ) ) ; msg . append ( '[' ) ; msg . append ( supportedType == null ? null : supportedType . getName ( ) ) ; msg . append ( "], " ) ; } throw new IllegalStateException ( msg . toString ( ) ) ; }
Returns the closest matching converter for the given type but not very efficiently .
32,587
private void checkAlterIntervalConverters ( ) throws SecurityException { SecurityManager sm = System . getSecurityManager ( ) ; if ( sm != null ) { sm . checkPermission ( new JodaTimePermission ( "ConverterManager.alterIntervalConverters" ) ) ; } }
Checks whether the user has permission ConverterManager . alterIntervalConverters .
32,588
public long roundHalfFloor ( long instant ) { long floor = roundFloor ( instant ) ; long ceiling = roundCeiling ( instant ) ; long diffFromFloor = instant - floor ; long diffToCeiling = ceiling - instant ; if ( diffFromFloor <= diffToCeiling ) { return floor ; } else { return ceiling ; } }
Round to the nearest whole unit of this field . If the given millisecond value is closer to the floor or is exactly halfway this function behaves like roundFloor . If the millisecond value is closer to the ceiling this function behaves like roundCeiling .
32,589
public long roundHalfCeiling ( long instant ) { long floor = roundFloor ( instant ) ; long ceiling = roundCeiling ( instant ) ; long diffFromFloor = instant - floor ; long diffToCeiling = ceiling - instant ; if ( diffToCeiling <= diffFromFloor ) { return ceiling ; } else { return floor ; } }
Round to the nearest whole unit of this field . If the given millisecond value is closer to the floor this function behaves like roundFloor . If the millisecond value is closer to the ceiling or is exactly halfway this function behaves like roundCeiling .
32,590
public long set ( long instant , int year ) { FieldUtils . verifyValueBounds ( this , year , 1 , getMaximumValue ( ) ) ; if ( iChronology . getYear ( instant ) <= 0 ) { year = 1 - year ; } return super . set ( instant , year ) ; }
Set the year component of the specified time instant .
32,591
protected void setInterval ( long startInstant , long endInstant , Chronology chrono ) { checkInterval ( startInstant , endInstant ) ; iStartMillis = startInstant ; iEndMillis = endInstant ; iChronology = DateTimeUtils . getChronology ( chrono ) ; }
Sets this interval from two millisecond instants and a chronology .
32,592
public long getInstantMillis ( Object object , Chronology chrono ) { Date date = ( Date ) object ; return date . getTime ( ) ; }
Gets the millis which is the Date millis value .
32,593
public void setInto ( ReadWritablePeriod duration , Object object , Chronology chrono ) { duration . setPeriod ( ( Period ) null ) ; }
Sets the given ReadWritableDuration to zero milliseconds .
32,594
public static PeriodFormatter standard ( ) { if ( cStandard == null ) { cStandard = new PeriodFormatterBuilder ( ) . appendLiteral ( "P" ) . appendYears ( ) . appendSuffix ( "Y" ) . appendMonths ( ) . appendSuffix ( "M" ) . appendWeeks ( ) . appendSuffix ( "W" ) . appendDays ( ) . appendSuffix ( "D" ) . appendSeparatorIfFieldsAfter ( "T" ) . appendHours ( ) . appendSuffix ( "H" ) . appendMinutes ( ) . appendSuffix ( "M" ) . appendSecondsWithOptionalMillis ( ) . appendSuffix ( "S" ) . toFormatter ( ) ; } return cStandard ; }
The standard ISO format - PyYmMwWdDThHmMsS . Milliseconds are not output . Note that the ISO8601 standard actually indicates weeks should not be shown if any other field is present and vice versa .
32,595
public void clear ( ) { iMinPrintedDigits = 1 ; iPrintZeroSetting = PRINT_ZERO_RARELY_LAST ; iMaxParsedDigits = 10 ; iRejectSignedValues = false ; iPrefix = null ; if ( iElementPairs == null ) { iElementPairs = new ArrayList < Object > ( ) ; } else { iElementPairs . clear ( ) ; } iNotPrinter = false ; iNotParser = false ; iFieldFormatters = new FieldFormatter [ 10 ] ; }
Clears out all the appended elements allowing this builder to be reused .
32,596
public PeriodFormatterBuilder append ( PeriodFormatter formatter ) { if ( formatter == null ) { throw new IllegalArgumentException ( "No formatter supplied" ) ; } clearPrefix ( ) ; append0 ( formatter . getPrinter ( ) , formatter . getParser ( ) ) ; return this ; }
Appends another formatter .
32,597
public static void main ( String [ ] args ) throws Exception { if ( args . length == 0 ) { printUsage ( ) ; return ; } File inputDir = null ; File outputDir = null ; boolean verbose = false ; int i ; for ( i = 0 ; i < args . length ; i ++ ) { try { if ( "-src" . equals ( args [ i ] ) ) { inputDir = new File ( args [ ++ i ] ) ; } else if ( "-dst" . equals ( args [ i ] ) ) { outputDir = new File ( args [ ++ i ] ) ; } else if ( "-verbose" . equals ( args [ i ] ) ) { verbose = true ; } else if ( "-?" . equals ( args [ i ] ) ) { printUsage ( ) ; return ; } else { break ; } } catch ( IndexOutOfBoundsException e ) { printUsage ( ) ; return ; } } if ( i >= args . length ) { printUsage ( ) ; return ; } File [ ] sources = new File [ args . length - i ] ; for ( int j = 0 ; i < args . length ; i ++ , j ++ ) { sources [ j ] = inputDir == null ? new File ( args [ i ] ) : new File ( inputDir , args [ i ] ) ; } ZoneInfoLogger . set ( verbose ) ; ZoneInfoCompiler zic = new ZoneInfoCompiler ( ) ; zic . compile ( outputDir , sources ) ; }
Launches the ZoneInfoCompiler tool .
32,598
public void setInterval ( ReadableInterval interval ) { if ( interval == null ) { throw new IllegalArgumentException ( "Interval must not be null" ) ; } long startMillis = interval . getStartMillis ( ) ; long endMillis = interval . getEndMillis ( ) ; Chronology chrono = interval . getChronology ( ) ; super . setInterval ( startMillis , endMillis , chrono ) ; }
Sets this interval to be the same as another .
32,599
public void setInterval ( ReadableInstant start , ReadableInstant end ) { if ( start == null && end == null ) { long now = DateTimeUtils . currentTimeMillis ( ) ; setInterval ( now , now ) ; } else { long startMillis = DateTimeUtils . getInstantMillis ( start ) ; long endMillis = DateTimeUtils . getInstantMillis ( end ) ; Chronology chrono = DateTimeUtils . getInstantChronology ( start ) ; super . setInterval ( startMillis , endMillis , chrono ) ; } }
Sets this interval from two instants replacing the chronology with that from the start instant .