use of org.bedework.util.calendar.PropertyIndex.DataType in project bw-calendar-engine by Bedework.
the class IcalTranslator method xmlProperty.
private void xmlProperty(final XmlEmit xml, final Property val) throws CalFacadeException {
try {
QName tag = openTag(xml, val.getName());
ParameterList pl = val.getParameters();
if (pl.size() > 0) {
xml.openTag(XcalTags.parameters);
Iterator pli = pl.iterator();
while (pli.hasNext()) {
xmlParameter(xml, (Parameter) pli.next());
}
xml.closeTag(XcalTags.parameters);
}
PropertyInfoIndex pii = PropertyInfoIndex.fromName(val.getName());
QName ptype = XcalTags.textVal;
if (pii != null) {
DataType dtype = pii.getPtype();
if (dtype != null) {
ptype = dtype.getXcalType();
}
}
if (ptype == null) {
// Special processing I haven't done
warn("Unimplemented value type for " + val.getName());
ptype = XcalTags.textVal;
}
if (ptype.equals(XcalTags.recurVal)) {
// Emit individual parts of recur rule
xml.openTag(ptype);
Recur r;
if (val instanceof ExRule) {
r = ((ExRule) val).getRecur();
} else {
r = ((RRule) val).getRecur();
}
xml.property(XcalTags.freq, r.getFrequency());
xmlProp(xml, XcalTags.wkst, r.getWeekStartDay().name());
if (r.getUntil() != null) {
xmlProp(xml, XcalTags.until, r.getUntil().toString());
}
xmlProp(xml, XcalTags.count, String.valueOf(r.getCount()));
xmlProp(xml, XcalTags.interval, String.valueOf(r.getInterval()));
xmlProp(xml, XcalTags.bymonth, r.getMonthList());
xmlProp(xml, XcalTags.byweekno, r.getWeekNoList());
xmlProp(xml, XcalTags.byyearday, r.getYearDayList());
xmlProp(xml, XcalTags.bymonthday, r.getMonthDayList());
xmlProp(xml, XcalTags.byday, r.getDayList());
xmlProp(xml, XcalTags.byhour, r.getHourList());
xmlProp(xml, XcalTags.byminute, r.getMinuteList());
xmlProp(xml, XcalTags.bysecond, r.getSecondList());
xmlProp(xml, XcalTags.bysetpos, r.getSetPosList());
xml.closeTag(ptype);
} else {
xml.property(ptype, val.getValue());
}
xml.closeTag(tag);
} catch (CalFacadeException cfe) {
throw cfe;
} catch (Throwable t) {
throw new CalFacadeException(t);
}
}
use of org.bedework.util.calendar.PropertyIndex.DataType in project bw-calendar-engine by Bedework.
the class IcalTranslator method xmlParameter.
private void xmlParameter(final XmlEmit xml, final Parameter val) throws CalFacadeException {
try {
ParameterInfoIndex pii = ParameterInfoIndex.lookupPname(val.getName());
QName ptype = XcalTags.textVal;
if (pii != null) {
DataType dtype = pii.getPtype();
if (dtype != null) {
ptype = dtype.getXcalType();
}
}
if (ptype.equals(XcalTags.textVal)) {
QName tag = new QName(XcalTags.namespace, val.getName().toLowerCase());
xml.property(tag, val.getValue());
} else {
QName tag = openTag(xml, val.getName());
xml.property(ptype, val.getValue());
xml.closeTag(tag);
}
} catch (CalFacadeException cfe) {
throw cfe;
} catch (Throwable t) {
throw new CalFacadeException(t);
}
}
use of org.bedework.util.calendar.PropertyIndex.DataType in project bw-calendar-engine by Bedework.
the class JsonProperty method getType.
private static DataType getType(final Property prop) {
final PropertyInfoIndex pii = PropertyInfoIndex.fromName(prop.getName());
if (pii == null) {
return DataType.TEXT;
}
final DataType dtype = pii.getPtype();
if (dtype == null) {
return DataType.TEXT;
}
final String nm = prop.getName().toLowerCase();
if ((dtype != DataType.SPECIAL) && (!types.contains(nm))) {
return dtype;
}
if (prop instanceof DateProperty) {
// dtend, dtstart, due
final DateProperty dp = (DateProperty) prop;
if (Value.DATE.equals(dp.getParameter(Parameter.VALUE))) {
return DataType.DATE;
}
return DataType.DATE_TIME;
}
if (prop instanceof DateListProperty) {
// exdate, rdate
final DateListProperty dlp = (DateListProperty) prop;
if (Value.DATE.equals(dlp.getDates().getType())) {
return DataType.DATE;
}
return DataType.DATE_TIME;
}
if ("attach".equals(nm)) {
final Attach att = (Attach) prop;
if (att.getUri() != null) {
return DataType.URI;
}
return DataType.BINARY;
}
if ("trigger".equals(nm)) {
final Trigger tr = (Trigger) prop;
if (tr.getDuration() != null) {
return DataType.DURATION;
}
return DataType.DATE_TIME;
}
// in the absence of anything else callit text
return DataType.TEXT;
}
use of org.bedework.util.calendar.PropertyIndex.DataType in project bw-calendar-engine by Bedework.
the class JsonProperty method addFields.
public static void addFields(final JsonGenerator jgen, final Property prop) throws CalFacadeException {
try {
jgen.writeStartArray();
jgen.writeString(prop.getName().toLowerCase());
JsonParameters.addFields(jgen, prop);
final DataType type = getType(prop);
jgen.writeString(type.getJsonType());
outValue(jgen, prop, type);
jgen.writeEndArray();
} catch (final CalFacadeException cfe) {
throw cfe;
} catch (final Throwable t) {
throw new CalFacadeException(t);
}
}
Aggregations