idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
37,800
public ICalendar first ( ) throws IOException { StreamReader reader = constructReader ( ) ; if ( index != null ) { reader . setScribeIndex ( index ) ; } try { ICalendar ical = reader . readNext ( ) ; if ( warnings != null ) { warnings . add ( reader . getWarnings ( ) ) ; } return ical ; } finally { if ( closeWhenDone (...
Reads the first iCalendar object from the stream .
100
12
37,801
public List < ICalendar > all ( ) throws IOException { StreamReader reader = constructReader ( ) ; if ( index != null ) { reader . setScribeIndex ( index ) ; } try { List < ICalendar > icals = new ArrayList < ICalendar > ( ) ; ICalendar ical ; while ( ( ical = reader . readNext ( ) ) != null ) { if ( warnings != null )...
Reads all iCalendar objects from the stream .
143
11
37,802
static Predicate < DateValue > weekIntervalFilter ( final int interval , final DayOfWeek weekStart , final DateValue dtStart ) { return new Predicate < DateValue > ( ) { private static final long serialVersionUID = 7059994888520369846L ; //the latest day with day of week weekStart on or before dtStart DateValue wkStart...
Constructs a filter that accepts only every X week starting from the week containing the given date .
256
19
37,803
static Predicate < DateValue > byHourFilter ( int [ ] hours ) { int hoursByBit = 0 ; for ( int hour : hours ) { hoursByBit |= 1 << hour ; } if ( ( hoursByBit & LOW_24_BITS ) == LOW_24_BITS ) { return Predicates . alwaysTrue ( ) ; } final int bitField = hoursByBit ; return new Predicate < DateValue > ( ) { private stati...
Constructs an hour filter based on a BYHOUR rule .
172
13
37,804
public String first ( ICalDataType dataType ) { String dataTypeStr = toLocalName ( dataType ) ; return first ( dataTypeStr ) ; }
Gets the first value of the given data type .
34
11
37,805
public String first ( String localName ) { for ( Element child : children ( ) ) { if ( localName . equals ( child . getLocalName ( ) ) && XCAL_NS . equals ( child . getNamespaceURI ( ) ) ) { return child . getTextContent ( ) ; } } return null ; }
Gets the value of the first child element with the given name .
69
14
37,806
public List < String > all ( ICalDataType dataType ) { String dataTypeStr = toLocalName ( dataType ) ; return all ( dataTypeStr ) ; }
Gets all the values of a given data type .
37
11
37,807
public List < String > all ( String localName ) { List < String > childrenText = new ArrayList < String > ( ) ; for ( Element child : children ( ) ) { if ( localName . equals ( child . getLocalName ( ) ) && XCAL_NS . equals ( child . getNamespaceURI ( ) ) ) { String text = child . getTextContent ( ) ; childrenText . ad...
Gets the values of all child elements that have the given name .
99
14
37,808
public Element append ( ICalDataType dataType , String value ) { String dataTypeStr = toLocalName ( dataType ) ; return append ( dataTypeStr , value ) ; }
Adds a value .
39
4
37,809
public Element append ( String name , String value ) { Element child = document . createElementNS ( XCAL_NS , name ) ; child . setTextContent ( value ) ; element . appendChild ( child ) ; return child ; }
Adds a child element .
50
5
37,810
public List < Element > append ( String name , Collection < String > values ) { List < Element > elements = new ArrayList < Element > ( values . size ( ) ) ; for ( String value : values ) { elements . add ( append ( name , value ) ) ; } return elements ; }
Adds multiple child elements each with the same name .
62
10
37,811
public List < XCalElement > children ( ICalDataType dataType ) { String localName = dataType . getName ( ) . toLowerCase ( ) ; List < XCalElement > children = new ArrayList < XCalElement > ( ) ; for ( Element child : children ( ) ) { if ( localName . equals ( child . getLocalName ( ) ) && XCAL_NS . equals ( child . get...
Gets all child elements with the given data type .
118
11
37,812
public XCalElement child ( ICalDataType dataType ) { String localName = dataType . getName ( ) . toLowerCase ( ) ; for ( Element child : children ( ) ) { if ( localName . equals ( child . getLocalName ( ) ) && XCAL_NS . equals ( child . getNamespaceURI ( ) ) ) { return new XCalElement ( child ) ; } } return null ; }
Gets the first child element with the given data type .
92
12
37,813
public void close ( ) throws IOException { try { if ( ! started ) { handler . startDocument ( ) ; if ( ! icalendarElementExists ) { //don't output a <icalendar> element if the parent is a <icalendar> element start ( ICALENDAR ) ; } } if ( ! icalendarElementExists ) { end ( ICALENDAR ) ; } handler . endDocument ( ) ; } ...
Terminates the XML document and closes the output stream .
125
11
37,814
public void writeStartComponent ( String componentName ) throws IOException { if ( generator == null ) { init ( ) ; } componentEnded = false ; if ( ! stack . isEmpty ( ) ) { Info parent = stack . getLast ( ) ; if ( ! parent . wroteEndPropertiesArray ) { generator . writeEndArray ( ) ; parent . wroteEndPropertiesArray =...
Writes the beginning of a new component array .
158
10
37,815
public void writeEndComponent ( ) throws IOException { if ( stack . isEmpty ( ) ) { throw new IllegalStateException ( Messages . INSTANCE . getExceptionMessage ( 2 ) ) ; } Info cur = stack . removeLast ( ) ; if ( ! cur . wroteEndPropertiesArray ) { generator . writeEndArray ( ) ; } if ( ! cur . wroteStartSubComponentsA...
Closes the current component array .
131
7
37,816
public void closeJsonStream ( ) throws IOException { if ( generator == null ) { return ; } while ( ! stack . isEmpty ( ) ) { writeEndComponent ( ) ; } if ( wrapInArray ) { generator . writeEndArray ( ) ; } if ( closeGenerator ) { generator . close ( ) ; } }
Finishes writing the JSON document so that it is syntactically correct . No more data can be written once this method is called .
71
27
37,817
static Generator serialInstanceGenerator ( final Predicate < ? super DateValue > filter , final Generator yearGenerator , final Generator monthGenerator , final Generator dayGenerator , final Generator hourGenerator , final Generator minuteGenerator , final Generator secondGenerator ) { if ( skipSubDayGenerators ( hour...
A collector that yields each date in the period without doing any set collecting .
500
15
37,818
public void setParameters ( ICalParameters parameters ) { if ( parameters == null ) { throw new NullPointerException ( Messages . INSTANCE . getExceptionMessage ( 16 ) ) ; } this . parameters = parameters ; }
Sets the property s parameters
46
6
37,819
public List < String > getParameters ( String name ) { return Collections . unmodifiableList ( parameters . get ( name ) ) ; }
Gets all values of a parameter with the given name .
29
12
37,820
public void setParameter ( String name , Collection < String > values ) { parameters . replace ( name , values ) ; }
Replaces all existing values of a parameter with the given values .
25
13
37,821
public Completed setCompleted ( Date completed ) { Completed prop = ( completed == null ) ? null : new Completed ( completed ) ; setCompleted ( prop ) ; return prop ; }
Sets the date and time that the to - do task was completed .
36
15
37,822
public PercentComplete setPercentComplete ( Integer percent ) { PercentComplete prop = ( percent == null ) ? null : new PercentComplete ( percent ) ; setPercentComplete ( prop ) ; return prop ; }
Sets the amount that the to - do task has been completed .
41
14
37,823
public Attendee addAttendee ( String email ) { Attendee prop = new Attendee ( null , email , null ) ; addAttendee ( prop ) ; return prop ; }
Adds a person who is involved in the to - do task .
39
13
37,824
public static DateValue add ( DateValue date , DateValue duration ) { DTBuilder db = new DTBuilder ( date ) ; db . year += duration . year ( ) ; db . month += duration . month ( ) ; db . day += duration . day ( ) ; if ( duration instanceof TimeValue ) { TimeValue tdur = ( TimeValue ) duration ; db . hour += tdur . hour...
Adds a duration to a date .
144
7
37,825
public static int daysBetween ( int year1 , int month1 , int day1 , int year2 , int month2 , int day2 ) { return fixedFromGregorian ( year1 , month1 , day1 ) - fixedFromGregorian ( year2 , month2 , day2 ) ; }
Calculates the number of days between two dates .
63
11
37,826
public static DayOfWeek dayOfWeek ( DateValue date ) { int dayIndex = fixedFromGregorian ( date . year ( ) , date . month ( ) , date . day ( ) ) % 7 ; if ( dayIndex < 0 ) { dayIndex += 7 ; } return DAYS_OF_WEEK [ dayIndex ] ; }
Gets the day of the week the given date falls on .
72
13
37,827
public static DayOfWeek firstDayOfWeekInMonth ( int year , int month ) { int result = fixedFromGregorian ( year , month , 1 ) % 7 ; if ( result < 0 ) { result += 7 ; } return DAYS_OF_WEEK [ result ] ; }
Gets the day of the week of the first day in the given month .
61
16
37,828
public static DateTimeValue timeFromSecsSinceEpoch ( long secsSinceEpoch ) { // TODO: should we handle -ve years? int secsInDay = ( int ) ( secsSinceEpoch % SECS_PER_DAY ) ; int daysSinceEpoch = ( int ) ( secsSinceEpoch / SECS_PER_DAY ) ; int approx = ( int ) ( ( daysSinceEpoch + 10 ) * 400L / 146097 ) ; int year = ( d...
Computes the gregorian time from the number of seconds since the Proleptic Gregorian Epoch . See Calendrical Calculations Reingold and Dershowitz .
357
37
37,829
@ SuppressWarnings ( "unchecked" ) public static < T > Predicate < T > and ( Collection < Predicate < ? super T > > components ) { return and ( components . toArray ( new Predicate [ 0 ] ) ) ; }
Returns a predicate that evaluates to true iff each of its components evaluates to true . The components are evaluated in order and evaluation will be short - circuited as soon as the answer is determined .
55
40
37,830
public DateIterator getDateIterator ( ICalDate startDate , TimeZone timezone ) { Recurrence recur = getValue ( ) ; return ( recur == null ) ? new Google2445Utils . EmptyDateIterator ( ) : recur . getDateIterator ( startDate , timezone ) ; }
Creates an iterator that computes the dates defined by this property .
65
14
37,831
public boolean isSupported ( ICalVersion version ) { for ( ICalVersion supportedVersion : supportedVersions ) { if ( supportedVersion == version ) { return true ; } } return false ; }
Determines if the parameter value is supported by the given iCalendar version .
40
17
37,832
public void write ( ICalendar ical ) throws IOException { Collection < Class < ? > > unregistered = findScribeless ( ical ) ; if ( ! unregistered . isEmpty ( ) ) { List < String > classNames = new ArrayList < String > ( unregistered . size ( ) ) ; for ( Class < ? > clazz : unregistered ) { classNames . add ( clazz . ge...
Writes an iCalendar object to the data stream .
158
12
37,833
public TimezoneOffsetTo setTimezoneOffsetTo ( UtcOffset offset ) { TimezoneOffsetTo prop = new TimezoneOffsetTo ( offset ) ; setTimezoneOffsetTo ( prop ) ; return prop ; }
Sets the UTC offset that the timezone observance transitions to .
45
14
37,834
public TimezoneOffsetFrom setTimezoneOffsetFrom ( UtcOffset offset ) { TimezoneOffsetFrom prop = new TimezoneOffsetFrom ( offset ) ; setTimezoneOffsetFrom ( prop ) ; return prop ; }
Sets the UTC offset that the timezone observance transitions from .
45
14
37,835
public TimezoneName addTimezoneName ( String timezoneName ) { TimezoneName prop = new TimezoneName ( timezoneName ) ; addTimezoneName ( prop ) ; return prop ; }
Adds a traditional non - standard name for the timezone observance .
42
14
37,836
private static String getCidUriValue ( String uri ) { int colon = uri . indexOf ( ' ' ) ; if ( colon == 3 ) { String scheme = uri . substring ( 0 , colon ) ; return "cid" . equalsIgnoreCase ( scheme ) ? uri . substring ( colon + 1 ) : null ; } if ( uri . length ( ) > 0 && uri . charAt ( 0 ) == ' ' && uri . charAt ( uri...
Gets the value of the given cid URI .
144
11
37,837
public < T extends ICalProperty > T getProperty ( Class < T > clazz ) { return clazz . cast ( properties . first ( clazz ) ) ; }
Gets the first property of a given class .
36
10
37,838
public List < ICalProperty > setProperty ( ICalProperty property ) { return properties . replace ( property . getClass ( ) , property ) ; }
Replaces all existing properties of the given property instance s class with the given property instance .
32
18
37,839
public < T extends ICalProperty > List < T > setProperty ( Class < T > clazz , T property ) { List < ICalProperty > replaced = properties . replace ( clazz , property ) ; return castList ( replaced , clazz ) ; }
Replaces all existing properties of the given class with a single property instance . If the property instance is null then all instances of that property will be removed .
55
31
37,840
public < T extends ICalProperty > boolean removeProperty ( T property ) { return properties . remove ( property . getClass ( ) , property ) ; }
Removes a specific property instance from this component .
32
10
37,841
public < T extends ICalProperty > List < T > removeProperties ( Class < T > clazz ) { List < ICalProperty > removed = properties . removeAll ( clazz ) ; return castList ( removed , clazz ) ; }
Removes all properties of a given class from this component .
52
12
37,842
public < T extends ICalComponent > boolean removeComponent ( T component ) { return components . remove ( component . getClass ( ) , component ) ; }
Removes a specific sub - component instance from this component .
32
12
37,843
public < T extends ICalComponent > List < T > removeComponents ( Class < T > clazz ) { List < ICalComponent > removed = components . removeAll ( clazz ) ; return castList ( removed , clazz ) ; }
Removes all sub - components of the given class from this component .
52
14
37,844
public RawProperty getExperimentalProperty ( String name ) { for ( RawProperty raw : getExperimentalProperties ( ) ) { if ( raw . getName ( ) . equalsIgnoreCase ( name ) ) { return raw ; } } return null ; }
Gets the first experimental property with a given name .
54
11
37,845
public List < RawProperty > getExperimentalProperties ( String name ) { /* * Note: The returned list is not backed by the parent component because * this would allow RawProperty objects without the specified name to be * added to the list. */ List < RawProperty > toReturn = new ArrayList < RawProperty > ( ) ; for ( Raw...
Gets all experimental properties with a given name .
125
10
37,846
public List < RawProperty > removeExperimentalProperties ( String name ) { List < RawProperty > all = getExperimentalProperties ( ) ; List < RawProperty > toRemove = new ArrayList < RawProperty > ( ) ; for ( RawProperty property : all ) { if ( property . getName ( ) . equalsIgnoreCase ( name ) ) { toRemove . add ( prop...
Removes all experimental properties that have the given name .
108
11
37,847
public < T extends ICalComponent > T getComponent ( Class < T > clazz ) { return clazz . cast ( components . first ( clazz ) ) ; }
Gets the first sub - component of a given class .
36
12
37,848
public < T extends ICalComponent > List < T > getComponents ( Class < T > clazz ) { return new ICalComponentList < T > ( clazz ) ; }
Gets all sub - components of a given class . Changes to the returned list will update the parent component object and vice versa .
39
26
37,849
public List < ICalComponent > setComponent ( ICalComponent component ) { return components . replace ( component . getClass ( ) , component ) ; }
Replaces all sub - components of a given class with the given component .
32
15
37,850
public < T extends ICalComponent > List < T > setComponent ( Class < T > clazz , T component ) { List < ICalComponent > replaced = components . replace ( clazz , component ) ; return castList ( replaced , clazz ) ; }
Replaces all sub - components of a given class with the given component . If the component instance is null then all instances of that component will be removed .
55
31
37,851
public RawComponent getExperimentalComponent ( String name ) { for ( RawComponent component : getExperimentalComponents ( ) ) { if ( component . getName ( ) . equalsIgnoreCase ( name ) ) { return component ; } } return null ; }
Gets the first experimental sub - component with a given name .
54
13
37,852
public List < RawComponent > getExperimentalComponents ( String name ) { /* * Note: The returned list is not backed by the parent component because * this would allow RawComponent objects without the specified name to * be added to the list. */ List < RawComponent > toReturn = new ArrayList < RawComponent > ( ) ; for (...
Gets all experimental sub - component with a given name .
125
12
37,853
public RawComponent addExperimentalComponent ( String name ) { RawComponent raw = new RawComponent ( name ) ; addComponent ( raw ) ; return raw ; }
Adds an experimental sub - component to this component .
33
10
37,854
public List < RawComponent > removeExperimentalComponents ( String name ) { List < RawComponent > all = getExperimentalComponents ( ) ; List < RawComponent > toRemove = new ArrayList < RawComponent > ( ) ; for ( RawComponent property : all ) { if ( property . getName ( ) . equalsIgnoreCase ( name ) ) { toRemove . add (...
Removes all experimental sub - components that have the given name .
108
13
37,855
protected void checkRequiredCardinality ( List < ValidationWarning > warnings , Class < ? extends ICalProperty > ... classes ) { for ( Class < ? extends ICalProperty > clazz : classes ) { List < ? extends ICalProperty > props = getProperties ( clazz ) ; if ( props . isEmpty ( ) ) { warnings . add ( new ValidationWarnin...
Utility method for validating that there is exactly one instance of each of the given properties .
135
19
37,856
private static < T > List < T > castList ( List < ? > list , Class < T > castTo ) { List < T > casted = new ArrayList < T > ( list . size ( ) ) ; for ( Object object : list ) { casted . add ( castTo . cast ( object ) ) ; } return Collections . unmodifiableList ( casted ) ; }
Casts all objects in the given list to the given class adding the casted objects to a new list .
83
22
37,857
public final T parseText ( String value , ICalDataType dataType , ICalParameters parameters , ParseContext context ) { T property = _parseText ( value , dataType , parameters , context ) ; property . setParameters ( parameters ) ; return property ; }
Unmarshals a property from a plain - text iCalendar data stream .
56
17
37,858
private static String jcalValueToString ( JCalValue value ) { List < JsonValue > values = value . getValues ( ) ; if ( values . size ( ) > 1 ) { List < String > multi = value . asMulti ( ) ; if ( ! multi . isEmpty ( ) ) { return VObjectPropertyValues . writeList ( multi ) ; } } if ( ! values . isEmpty ( ) && values . g...
Converts a jCal value to its plain - text format representation .
232
14
37,859
protected static DateWriter date ( Date date ) { return date ( ( date == null ) ? null : new ICalDate ( date ) ) ; }
Formats a date as a string .
31
8
37,860
protected static ICalParameters handleTzidParameter ( ICalProperty property , boolean hasTime , WriteContext context ) { ICalParameters parameters = property . getParameters ( ) ; //date values don't have timezones if ( ! hasTime ) { return parameters ; } //vCal doesn't use the TZID parameter if ( context . getVersion ...
Adds a TZID parameter to a property s parameter list if necessary .
357
15
37,861
public ICalComponentScribe < ? extends ICalComponent > getComponentScribe ( String componentName , ICalVersion version ) { componentName = componentName . toUpperCase ( ) ; ICalComponentScribe < ? extends ICalComponent > scribe = experimentalCompByName . get ( componentName ) ; if ( scribe == null ) { scribe = standard...
Gets a component scribe by name .
168
9
37,862
public ICalPropertyScribe < ? extends ICalProperty > getPropertyScribe ( String propertyName , ICalVersion version ) { propertyName = propertyName . toUpperCase ( ) ; String key = propertyNameKey ( propertyName , version ) ; ICalPropertyScribe < ? extends ICalProperty > scribe = experimentalPropByName . get ( key ) ; i...
Gets a property scribe by name .
179
9
37,863
public ICalComponentScribe < ? extends ICalComponent > getComponentScribe ( Class < ? extends ICalComponent > clazz ) { ICalComponentScribe < ? extends ICalComponent > scribe = experimentalCompByClass . get ( clazz ) ; if ( scribe != null ) { return scribe ; } return standardCompByClass . get ( clazz ) ; }
Gets a component scribe by class .
82
9
37,864
public ICalPropertyScribe < ? extends ICalProperty > getPropertyScribe ( Class < ? extends ICalProperty > clazz ) { ICalPropertyScribe < ? extends ICalProperty > scribe = experimentalPropByClass . get ( clazz ) ; if ( scribe != null ) { return scribe ; } return standardPropByClass . get ( clazz ) ; }
Gets a property scribe by class .
82
9
37,865
public ICalComponentScribe < ? extends ICalComponent > getComponentScribe ( ICalComponent component ) { if ( component instanceof RawComponent ) { RawComponent raw = ( RawComponent ) component ; return new RawComponentScribe ( raw . getName ( ) ) ; } return getComponentScribe ( component . getClass ( ) ) ; }
Gets the appropriate component scribe for a given component instance .
74
13
37,866
public ICalPropertyScribe < ? extends ICalProperty > getPropertyScribe ( ICalProperty property ) { if ( property instanceof RawProperty ) { RawProperty raw = ( RawProperty ) property ; return new RawPropertyScribe ( raw . getName ( ) ) ; } return getPropertyScribe ( property . getClass ( ) ) ; }
Gets the appropriate property scribe for a given property instance .
74
13
37,867
public ICalPropertyScribe < ? extends ICalProperty > getPropertyScribe ( QName qname ) { ICalPropertyScribe < ? extends ICalProperty > scribe = experimentalPropByQName . get ( qname ) ; if ( scribe == null ) { scribe = standardPropByQName . get ( qname ) ; } if ( scribe == null || ! scribe . getSupportedVersions ( ) . ...
Gets a property scribe by XML local name and namespace .
176
13
37,868
public void unregister ( ICalComponentScribe < ? extends ICalComponent > scribe ) { experimentalCompByName . remove ( scribe . getComponentName ( ) . toUpperCase ( ) ) ; experimentalCompByClass . remove ( scribe . getComponentClass ( ) ) ; }
Unregisters a component scribe .
63
8
37,869
public void unregister ( ICalPropertyScribe < ? extends ICalProperty > scribe ) { for ( ICalVersion version : ICalVersion . values ( ) ) { experimentalPropByName . remove ( propertyNameKey ( scribe , version ) ) ; } experimentalPropByClass . remove ( scribe . getPropertyClass ( ) ) ; experimentalPropByQName . remove ( ...
Unregisters a property scribe
92
7
37,870
private static Date determineStartDate ( VAlarm valarm , ICalComponent parent ) { Trigger trigger = valarm . getTrigger ( ) ; if ( trigger == null ) { return null ; } Date triggerStart = trigger . getDate ( ) ; if ( triggerStart != null ) { return triggerStart ; } Duration triggerDuration = trigger . getDuration ( ) ; ...
Determines what the alarm property s start date should be .
271
13
37,871
static int [ ] uniquify ( int [ ] ints ) { IntSet iset = new IntSet ( ) ; for ( int i : ints ) { iset . add ( i ) ; } return iset . toIntArray ( ) ; }
Returns a sorted copy of an integer array with duplicate values removed .
55
13
37,872
static int countInPeriod ( DayOfWeek dow , DayOfWeek dow0 , int nDays ) { //two cases: // (1a) dow >= dow0: count === (nDays - (dow - dow0)) / 7 // (1b) dow < dow0: count === (nDays - (7 - dow0 - dow)) / 7 if ( dow . getCalendarConstant ( ) >= dow0 . getCalendarConstant ( ) ) { return 1 + ( ( nDays - ( dow . getCalenda...
Counts the number of occurrences of a weekday in a given period .
185
14
37,873
private DateValue generateInstance ( ) { try { do { if ( ! instanceGenerator . generate ( builder ) ) { return null ; } DateValue dUtc = dtStart instanceof TimeValue ? TimeUtils . toUtc ( builder . toDateTime ( ) , tzid ) : builder . toDate ( ) ; if ( dUtc . compareTo ( lastUtc_ ) > 0 ) { return dUtc ; } } while ( true...
Generates a date .
121
5
37,874
public void setTimezone ( ICalProperty property , TimezoneAssignment timezone ) { if ( timezone == null ) { TimezoneAssignment existing = propertyTimezones . remove ( property ) ; if ( existing != null && existing != defaultTimezone && ! propertyTimezones . values ( ) . contains ( existing ) ) { assignments . remove ( ...
Assigns a timezone to a specific property .
104
11
37,875
public boolean isFloating ( ICalProperty property ) { if ( containsIdentity ( floatingProperties , property ) ) { return true ; } if ( propertyTimezones . containsKey ( property ) ) { return false ; } return globalFloatingTime ; }
Determines if a property value should be formatted in floating time when written to an output stream .
55
20
37,876
private static < T > void removeIdentity ( List < T > list , T object ) { Iterator < T > it = list . iterator ( ) ; while ( it . hasNext ( ) ) { if ( object == it . next ( ) ) { it . remove ( ) ; } } }
Removes an object from a list using reference equality .
63
11
37,877
private static < T > boolean containsIdentity ( List < T > list , T object ) { for ( T item : list ) { if ( item == object ) { return true ; } } return false ; }
Searches for an item in a list using reference equality .
44
13
37,878
public ChainingXmlWriter register ( String parameterName , ICalDataType dataType ) { parameterDataTypes . put ( parameterName , dataType ) ; return this ; }
Registers the data type of a non - standard parameter . Non - standard parameters use the unknown data type by default .
37
24
37,879
public void setScribeIndex ( ScribeIndex index ) { this . index = index ; serializer . setScribeIndex ( index ) ; deserializer . setScribeIndex ( index ) ; }
Sets the scribe index for the serializer and deserializer to use .
43
17
37,880
public static JCalValue multi ( List < ? > values ) { List < JsonValue > multiValues = new ArrayList < JsonValue > ( values . size ( ) ) ; for ( Object value : values ) { multiValues . add ( new JsonValue ( value ) ) ; } return new JCalValue ( multiValues ) ; }
Creates a multi - valued value .
73
8
37,881
public static JCalValue structured ( List < List < ? > > values ) { List < JsonValue > array = new ArrayList < JsonValue > ( values . size ( ) ) ; for ( List < ? > list : values ) { if ( list . isEmpty ( ) ) { array . add ( new JsonValue ( "" ) ) ; continue ; } if ( list . size ( ) == 1 ) { Object value = list . get ( ...
Creates a structured value .
218
6
37,882
public static JCalValue object ( ListMultimap < String , Object > value ) { Map < String , JsonValue > object = new LinkedHashMap < String , JsonValue > ( ) ; for ( Map . Entry < String , List < Object > > entry : value ) { String key = entry . getKey ( ) ; List < Object > list = entry . getValue ( ) ; JsonValue v ; if...
Creates an object value .
202
6
37,883
public String asSingle ( ) { if ( values . isEmpty ( ) ) { return "" ; } JsonValue first = values . get ( 0 ) ; if ( first . isNull ( ) ) { return "" ; } Object obj = first . getValue ( ) ; if ( obj != null ) { return obj . toString ( ) ; } //get the first element of the array List < JsonValue > array = first . getArra...
Parses this jCal value as a single - valued property value .
146
15
37,884
public List < List < String > > asStructured ( ) { if ( values . isEmpty ( ) ) { return Collections . emptyList ( ) ; } JsonValue first = values . get ( 0 ) ; //["request-status", {}, "text", ["2.0", "Success"] ] List < JsonValue > array = first . getArray ( ) ; if ( array != null ) { List < List < String >> components...
Parses this jCal value as a structured property value .
579
13
37,885
public List < String > asMulti ( ) { if ( values . isEmpty ( ) ) { return Collections . emptyList ( ) ; } List < String > multi = new ArrayList < String > ( values . size ( ) ) ; for ( JsonValue value : values ) { if ( value . isNull ( ) ) { multi . add ( "" ) ; continue ; } Object obj = value . getValue ( ) ; if ( obj...
Parses this jCal value as a multi - valued property value .
116
15
37,886
public ListMultimap < String , String > asObject ( ) { if ( values . isEmpty ( ) ) { return new ListMultimap < String , String > ( 0 ) ; } Map < String , JsonValue > map = values . get ( 0 ) . getObject ( ) ; if ( map == null ) { return new ListMultimap < String , String > ( 0 ) ; } ListMultimap < String , String > val...
Parses this jCal value as an object property value .
302
13
37,887
public static DateTimeComponents parse ( String dateString , Boolean hasTime ) { Matcher m = regex . matcher ( dateString ) ; if ( ! m . find ( ) ) { throw Messages . INSTANCE . getIllegalArgumentException ( 19 , dateString ) ; } int i = 1 ; int year = Integer . parseInt ( m . group ( i ++ ) ) ; int month = Integer . p...
Parses the components out of a date - time string .
304
13
37,888
public static RecurrenceIterator createRecurrenceIterator ( Collection < ? extends DateValue > dates ) { DateValue [ ] datesArray = dates . toArray ( new DateValue [ 0 ] ) ; return new RDateIteratorImpl ( datesArray ) ; }
Creates a recurrence iterator from an RDATE or EXDATE list .
52
16
37,889
public static RecurrenceIterable createRecurrenceIterable ( final Recurrence rrule , final DateValue dtStart , final TimeZone tzid ) { return new RecurrenceIterable ( ) { public RecurrenceIterator iterator ( ) { return createRecurrenceIterator ( rrule , dtStart , tzid ) ; } } ; }
Creates a recurrence iterable from an RRULE .
72
12
37,890
public static RecurrenceIterator join ( RecurrenceIterator first , RecurrenceIterator ... rest ) { List < RecurrenceIterator > all = new ArrayList < RecurrenceIterator > ( ) ; all . add ( first ) ; all . addAll ( Arrays . asList ( rest ) ) ; return new CompoundIteratorImpl ( all , Collections . < RecurrenceIterator > e...
Generates a recurrence iterator that iterates over the union of the given recurrence iterators .
83
20
37,891
public static Duration parse ( String value ) { /* * Implementation note: Regular expressions are not used to improve * performance. */ if ( value . length ( ) == 0 ) { throw parseError ( value ) ; } int index = 0 ; char first = value . charAt ( index ) ; boolean prior = ( first == ' ' ) ; if ( first == ' ' || first ==...
Parses a duration string .
370
7
37,892
public static Duration diff ( Date start , Date end ) { return fromMillis ( end . getTime ( ) - start . getTime ( ) ) ; }
Builds a duration based on the difference between two dates .
33
12
37,893
public static Duration fromMillis ( long milliseconds ) { Duration . Builder builder = builder ( ) ; if ( milliseconds < 0 ) { builder . prior ( true ) ; milliseconds *= - 1 ; } int seconds = ( int ) ( milliseconds / 1000 ) ; Integer weeks = seconds / ( 60 * 60 * 24 * 7 ) ; if ( weeks > 0 ) { builder . weeks ( weeks ) ...
Builds a duration from a number of milliseconds .
216
10
37,894
public long toMillis ( ) { long totalSeconds = 0 ; if ( weeks != null ) { totalSeconds += 60L * 60 * 24 * 7 * weeks ; } if ( days != null ) { totalSeconds += 60L * 60 * 24 * days ; } if ( hours != null ) { totalSeconds += 60L * 60 * hours ; } if ( minutes != null ) { totalSeconds += 60L * minutes ; } if ( seconds != nu...
Converts the duration value to milliseconds .
131
8
37,895
private static DateValue [ ] removeDuplicates ( DateValue [ ] dates ) { int k = 0 ; for ( int i = 1 ; i < dates . length ; ++ i ) { if ( ! dates [ i ] . equals ( dates [ k ] ) ) { dates [ ++ k ] = dates [ i ] ; } } if ( ++ k < dates . length ) { DateValue [ ] uniqueDates = new DateValue [ k ] ; System . arraycopy ( dat...
Removes duplicates from a list of date values .
123
11
37,896
public T emptyInstance ( ) { T component = _newInstance ( ) ; //remove any properties/components that were created in the constructor component . getProperties ( ) . clear ( ) ; component . getComponents ( ) . clear ( ) ; return component ; }
Creates a new instance of the component class that doesn t have any properties or sub - components .
57
20
37,897
public List < ICalComponent > getComponents ( T component ) { return new ArrayList < ICalComponent > ( component . getComponents ( ) . values ( ) ) ; }
Gets the sub - components to marshal . Child classes can override this for better control over which components are marshalled .
39
25
37,898
public List < ICalProperty > getProperties ( T component ) { return new ArrayList < ICalProperty > ( component . getProperties ( ) . values ( ) ) ; }
Gets the properties to marshal . Child classes can override this for better control over which properties are marshalled .
39
23
37,899
public void registerParameterDataType ( String parameterName , ICalDataType dataType ) { parameterName = parameterName . toLowerCase ( ) ; if ( dataType == null ) { parameterDataTypes . remove ( parameterName ) ; } else { parameterDataTypes . put ( parameterName , dataType ) ; } }
Registers the data type of an experimental parameter . Experimental parameters use the unknown data type by default .
67
20