idx
int64
0
41.2k
question
stringlengths
74
4.04k
target
stringlengths
7
750
37,800
public List < WarningsGroup > getByProperty ( Class < ? extends ICalProperty > propertyClass ) { List < WarningsGroup > warnings = new ArrayList < WarningsGroup > ( ) ; for ( WarningsGroup group : this . warnings ) { ICalProperty property = group . getProperty ( ) ; if ( property == null ) { continue ; } if ( propertyClass == property . getClass ( ) ) { warnings . add ( group ) ; } } return warnings ; }
Gets all validation warnings of a given property .
37,801
public List < WarningsGroup > getByComponent ( Class < ? extends ICalComponent > componentClass ) { List < WarningsGroup > warnings = new ArrayList < WarningsGroup > ( ) ; for ( WarningsGroup group : this . warnings ) { ICalComponent component = group . getComponent ( ) ; if ( component == null ) { continue ; } if ( componentClass == component . getClass ( ) ) { warnings . add ( group ) ; } } return warnings ; }
Gets all validation warnings of a given component .
37,802
public String go ( ) { StringWriter sw = new StringWriter ( ) ; try { go ( sw ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } return sw . toString ( ) ; }
Writes the iCalendar objects to a string .
37,803
public void addDate ( ICalDate date , boolean floating , TimeZone tz ) { if ( date != null && date . hasTime ( ) && ! floating && tz != null ) { dates . add ( date ) ; } }
Records the timezoned date - time values that are being written . This is used to generate a DAYLIGHT property for vCalendar objects .
37,804
public T get ( V value ) { T found = find ( value ) ; if ( found != null ) { return found ; } synchronized ( runtimeDefined ) { for ( T obj : runtimeDefined ) { if ( matches ( obj , value ) ) { return obj ; } } T created = create ( value ) ; runtimeDefined . add ( created ) ; return created ; } }
Searches for a case object by value creating a new object if one cannot be found .
37,805
public String asString ( String charset ) throws IOException { Reader reader = buildReader ( charset ) ; return consumeReader ( reader ) ; }
Gets the stream contents as a string .
37,806
public byte [ ] asByteArray ( ) throws IOException { if ( reader != null ) { throw new IllegalStateException ( "Cannot get raw bytes from a Reader object." ) ; } InputStream in = buildInputStream ( ) ; return consumeInputStream ( in ) ; }
Gets the stream contents as a byte array .
37,807
public Name setName ( String name ) { Name property = ( name == null ) ? null : new Name ( name ) ; setName ( property ) ; return property ; }
Sets the human - readable name of the calendar as a whole .
37,808
public Description setDescription ( String description ) { Description property = ( description == null ) ? null : new Description ( description ) ; setDescription ( property ) ; return property ; }
Sets the human - readable description of the calendar as a whole .
37,809
public Uid setUid ( String uid ) { Uid property = ( uid == null ) ? null : new Uid ( uid ) ; setUid ( property ) ; return property ; }
Sets the calendar s unique identifier .
37,810
public LastModified setLastModified ( Date lastModified ) { LastModified property = ( lastModified == null ) ? null : new LastModified ( lastModified ) ; setLastModified ( property ) ; return property ; }
Sets the date and time that the information in this calendar object was last revised .
37,811
public Categories addCategories ( String ... categories ) { Categories prop = new Categories ( categories ) ; addProperty ( prop ) ; return prop ; }
Adds a list of keywords that describe the calendar .
37,812
public RefreshInterval setRefreshInterval ( Duration refreshInterval ) { RefreshInterval property = ( refreshInterval == null ) ? null : new RefreshInterval ( refreshInterval ) ; setRefreshInterval ( property ) ; return property ; }
Sets the suggested minimum polling interval for checking for updates to the calendar data .
37,813
public Source setSource ( String url ) { Source property = ( url == null ) ? null : new Source ( url ) ; setSource ( property ) ; return property ; }
Sets the location that the calendar data can be refreshed from .
37,814
public ICalendar _readNext ( ) throws IOException { if ( reader . eof ( ) ) { return null ; } context . setVersion ( ICalVersion . V2_0 ) ; JCalDataStreamListenerImpl listener = new JCalDataStreamListenerImpl ( ) ; reader . readNext ( listener ) ; return listener . getICalendar ( ) ; }
Reads the next iCalendar object from the JSON data stream .
37,815
public static VAlarm audio ( Trigger trigger , Attachment sound ) { VAlarm alarm = new VAlarm ( Action . audio ( ) , trigger ) ; if ( sound != null ) { alarm . addAttachment ( sound ) ; } return alarm ; }
Creates an audio alarm .
37,816
public static VAlarm display ( Trigger trigger , String displayText ) { VAlarm alarm = new VAlarm ( Action . display ( ) , trigger ) ; alarm . setDescription ( displayText ) ; return alarm ; }
Creates a display alarm .
37,817
public DurationProperty setDuration ( Duration duration ) { DurationProperty prop = ( duration == null ) ? null : new DurationProperty ( duration ) ; setDuration ( prop ) ; return prop ; }
Sets the length of the pause between alarm repetitions .
37,818
public Repeat setRepeat ( Integer count ) { Repeat prop = ( count == null ) ? null : new Repeat ( count ) ; setRepeat ( prop ) ; return prop ; }
Sets the number of times an alarm should be repeated after its initial trigger .
37,819
public void setRepeat ( int count , Duration pauseDuration ) { Repeat repeat = new Repeat ( count ) ; DurationProperty duration = new DurationProperty ( pauseDuration ) ; setRepeat ( repeat ) ; setDuration ( duration ) ; }
Sets the repetition information for the alarm .
37,820
public static Document createDocument ( ) { try { DocumentBuilderFactory fact = DocumentBuilderFactory . newInstance ( ) ; fact . setNamespaceAware ( true ) ; DocumentBuilder db = fact . newDocumentBuilder ( ) ; return db . newDocument ( ) ; } catch ( ParserConfigurationException e ) { throw new RuntimeException ( e ) ; } }
Creates a new XML document .
37,821
public static Document toDocument ( String xml ) throws SAXException { try { return toDocument ( new StringReader ( xml ) ) ; } catch ( IOException e ) { throw new RuntimeException ( e ) ; } }
Parses an XML string into a DOM .
37,822
public static Document toDocument ( File file ) throws SAXException , IOException { InputStream in = new BufferedInputStream ( new FileInputStream ( file ) ) ; try { return XmlUtils . toDocument ( in ) ; } finally { in . close ( ) ; } }
Parses an XML document from a file .
37,823
private static Element getFirstChildElement ( Node parent ) { NodeList nodeList = parent . getChildNodes ( ) ; for ( int i = 0 ; i < nodeList . getLength ( ) ; i ++ ) { Node node = nodeList . item ( i ) ; if ( node instanceof Element ) { return ( Element ) node ; } } return null ; }
Gets the first child element of a node .
37,824
public static boolean hasQName ( Node node , QName qname ) { return qname . getNamespaceURI ( ) . equals ( node . getNamespaceURI ( ) ) && qname . getLocalPart ( ) . equals ( node . getLocalName ( ) ) ; }
Determines if a node has a particular qualified name .
37,825
public void close ( ) throws IOException { if ( thread . isAlive ( ) ) { thread . closed = true ; thread . interrupt ( ) ; } if ( stream != null ) { stream . close ( ) ; } }
Closes the underlying input stream .
37,826
public static DataUri parse ( String uri ) { String scheme = "data:" ; if ( uri . length ( ) < scheme . length ( ) || ! uri . substring ( 0 , scheme . length ( ) ) . equalsIgnoreCase ( scheme ) ) { throw Messages . INSTANCE . getIllegalArgumentException ( 22 ) ; } String contentType = null ; String charset = null ; boolean base64 = false ; String dataStr = null ; int tokenStart = scheme . length ( ) ; for ( int i = scheme . length ( ) ; i < uri . length ( ) ; i ++ ) { char c = uri . charAt ( i ) ; if ( c == ';' ) { String token = uri . substring ( tokenStart , i ) ; if ( contentType == null ) { contentType = token . toLowerCase ( ) ; } else { String cs = StringUtils . afterPrefixIgnoreCase ( token , "charset=" ) ; if ( cs != null ) { charset = cs ; } else if ( "base64" . equalsIgnoreCase ( token ) ) { base64 = true ; } } tokenStart = i + 1 ; continue ; } if ( c == ',' ) { String token = uri . substring ( tokenStart , i ) ; if ( contentType == null ) { contentType = token . toLowerCase ( ) ; } else { String cs = StringUtils . afterPrefixIgnoreCase ( token , "charset=" ) ; if ( cs != null ) { charset = cs ; } else if ( "base64" . equalsIgnoreCase ( token ) ) { base64 = true ; } } dataStr = uri . substring ( i + 1 ) ; break ; } } if ( dataStr == null ) { throw Messages . INSTANCE . getIllegalArgumentException ( 23 ) ; } String text = null ; byte [ ] data = null ; if ( base64 ) { dataStr = dataStr . replaceAll ( "\\s" , "" ) ; data = Base64 . decodeBase64 ( dataStr ) ; if ( charset != null ) { try { text = new String ( data , charset ) ; } catch ( UnsupportedEncodingException e ) { throw new IllegalArgumentException ( Messages . INSTANCE . getExceptionMessage ( 24 , charset ) , e ) ; } data = null ; } } else { text = dataStr ; } return new DataUri ( contentType , data , text ) ; }
Parses a data URI string .
37,827
public String toCuaPriority ( ) { if ( value == null || value < 1 || value > 9 ) { return null ; } int letter = ( ( value - 1 ) / 3 ) + 'A' ; int number = ( ( value - 1 ) % 3 ) + 1 ; return ( char ) letter + "" + number ; }
Converts this priority to its two - character CUA code .
37,828
public List < ICalendar > readAll ( ) throws IOException { List < ICalendar > icals = new ArrayList < ICalendar > ( ) ; ICalendar ical ; while ( ( ical = readNext ( ) ) != null ) { icals . add ( ical ) ; } return icals ; }
Reads all iCalendar objects from the data stream .
37,829
public ICalendar readNext ( ) throws IOException { warnings . clear ( ) ; context = new ParseContext ( ) ; ICalendar ical = _readNext ( ) ; if ( ical == null ) { return null ; } ical . setVersion ( context . getVersion ( ) ) ; handleTimezones ( ical ) ; return ical ; }
Reads the next iCalendar object from the data stream .
37,830
public void putAll ( K key , Collection < ? extends V > values ) { if ( values . isEmpty ( ) ) { return ; } key = sanitizeKey ( key ) ; List < V > list = map . get ( key ) ; if ( list == null ) { list = new ArrayList < V > ( ) ; map . put ( key , list ) ; } list . addAll ( values ) ; }
Adds multiple values to the multimap .
37,831
public List < V > get ( K key ) { key = sanitizeKey ( key ) ; List < V > value = map . get ( key ) ; if ( value == null ) { value = new ArrayList < V > ( 0 ) ; } return new WrappedList ( key , value , null ) ; }
Gets the values associated with the key . Changes to the returned list will update the underlying multimap and vice versa .
37,832
public V first ( K key ) { key = sanitizeKey ( key ) ; List < V > values = map . get ( key ) ; return ( values == null ) ? null : values . get ( 0 ) ; }
Gets the first value that s associated with a key .
37,833
public boolean remove ( K key , V value ) { key = sanitizeKey ( key ) ; List < V > values = map . get ( key ) ; if ( values == null ) { return false ; } boolean success = values . remove ( value ) ; if ( values . isEmpty ( ) ) { map . remove ( key ) ; } return success ; }
Removes a particular value .
37,834
public List < V > removeAll ( K key ) { key = sanitizeKey ( key ) ; List < V > removed = map . remove ( key ) ; if ( removed == null ) { return Collections . emptyList ( ) ; } List < V > unmodifiableCopy = Collections . unmodifiableList ( new ArrayList < V > ( removed ) ) ; removed . clear ( ) ; return unmodifiableCopy ; }
Removes all the values associated with a key
37,835
public List < V > replace ( K key , V value ) { List < V > replaced = removeAll ( key ) ; if ( value != null ) { put ( key , value ) ; } return replaced ; }
Replaces all values with the given value .
37,836
public List < V > replace ( K key , Collection < ? extends V > values ) { List < V > replaced = removeAll ( key ) ; putAll ( key , values ) ; return replaced ; }
Replaces all values with the given values .
37,837
public void clear ( ) { for ( List < V > value : map . values ( ) ) { value . clear ( ) ; } map . clear ( ) ; }
Clears all entries from the multimap .
37,838
public List < V > values ( ) { List < V > list = new ArrayList < V > ( ) ; for ( List < V > value : map . values ( ) ) { list . addAll ( value ) ; } return Collections . unmodifiableList ( list ) ; }
Gets all the values in the multimap .
37,839
public int size ( ) { int size = 0 ; for ( List < V > value : map . values ( ) ) { size += value . size ( ) ; } return size ; }
Gets the number of values in the map .
37,840
public Integer getIndent ( ) { if ( ! "yes" . equals ( get ( OutputKeys . INDENT ) ) ) { return null ; } String value = get ( INDENT_AMT ) ; return ( value == null ) ? null : Integer . valueOf ( value ) ; }
Gets the number of indent spaces to use for pretty - printing .
37,841
public static UtcOffset parse ( String text ) { Pattern timeZoneRegex = Pattern . compile ( "^([-\\+])?(\\d{1,2})(:?(\\d{2}))?(:?(\\d{2}))?$" ) ; Matcher m = timeZoneRegex . matcher ( text ) ; if ( ! m . find ( ) ) { throw Messages . INSTANCE . getIllegalArgumentException ( 21 , text ) ; } String signStr = m . group ( 1 ) ; boolean positive = ! "-" . equals ( signStr ) ; String hourStr = m . group ( 2 ) ; int hourOffset = Integer . parseInt ( hourStr ) ; String minuteStr = m . group ( 4 ) ; int minuteOffset = ( minuteStr == null ) ? 0 : Integer . parseInt ( minuteStr ) ; return new UtcOffset ( positive , hourOffset , minuteOffset ) ; }
Parses a UTC offset from a string .
37,842
private List < String > splitRRULEValues ( String value ) { List < String > values = new ArrayList < String > ( ) ; Pattern p = Pattern . compile ( "#\\d+|\\d{8}T\\d{6}Z?" ) ; Matcher m = p . matcher ( value ) ; int prevIndex = 0 ; while ( m . find ( ) ) { int end = m . end ( ) ; String subValue = value . substring ( prevIndex , end ) . trim ( ) ; values . add ( subValue ) ; prevIndex = end ; } String subValue = value . substring ( prevIndex ) . trim ( ) ; if ( subValue . length ( ) > 0 ) { values . add ( subValue ) ; } return values ; }
Version 1 . 0 allows multiple RRULE values to be defined inside of the same property . This method extracts each RRULE value from the property value .
37,843
private List < Observance > calculateSortedObservances ( ) { List < DaylightSavingsTime > daylights = component . getDaylightSavingsTime ( ) ; List < StandardTime > standards = component . getStandardTimes ( ) ; int numObservances = standards . size ( ) + daylights . size ( ) ; List < Observance > sortedObservances = new ArrayList < Observance > ( numObservances ) ; sortedObservances . addAll ( standards ) ; sortedObservances . addAll ( daylights ) ; Collections . sort ( sortedObservances , new Comparator < Observance > ( ) { public int compare ( Observance left , Observance right ) { ICalDate startLeft = getValue ( left . getDateStart ( ) ) ; ICalDate startRight = getValue ( right . getDateStart ( ) ) ; if ( startLeft == null && startRight == null ) { return 0 ; } if ( startLeft == null ) { return - 1 ; } if ( startRight == null ) { return 1 ; } return startLeft . getRawComponents ( ) . compareTo ( startRight . getRawComponents ( ) ) ; } } ) ; return Collections . unmodifiableList ( sortedObservances ) ; }
Builds a list of all the observances in the VTIMEZONE component sorted by DTSTART .
37,844
public Boundary getObservanceBoundary ( Date date ) { utcCalendar . setTime ( date ) ; int year = utcCalendar . get ( Calendar . YEAR ) ; int month = utcCalendar . get ( Calendar . MONTH ) + 1 ; int day = utcCalendar . get ( Calendar . DATE ) ; int hour = utcCalendar . get ( Calendar . HOUR ) ; int minute = utcCalendar . get ( Calendar . MINUTE ) ; int second = utcCalendar . get ( Calendar . SECOND ) ; return getObservanceBoundary ( year , month , day , hour , minute , second ) ; }
Gets the timezone information of a date .
37,845
private Boundary getObservanceBoundary ( int year , int month , int day , int hour , int minute , int second ) { if ( sortedObservances . isEmpty ( ) ) { return null ; } DateValue givenTime = new DateTimeValueImpl ( year , month , day , hour , minute , second ) ; int closestIndex = - 1 ; Observance closest = null ; DateValue closestValue = null ; for ( int i = 0 ; i < sortedObservances . size ( ) ; i ++ ) { Observance observance = sortedObservances . get ( i ) ; ICalDate dtstart = getValue ( observance . getDateStart ( ) ) ; if ( dtstart != null ) { DateValue dtstartValue = convertFromRawComponents ( dtstart ) ; if ( dtstartValue . compareTo ( givenTime ) > 0 ) { continue ; } } DateValue dateValue = getObservanceDateClosestToTheGivenDate ( observance , givenTime , false ) ; if ( dateValue != null && ( closestValue == null || closestValue . compareTo ( dateValue ) < 0 ) ) { closestValue = dateValue ; closest = observance ; closestIndex = i ; } } Observance observanceIn = closest ; DateValue observanceInStart = closestValue ; Observance observanceAfter = null ; DateValue observanceAfterStart = null ; if ( closestIndex < sortedObservances . size ( ) - 1 ) { observanceAfter = sortedObservances . get ( closestIndex + 1 ) ; observanceAfterStart = getObservanceDateClosestToTheGivenDate ( observanceAfter , givenTime , true ) ; } if ( observanceInStart != null && ! ( observanceInStart instanceof DateTimeValue ) ) { observanceInStart = new DTBuilder ( observanceInStart ) . toDateTime ( ) ; } if ( observanceAfterStart != null && ! ( observanceAfterStart instanceof DateTimeValue ) ) { observanceAfterStart = new DTBuilder ( observanceAfterStart ) . toDateTime ( ) ; } return new Boundary ( ( DateTimeValue ) observanceInStart , observanceIn , ( DateTimeValue ) observanceAfterStart , observanceAfter ) ; }
Gets the observance information of a date .
37,846
private DateValue getObservanceDateClosestToTheGivenDate ( Observance observance , DateValue givenDate , boolean after ) { List < DateValue > dateCache = observanceDateCache . get ( observance ) ; if ( dateCache == null ) { dateCache = new ArrayList < DateValue > ( ) ; observanceDateCache . put ( observance , dateCache ) ; } if ( dateCache . isEmpty ( ) ) { DateValue prev = null , cur = null ; boolean stopped = false ; RecurrenceIterator it = createIterator ( observance ) ; while ( it . hasNext ( ) ) { cur = it . next ( ) ; dateCache . add ( cur ) ; if ( givenDate . compareTo ( cur ) < 0 ) { stopped = true ; break ; } prev = cur ; } return after ? ( stopped ? cur : null ) : prev ; } DateValue last = dateCache . get ( dateCache . size ( ) - 1 ) ; int comparison = last . compareTo ( givenDate ) ; if ( ( after && comparison <= 0 ) || comparison < 0 ) { RecurrenceIterator it = createIterator ( observance ) ; it . advanceTo ( last ) ; DateValue prev = null , cur = null ; boolean stopped = false ; while ( it . hasNext ( ) ) { cur = it . next ( ) ; dateCache . add ( cur ) ; if ( givenDate . compareTo ( cur ) < 0 ) { stopped = true ; break ; } prev = cur ; } return after ? ( stopped ? cur : null ) : prev ; } int index = Collections . binarySearch ( dateCache , givenDate ) ; if ( index < 0 ) { index = ( index * - 1 ) - 1 ; if ( after ) { int afterIndex = index ; return ( afterIndex < dateCache . size ( ) ) ? dateCache . get ( afterIndex ) : null ; } int beforeIndex = index - 1 ; if ( beforeIndex < 0 ) { return null ; } if ( beforeIndex >= dateCache . size ( ) ) { return dateCache . get ( dateCache . size ( ) - 1 ) ; } return dateCache . get ( beforeIndex ) ; } if ( after ) { int afterIndex = index + 1 ; return ( afterIndex < dateCache . size ( ) ) ? dateCache . get ( afterIndex ) : null ; } return dateCache . get ( index ) ; }
Iterates through each of the timezone boundary dates defined by the given observance and finds the date that comes closest to the given date .
37,847
RecurrenceIterator createIterator ( Observance observance ) { List < RecurrenceIterator > inclusions = new ArrayList < RecurrenceIterator > ( ) ; List < RecurrenceIterator > exclusions = new ArrayList < RecurrenceIterator > ( ) ; ICalDate dtstart = getValue ( observance . getDateStart ( ) ) ; if ( dtstart != null ) { DateValue dtstartValue = convertFromRawComponents ( dtstart ) ; inclusions . add ( new DateValueRecurrenceIterator ( Arrays . asList ( dtstartValue ) ) ) ; for ( RecurrenceRule rrule : observance . getProperties ( RecurrenceRule . class ) ) { Recurrence recur = rrule . getValue ( ) ; if ( recur != null ) { inclusions . add ( RecurrenceIteratorFactory . createRecurrenceIterator ( recur , dtstartValue , utc ) ) ; } } for ( ExceptionRule exrule : observance . getProperties ( ExceptionRule . class ) ) { Recurrence recur = exrule . getValue ( ) ; if ( recur != null ) { exclusions . add ( RecurrenceIteratorFactory . createRecurrenceIterator ( recur , dtstartValue , utc ) ) ; } } } List < ICalDate > rdates = new ArrayList < ICalDate > ( ) ; for ( RecurrenceDates rdate : observance . getRecurrenceDates ( ) ) { rdates . addAll ( rdate . getDates ( ) ) ; } Collections . sort ( rdates ) ; inclusions . add ( new DateRecurrenceIterator ( rdates ) ) ; List < ICalDate > exdates = new ArrayList < ICalDate > ( ) ; for ( ExceptionDates exdate : observance . getProperties ( ExceptionDates . class ) ) { exdates . addAll ( exdate . getValues ( ) ) ; } Collections . sort ( exdates ) ; exclusions . add ( new DateRecurrenceIterator ( exdates ) ) ; RecurrenceIterator included = join ( inclusions ) ; if ( exclusions . isEmpty ( ) ) { return included ; } RecurrenceIterator excluded = join ( exclusions ) ; return RecurrenceIteratorFactory . except ( included , excluded ) ; }
Creates an iterator which iterates over each of the dates in an observance .
37,848
public Classification setClassification ( String classification ) { Classification prop = ( classification == null ) ? null : new Classification ( classification ) ; setClassification ( prop ) ; return prop ; }
Sets the level of sensitivity of the journal entry . If not specified the data within the journal entry should be considered public .
37,849
public Created setCreated ( Date created ) { Created prop = ( created == null ) ? null : new Created ( created ) ; setCreated ( prop ) ; return prop ; }
Sets the date - time that the journal entry was initially created .
37,850
public DateStart setDateStart ( Date dateStart , boolean hasTime ) { DateStart prop = ( dateStart == null ) ? null : new DateStart ( dateStart , hasTime ) ; setDateStart ( prop ) ; return prop ; }
Sets the date that the journal entry starts .
37,851
public LastModified setLastModified ( Date lastModified ) { LastModified prop = ( lastModified == null ) ? null : new LastModified ( lastModified ) ; setLastModified ( prop ) ; return prop ; }
Sets the date - time that the journal entry was last changed .
37,852
public Organizer setOrganizer ( String email ) { Organizer prop = ( email == null ) ? null : new Organizer ( null , email ) ; setOrganizer ( prop ) ; return prop ; }
Sets the organizer of the journal entry .
37,853
public Sequence setSequence ( Integer sequence ) { Sequence prop = ( sequence == null ) ? null : new Sequence ( sequence ) ; setSequence ( prop ) ; return prop ; }
Sets the revision number of the journal entry . The organizer can increment this number every time he or she makes a significant change .
37,854
public Url setUrl ( String url ) { Url prop = ( url == null ) ? null : new Url ( url ) ; setUrl ( prop ) ; return prop ; }
Sets a URL to a resource that contains additional information about the journal entry .
37,855
public RecurrenceRule setRecurrenceRule ( Recurrence recur ) { RecurrenceRule prop = ( recur == null ) ? null : new RecurrenceRule ( recur ) ; setRecurrenceRule ( prop ) ; return prop ; }
Sets how often the journal entry repeats .
37,856
public Comment addComment ( String comment ) { Comment prop = new Comment ( comment ) ; addComment ( prop ) ; return prop ; }
Adds a comment to the journal entry .
37,857
public RelatedTo addRelatedTo ( String uid ) { RelatedTo prop = new RelatedTo ( uid ) ; addRelatedTo ( prop ) ; return prop ; }
Adds a component that the journal entry is related to .
37,858
public static void repeat ( char c , int count , StringBuilder sb ) { for ( int i = 0 ; i < count ; i ++ ) { sb . append ( c ) ; } }
Creates a string consisting of count occurrences of char c .
37,859
public TimezoneUrl setTimezoneUrl ( String url ) { TimezoneUrl prop = ( url == null ) ? null : new TimezoneUrl ( url ) ; setTimezoneUrl ( prop ) ; return prop ; }
Sets the timezone URL which points to an iCalendar object that contains further information on the timezone .
37,860
public void setDuration ( Duration duration , Related related ) { this . date = null ; this . duration = duration ; setRelated ( related ) ; }
Sets a relative time at which the alarm will trigger .
37,861
protected Collection < ICalVersion > getValueSupportedVersions ( ) { return ( value == null ) ? Collections . < ICalVersion > emptyList ( ) : Arrays . asList ( ICalVersion . values ( ) ) ; }
Gets the iCalendar versions that this property s value is supported in . Meant to be overridden by the child class .
37,862
public Location setLocation ( String location ) { Location prop = ( location == null ) ? null : new Location ( location ) ; setLocation ( prop ) ; return prop ; }
Sets the physical location of the event .
37,863
public Priority setPriority ( Integer priority ) { Priority prop = ( priority == null ) ? null : new Priority ( priority ) ; setPriority ( prop ) ; return prop ; }
Sets the priority of the event .
37,864
public Resources addResources ( String ... resources ) { Resources prop = new Resources ( resources ) ; addResources ( prop ) ; return prop ; }
Adds a list of resources that are needed for the event .
37,865
public void readNext ( JCalDataStreamListener listener ) throws IOException { if ( parser == null ) { JsonFactory factory = new JsonFactory ( ) ; parser = factory . createParser ( reader ) ; } if ( parser . isClosed ( ) ) { return ; } this . listener = listener ; JsonToken prev = parser . getCurrentToken ( ) ; JsonToken cur ; while ( ( cur = parser . nextToken ( ) ) != null ) { if ( prev == JsonToken . START_ARRAY && cur == JsonToken . VALUE_STRING && VCALENDAR_COMPONENT_NAME . equals ( parser . getValueAsString ( ) ) ) { break ; } if ( strict ) { if ( prev != JsonToken . START_ARRAY ) { throw new JCalParseException ( JsonToken . START_ARRAY , prev ) ; } if ( cur != JsonToken . VALUE_STRING ) { throw new JCalParseException ( JsonToken . VALUE_STRING , cur ) ; } throw new JCalParseException ( "Invalid value for first token: expected \"vcalendar\" , was \"" + parser . getValueAsString ( ) + "\"" , JsonToken . VALUE_STRING , cur ) ; } prev = cur ; } if ( cur == null ) { eof = true ; return ; } parseComponent ( new ArrayList < String > ( ) ) ; }
Reads the next iCalendar object from the jCal data stream .
37,866
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 ( ) ) { reader . close ( ) ; } } }
Reads the first iCalendar object from the stream .
37,867
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 ) { warnings . add ( reader . getWarnings ( ) ) ; } icals . add ( ical ) ; } return icals ; } finally { if ( closeWhenDone ( ) ) { reader . close ( ) ; } } }
Reads all iCalendar objects from the stream .
37,868
static Predicate < DateValue > weekIntervalFilter ( final int interval , final DayOfWeek weekStart , final DateValue dtStart ) { return new Predicate < DateValue > ( ) { private static final long serialVersionUID = 7059994888520369846L ; DateValue wkStart ; { DTBuilder wkStartB = new DTBuilder ( dtStart ) ; wkStartB . day -= ( 7 + TimeUtils . dayOfWeek ( dtStart ) . getCalendarConstant ( ) - weekStart . getCalendarConstant ( ) ) % 7 ; wkStart = wkStartB . toDate ( ) ; } public boolean apply ( DateValue date ) { int daysBetween = TimeUtils . daysBetween ( date , wkStart ) ; if ( daysBetween < 0 ) { daysBetween += ( interval * 7 * ( 1 + daysBetween / ( - 7 * interval ) ) ) ; } int off = ( daysBetween / 7 ) % interval ; return off == 0 ; } } ; }
Constructs a filter that accepts only every X week starting from the week containing the given date .
37,869
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 static final long serialVersionUID = - 6284974028385246889L ; public boolean apply ( DateValue date ) { if ( ! ( date instanceof TimeValue ) ) { return false ; } TimeValue tv = ( TimeValue ) date ; return ( bitField & ( 1 << tv . hour ( ) ) ) != 0 ; } } ; }
Constructs an hour filter based on a BYHOUR rule .
37,870
public String first ( ICalDataType dataType ) { String dataTypeStr = toLocalName ( dataType ) ; return first ( dataTypeStr ) ; }
Gets the first value of the given data type .
37,871
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 .
37,872
public List < String > all ( ICalDataType dataType ) { String dataTypeStr = toLocalName ( dataType ) ; return all ( dataTypeStr ) ; }
Gets all the values of a given data type .
37,873
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 . add ( text ) ; } } return childrenText ; }
Gets the values of all child elements that have the given name .
37,874
public Element append ( ICalDataType dataType , String value ) { String dataTypeStr = toLocalName ( dataType ) ; return append ( dataTypeStr , value ) ; }
Adds a value .
37,875
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 .
37,876
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 .
37,877
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 . getNamespaceURI ( ) ) ) { children . add ( new XCalElement ( child ) ) ; } } return children ; }
Gets all child elements with the given data type .
37,878
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 .
37,879
public void close ( ) throws IOException { try { if ( ! started ) { handler . startDocument ( ) ; if ( ! icalendarElementExists ) { start ( ICALENDAR ) ; } } if ( ! icalendarElementExists ) { end ( ICALENDAR ) ; } handler . endDocument ( ) ; } catch ( SAXException e ) { throw new IOException ( e ) ; } if ( writer != null ) { writer . close ( ) ; } }
Terminates the XML document and closes the output stream .
37,880
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 = true ; } if ( ! parent . wroteStartSubComponentsArray ) { generator . writeStartArray ( ) ; parent . wroteStartSubComponentsArray = true ; } } generator . writeStartArray ( ) ; generator . writeString ( componentName ) ; generator . writeStartArray ( ) ; stack . add ( new Info ( ) ) ; }
Writes the beginning of a new component array .
37,881
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 . wroteStartSubComponentsArray ) { generator . writeStartArray ( ) ; } generator . writeEndArray ( ) ; generator . writeEndArray ( ) ; componentEnded = true ; }
Closes the current component array .
37,882
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 .
37,883
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 ( hourGenerator , minuteGenerator , secondGenerator ) ) { return new Generator ( ) { public boolean generate ( DTBuilder builder ) throws IteratorShortCircuitingException { do { while ( ! dayGenerator . generate ( builder ) ) { while ( ! monthGenerator . generate ( builder ) ) { if ( ! yearGenerator . generate ( builder ) ) { return false ; } } } } while ( ! filter . apply ( builder . toDateTime ( ) ) ) ; return true ; } } ; } else { return new Generator ( ) { public boolean generate ( DTBuilder builder ) throws IteratorShortCircuitingException { do { while ( ! secondGenerator . generate ( builder ) ) { while ( ! minuteGenerator . generate ( builder ) ) { while ( ! hourGenerator . generate ( builder ) ) { while ( ! dayGenerator . generate ( builder ) ) { while ( ! monthGenerator . generate ( builder ) ) { if ( ! yearGenerator . generate ( builder ) ) { return false ; } } } } } } } while ( ! filter . apply ( builder . toDateTime ( ) ) ) ; return true ; } } ; } }
A collector that yields each date in the period without doing any set collecting .
37,884
public void setParameters ( ICalParameters parameters ) { if ( parameters == null ) { throw new NullPointerException ( Messages . INSTANCE . getExceptionMessage ( 16 ) ) ; } this . parameters = parameters ; }
Sets the property s parameters
37,885
public List < String > getParameters ( String name ) { return Collections . unmodifiableList ( parameters . get ( name ) ) ; }
Gets all values of a parameter with the given name .
37,886
public void setParameter ( String name , Collection < String > values ) { parameters . replace ( name , values ) ; }
Replaces all existing values of a parameter with the given values .
37,887
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 .
37,888
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 .
37,889
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 .
37,890
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 ( ) ; db . minute += tdur . minute ( ) ; db . second += tdur . second ( ) ; return db . toDateTime ( ) ; } return ( date instanceof TimeValue ) ? db . toDateTime ( ) : db . toDate ( ) ; }
Adds a duration to a date .
37,891
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 .
37,892
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 .
37,893
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 .
37,894
public static DateTimeValue timeFromSecsSinceEpoch ( long secsSinceEpoch ) { int secsInDay = ( int ) ( secsSinceEpoch % SECS_PER_DAY ) ; int daysSinceEpoch = ( int ) ( secsSinceEpoch / SECS_PER_DAY ) ; int approx = ( int ) ( ( daysSinceEpoch + 10 ) * 400L / 146097 ) ; int year = ( daysSinceEpoch >= fixedFromGregorian ( approx + 1 , 1 , 1 ) ) ? approx + 1 : approx ; int jan1 = fixedFromGregorian ( year , 1 , 1 ) ; int priorDays = daysSinceEpoch - jan1 ; int march1 = fixedFromGregorian ( year , 3 , 1 ) ; int correction = ( daysSinceEpoch < march1 ) ? 0 : isLeapYear ( year ) ? 1 : 2 ; int month = ( 12 * ( priorDays + correction ) + 373 ) / 367 ; int month1 = fixedFromGregorian ( year , month , 1 ) ; int day = daysSinceEpoch - month1 + 1 ; int second = secsInDay % 60 ; int minutesInDay = secsInDay / 60 ; int minute = minutesInDay % 60 ; int hour = minutesInDay / 60 ; if ( ! ( hour >= 0 && hour < 24 ) ) { throw new AssertionError ( "Input was: " + secsSinceEpoch + "to make hour: " + hour ) ; } return new DateTimeValueImpl ( year , month , day , hour , minute , second ) ; }
Computes the gregorian time from the number of seconds since the Proleptic Gregorian Epoch . See Calendrical Calculations Reingold and Dershowitz .
37,895
@ 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 .
37,896
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 .
37,897
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 .
37,898
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 . getName ( ) ) ; } throw Messages . INSTANCE . getIllegalArgumentException ( 13 , classNames ) ; } tzinfo = ical . getTimezoneInfo ( ) ; context = new WriteContext ( getTargetVersion ( ) , tzinfo , globalTimezone ) ; _write ( ical ) ; }
Writes an iCalendar object to the data stream .
37,899
public TimezoneOffsetTo setTimezoneOffsetTo ( UtcOffset offset ) { TimezoneOffsetTo prop = new TimezoneOffsetTo ( offset ) ; setTimezoneOffsetTo ( prop ) ; return prop ; }
Sets the UTC offset that the timezone observance transitions to .