code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
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 == pr... | java |
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 (componentCla... | java |
public String go() {
StringWriter sw = new StringWriter();
try {
go(sw);
} catch (IOException e) {
//should never be thrown because we're writing to a string
throw new RuntimeException(e);
}
return sw.toString();
} | java |
public void addDate(ICalDate date, boolean floating, TimeZone tz) {
if (date != null && date.hasTime() && !floating && tz != null) {
dates.add(date);
}
} | java |
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;
}
} | java |
public String asString(String charset) throws IOException {
Reader reader = buildReader(charset);
return consumeReader(reader);
} | java |
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);
} | java |
public Name setName(String name) {
Name property = (name == null) ? null : new Name(name);
setName(property);
return property;
} | java |
public Description setDescription(String description) {
Description property = (description == null) ? null : new Description(description);
setDescription(property);
return property;
} | java |
public Uid setUid(String uid) {
Uid property = (uid == null) ? null : new Uid(uid);
setUid(property);
return property;
} | java |
public LastModified setLastModified(Date lastModified) {
LastModified property = (lastModified == null) ? null : new LastModified(lastModified);
setLastModified(property);
return property;
} | java |
public Categories addCategories(String... categories) {
Categories prop = new Categories(categories);
addProperty(prop);
return prop;
} | java |
public RefreshInterval setRefreshInterval(Duration refreshInterval) {
RefreshInterval property = (refreshInterval == null) ? null : new RefreshInterval(refreshInterval);
setRefreshInterval(property);
return property;
} | java |
public Source setSource(String url) {
Source property = (url == null) ? null : new Source(url);
setSource(property);
return property;
} | java |
@Override
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();
} | java |
public static VAlarm audio(Trigger trigger, Attachment sound) {
VAlarm alarm = new VAlarm(Action.audio(), trigger);
if (sound != null) {
alarm.addAttachment(sound);
}
return alarm;
} | java |
public static VAlarm display(Trigger trigger, String displayText) {
VAlarm alarm = new VAlarm(Action.display(), trigger);
alarm.setDescription(displayText);
return alarm;
} | java |
public DurationProperty setDuration(Duration duration) {
DurationProperty prop = (duration == null) ? null : new DurationProperty(duration);
setDuration(prop);
return prop;
} | java |
public Repeat setRepeat(Integer count) {
Repeat prop = (count == null) ? null : new Repeat(count);
setRepeat(prop);
return prop;
} | java |
public void setRepeat(int count, Duration pauseDuration) {
Repeat repeat = new Repeat(count);
DurationProperty duration = new DurationProperty(pauseDuration);
setRepeat(repeat);
setDuration(duration);
} | java |
public static Document createDocument() {
try {
DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
fact.setNamespaceAware(true);
DocumentBuilder db = fact.newDocumentBuilder();
return db.newDocument();
} catch (ParserConfigurationException e) {
//will probably never be thrown because... | java |
public static Document toDocument(String xml) throws SAXException {
try {
return toDocument(new StringReader(xml));
} catch (IOException e) {
//reading from string
throw new RuntimeException(e);
}
} | java |
public static Document toDocument(File file) throws SAXException, IOException {
InputStream in = new BufferedInputStream(new FileInputStream(file));
try {
return XmlUtils.toDocument(in);
} finally {
in.close();
}
} | java |
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;
} | java |
public static boolean hasQName(Node node, QName qname) {
return qname.getNamespaceURI().equals(node.getNamespaceURI()) && qname.getLocalPart().equals(node.getLocalName());
} | java |
public void close() throws IOException {
if (thread.isAlive()) {
thread.closed = true;
thread.interrupt();
}
if (stream != null) {
stream.close();
}
} | java |
public static DataUri parse(String uri) {
//Syntax: data:[<media type>][;charset=<character set>][;base64],<data>
String scheme = "data:";
if (uri.length() < scheme.length() || !uri.substring(0, scheme.length()).equalsIgnoreCase(scheme)) {
//not a data URI
throw Messages.INSTANCE.getIllegalArgumentExceptio... | java |
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;
} | java |
public List<ICalendar> readAll() throws IOException {
List<ICalendar> icals = new ArrayList<ICalendar>();
ICalendar ical;
while ((ical = readNext()) != null) {
icals.add(ical);
}
return icals;
} | java |
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;
} | java |
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);
} | java |
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);
} | java |
public V first(K key) {
key = sanitizeKey(key);
List<V> values = map.get(key);
/*
* The list can be null, but never empty. Empty lists are removed from
* the map.
*/
return (values == null) ? null : values.get(0);
} | java |
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;
} | java |
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;
} | java |
public List<V> replace(K key, V value) {
List<V> replaced = removeAll(key);
if (value != null) {
put(key, value);
}
return replaced;
} | java |
public List<V> replace(K key, Collection<? extends V> values) {
List<V> replaced = removeAll(key);
putAll(key, values);
return replaced;
} | java |
public void clear() {
//clear each collection to make previously returned lists empty
for (List<V> value : map.values()) {
value.clear();
}
map.clear();
} | java |
public List<V> values() {
List<V> list = new ArrayList<V>();
for (List<V> value : map.values()) {
list.addAll(value);
}
return Collections.unmodifiableList(list);
} | java |
public int size() {
int size = 0;
for (List<V> value : map.values()) {
size += value.size();
}
return size;
} | java |
public Integer getIndent() {
if (!"yes".equals(get(OutputKeys.INDENT))) {
return null;
}
String value = get(INDENT_AMT);
return (value == null) ? null : Integer.valueOf(value);
} | java |
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 positi... | java |
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();
... | java |
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>... | java |
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 ... | java |
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 clos... | java |
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 (dat... | java |
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 dtstartVal... | java |
public Classification setClassification(String classification) {
Classification prop = (classification == null) ? null : new Classification(classification);
setClassification(prop);
return prop;
} | java |
public Created setCreated(Date created) {
Created prop = (created == null) ? null : new Created(created);
setCreated(prop);
return prop;
} | java |
public DateStart setDateStart(Date dateStart, boolean hasTime) {
DateStart prop = (dateStart == null) ? null : new DateStart(dateStart, hasTime);
setDateStart(prop);
return prop;
} | java |
public LastModified setLastModified(Date lastModified) {
LastModified prop = (lastModified == null) ? null : new LastModified(lastModified);
setLastModified(prop);
return prop;
} | java |
public Organizer setOrganizer(String email) {
Organizer prop = (email == null) ? null : new Organizer(null, email);
setOrganizer(prop);
return prop;
} | java |
public Sequence setSequence(Integer sequence) {
Sequence prop = (sequence == null) ? null : new Sequence(sequence);
setSequence(prop);
return prop;
} | java |
public Url setUrl(String url) {
Url prop = (url == null) ? null : new Url(url);
setUrl(prop);
return prop;
} | java |
public RecurrenceRule setRecurrenceRule(Recurrence recur) {
RecurrenceRule prop = (recur == null) ? null : new RecurrenceRule(recur);
setRecurrenceRule(prop);
return prop;
} | java |
public Comment addComment(String comment) {
Comment prop = new Comment(comment);
addComment(prop);
return prop;
} | java |
public RelatedTo addRelatedTo(String uid) {
RelatedTo prop = new RelatedTo(uid);
addRelatedTo(prop);
return prop;
} | java |
public static void repeat(char c, int count, StringBuilder sb) {
for (int i = 0; i < count; i++) {
sb.append(c);
}
} | java |
public TimezoneUrl setTimezoneUrl(String url) {
TimezoneUrl prop = (url == null) ? null : new TimezoneUrl(url);
setTimezoneUrl(prop);
return prop;
} | java |
public void setDuration(Duration duration, Related related) {
this.date = null;
this.duration = duration;
setRelated(related);
} | java |
protected Collection<ICalVersion> getValueSupportedVersions() {
return (value == null) ? Collections.<ICalVersion> emptyList() : Arrays.asList(ICalVersion.values());
} | java |
public Location setLocation(String location) {
Location prop = (location == null) ? null : new Location(location);
setLocation(prop);
return prop;
} | java |
public Priority setPriority(Integer priority) {
Priority prop = (priority == null) ? null : new Priority(priority);
setPriority(prop);
return prop;
} | java |
public Resources addResources(String... resources) {
Resources prop = new Resources(resources);
addResources(prop);
return prop;
} | java |
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;
//find the next iCalendar object
JsonToken prev = pars... | java |
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(... | java |
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) {
war... | java |
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;
... | java |
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 fi... | java |
public String first(ICalDataType dataType) {
String dataTypeStr = toLocalName(dataType);
return first(dataTypeStr);
} | java |
public String first(String localName) {
for (Element child : children()) {
if (localName.equals(child.getLocalName()) && XCAL_NS.equals(child.getNamespaceURI())) {
return child.getTextContent();
}
}
return null;
} | java |
public List<String> all(ICalDataType dataType) {
String dataTypeStr = toLocalName(dataType);
return all(dataTypeStr);
} | java |
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 chil... | java |
public Element append(ICalDataType dataType, String value) {
String dataTypeStr = toLocalName(dataType);
return append(dataTypeStr, value);
} | java |
public Element append(String name, String value) {
Element child = document.createElementNS(XCAL_NS, name);
child.setTextContent(value);
element.appendChild(child);
return child;
} | java |
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;
} | java |
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... | java |
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;
} | java |
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.e... | java |
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;... | java |
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) {
generato... | java |
public void closeJsonStream() throws IOException {
if (generator == null) {
return;
}
while (!stack.isEmpty()) {
writeEndComponent();
}
if (wrapInArray) {
generator.writeEndArray();
}
if (closeGenerator) {
generator.close();
}
} | java |
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, mi... | java |
public void setParameters(ICalParameters parameters) {
if (parameters == null) {
throw new NullPointerException(Messages.INSTANCE.getExceptionMessage(16));
}
this.parameters = parameters;
} | java |
public List<String> getParameters(String name) {
return Collections.unmodifiableList(parameters.get(name));
} | java |
public void setParameter(String name, Collection<String> values) {
parameters.replace(name, values);
} | java |
public Completed setCompleted(Date completed) {
Completed prop = (completed == null) ? null : new Completed(completed);
setCompleted(prop);
return prop;
} | java |
public PercentComplete setPercentComplete(Integer percent) {
PercentComplete prop = (percent == null) ? null : new PercentComplete(percent);
setPercentComplete(prop);
return prop;
} | java |
public Attendee addAttendee(String email) {
Attendee prop = new Attendee(null, email, null);
addAttendee(prop);
return prop;
} | java |
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 += td... | java |
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);
} | java |
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];
} | java |
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];
} | java |
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 = (daysSinceEpo... | java |
@SuppressWarnings("unchecked")
public static <T> Predicate<T> and(Collection<Predicate<? super T>> components) {
return and(components.toArray(new Predicate[0]));
} | java |
public DateIterator getDateIterator(ICalDate startDate, TimeZone timezone) {
Recurrence recur = getValue();
return (recur == null) ? new Google2445Utils.EmptyDateIterator() : recur.getDateIterator(startDate, timezone);
} | java |
public boolean isSupported(ICalVersion version) {
for (ICalVersion supportedVersion : supportedVersions) {
if (supportedVersion == version) {
return true;
}
}
return false;
} | java |
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 Message... | java |
public TimezoneOffsetTo setTimezoneOffsetTo(UtcOffset offset) {
TimezoneOffsetTo prop = new TimezoneOffsetTo(offset);
setTimezoneOffsetTo(prop);
return prop;
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.