gpt4 book ai didi

org.bedework.util.xml.XmlUtil.getElementsArray()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-20 13:27:40 32 4
gpt4 key购买 nike

本文整理了Java中org.bedework.util.xml.XmlUtil.getElementsArray()方法的一些代码示例,展示了XmlUtil.getElementsArray()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlUtil.getElementsArray()方法的具体详情如下:
包路径:org.bedework.util.xml.XmlUtil
类名称:XmlUtil
方法名:getElementsArray

XmlUtil.getElementsArray介绍

暂无

代码示例

代码示例来源:origin: org.bedework/bw-util-xml

/**
 * @param nd
 * @return only child node
 * @throws SAXException  if not exactly one child elemnt
 */
public static Element getOnlyElement(final Node nd) throws SAXException {
 Element[] els = getElementsArray(nd);
 if (els.length != 1) {
  throw new SAXException("Expected exactly one child node for " +
              nd.getLocalName());
 }
 return els[0];
}

代码示例来源:origin: org.bedework/bw-util-dav

/**
 * @param nd
 * @return Element[]
 * @throws Throwable
 */
public static Element[] getChildrenArray(final Node nd) throws Throwable {
 try {
  return XmlUtil.getElementsArray(nd);
 } catch (Throwable t) {
  //if (debug) {
  //  getLogger().error(this, t);
  //}
  throw new Exception(t.getMessage());
 }
}

代码示例来源:origin: org.bedework/bw-util2-calendar

protected Element[] getChildrenArray(final Node nd) throws ParserException {
 try {
  return XmlUtil.getElementsArray(nd);
 } catch (Throwable t) {
  throw new ParserException(t.getMessage(), 0);
 }
}

代码示例来源:origin: org.bedework/bw-caldav-util

private void parseSupportedComponents(final Node nd,
                   final List<String> comps) throws Throwable {
 for (Element curnode: XmlUtil.getElementsArray(nd)) {
  if (!XmlUtil.nodeMatches(curnode, compTag)) {
   throw badComps();
  }
  comps.add(XmlUtil.getAttrVal(curnode, "name"));
 }
}

代码示例来源:origin: org.bedework/bw-caldav-util

private PropType parseProps(final Element nd) throws Throwable {
 PropType p = new PropType();
 for (Element curnode: XmlUtil.getElementsArray(nd)) {
  p.getQnames().add(XmlUtil.fromNode(curnode));
 }
 return p;
}

代码示例来源:origin: org.bedework/bw-caldav-util

private CalendarChangesType parseCalendarChange(final Element nd) throws Throwable {
 CalendarChangesType cc = new CalendarChangesType();
 for (Element curnode: XmlUtil.getElementsArray(nd)) {
  expect(curnode, AppleServerTags.recurrence);
  cc.getRecurrence().add(parseRecurrence(curnode));
 }
 return cc;
}

代码示例来源:origin: org.bedework/bw-caldav-util

private ChangesType parseChanges(final Element nd) throws Throwable {
 ChangesType c = new ChangesType();
 for (Element curnode: XmlUtil.getElementsArray(nd)) {
  expect(curnode, AppleServerTags.changedProperty);
  c.getChangedProperty().add(parseChangedProperty(curnode));
 }
 return c;
}

代码示例来源:origin: org.bedework/bw-caldav-util

ProcessorsType parseProcessors(final Element nd) throws Throwable {
 final ProcessorsType pt = new ProcessorsType();
 final Element[] els = XmlUtil.getElementsArray(nd);
 for (final Element curnode: els) {
  if (!XmlUtil.nodeMatches(curnode, BedeworkServerTags.processor)) {
   throw new WebdavBadRequest("Expected " + BedeworkServerTags.processor);
  }
  pt.getProcessor().add(parseProcessor(curnode));
 }
 return pt;
}

代码示例来源:origin: org.bedework/bw-caldav-util

/** Parse elements common to all
 *
 * @param note the notification
 * @param nd   the node
 * @throws WebdavException
 * @return number of elements parsed
 */
public int parseCommonElements(final NotificationType note,
                final Node nd) throws Throwable {
 final Element[] els = XmlUtil.getElementsArray(nd);
 if (els.length == 0) {
  return 0;
 }
 if (!XmlUtil.nodeMatches(els[0], BedeworkServerTags.processors)) {
  return 0;
 }
 note.setProcessors(parseProcessors(els[0]));
 return 1;
}

代码示例来源:origin: org.bedework/bw-util-config

/** XML root element must have type attribute
 *
 * @param rootEl - root of parsed document
 * @param cl class of object or null
 * @return parsed notification or null
 * @throws ConfigException on error
 */
public ConfigBase fromXml(final Element rootEl,
             final Class cl) throws ConfigException {
 try {
  final ConfigBase cb = (ConfigBase)getObject(rootEl, cl);
  if (cb == null) {
   // Can't do this
   return null;
  }
  for (final Element el: XmlUtil.getElementsArray(rootEl)) {
   populate(el, cb, null, null);
  }
  return cb;
 } catch (final ConfigException ce) {
  throw ce;
 } catch (final Throwable t) {
  throw new ConfigException(t);
 }
}

代码示例来源:origin: org.bedework/bw-access

private Privs parseGrantDeny(final Node nd) throws Throwable {
 boolean denial = false;
 if (XmlUtil.nodeMatches(nd, WebdavTags.deny)) {
  denial = true;
 } else if (!XmlUtil.nodeMatches(nd, WebdavTags.grant)) {
  return null;
 }
 Collection<Privilege> privs = new ArrayList<Privilege>();
 Element[] pchildren = XmlUtil.getElementsArray(nd);
 for (int pi = 0; pi < pchildren.length; pi++) {
  Element pnode = pchildren[pi];
  if (!XmlUtil.nodeMatches(pnode, WebdavTags.privilege)) {
   throw exc("Bad ACE - expect privilege");
  }
  privs.add(parsePrivilege(pnode, denial));
 }
 return new Privs(privs, denial);
}

代码示例来源:origin: org.bedework/bw-caldav-util

private CreatedType parseCreated(final Element nd) throws Throwable {
 CreatedType c = new CreatedType();
 Element[] els = XmlUtil.getElementsArray(nd);
 if (els.length < 1) {
  throw badNotification("No elements for create");
 }
 c.setHref(parseHref(els[0]));
 if (els.length > 1) {
  if (XmlUtil.nodeMatches(els[1], AppleServerTags.changedBy)) {
   c.setChangedBy(parseChangedBy(els[1]));
  }
 }
 return c;
}

代码示例来源:origin: org.bedework/bw-caldav-util

private RemoveType parseRemove(final Node nd) throws Throwable {
 RemoveType r = new RemoveType();
 Element[] els = XmlUtil.getElementsArray(nd);
 for (Element curnode: els) {
  if (XmlUtil.nodeMatches(curnode, hrefTag)) {
   if (r.getHref() != null) {
    throw badRemove();
   }
   r.setHref(XmlUtil.getElementContent(curnode));
   continue;
  }
  throw badRemove();
 }
 if (r.getHref() == null) {
  throw badRemove();
 }
 return r;
}

代码示例来源:origin: org.bedework/bw-caldav-util

private DeletedType parseDeleted(final Element nd) throws Throwable {
 DeletedType d = new DeletedType();
 Element[] els = XmlUtil.getElementsArray(nd);
 if (els.length < 1) {
  throw badNotification("No elements for delete");
 }
 int pos = 0;
 d.setHref(parseHref(els[pos]));
 pos++;
 if ((els.length > pos) &&
  XmlUtil.nodeMatches(els[pos], AppleServerTags.changedBy)) {
  d.setChangedBy(parseChangedBy(els[pos]));
  pos++;
 }
 expect(els[pos], AppleServerTags.deletedDetails);
 d.setDeletedDetails(parseDeletedDetails(els[pos]));
 return d;
}

代码示例来源:origin: org.bedework/bw-caldav-util

private ChangedParameterType parseChangedParameter(final Element nd) throws Throwable {
 ChangedParameterType cp = new ChangedParameterType();
 cp.setName(XmlUtil.getAttrVal(nd, "name"));
 Element[] els = XmlUtil.getElementsArray(nd);
 int pos = 0;
 if ((els.length > pos) &&
  XmlUtil.nodeMatches(els[pos], BedeworkServerTags.dataFrom)) {
  cp.setDataFrom(XmlUtil.getElementContent(els[pos]));
  pos++;
 }
 if ((els.length > pos) &&
  XmlUtil.nodeMatches(els[pos], BedeworkServerTags.dataTo)) {
  cp.setDataTo(XmlUtil.getElementContent(els[pos]));
  pos++;
 }
 if (els.length > pos) {
  throw badNotification(els[pos]);
 }
 return cp;
}

代码示例来源:origin: org.bedework/bw-caldav-util

private ChangedPropertyType parseChangedProperty(final Element nd) throws Throwable {
 ChangedPropertyType cp = new ChangedPropertyType();
 cp.setName(XmlUtil.getAttrVal(nd, "name"));
 Element[] els = XmlUtil.getElementsArray(nd);
 int pos = 0;
 while ((els.length > pos) &&
  XmlUtil.nodeMatches(els[pos], AppleServerTags.changedParameter)) {
  cp.getChangedParameter().add(parseChangedParameter(els[pos]));
  pos++;
 }
 if ((els.length > pos) &&
  XmlUtil.nodeMatches(els[pos], BedeworkServerTags.dataFrom)) {
  cp.setDataFrom(XmlUtil.getElementContent(els[pos]));
  pos++;
 }
 if ((els.length > pos) &&
  XmlUtil.nodeMatches(els[pos], BedeworkServerTags.dataTo)) {
  cp.setDataTo(XmlUtil.getElementContent(els[pos]));
  pos++;
 }
 if (els.length > pos) {
  throw badNotification(els[pos]);
 }
 return cp;
}

代码示例来源:origin: org.bedework/bw-caldav-util

ProcessorType parseProcessor(final Element nd) throws Throwable {
 final ProcessorType pt = new ProcessorType();
 final Element[] els = XmlUtil.getElementsArray(nd);
 final int len = els.length;
 int pos = 0;
 if ((len > pos) &&
     XmlUtil.nodeMatches(els[pos], BedeworkServerTags.type)) {
  pt.setType(XmlUtil.getElementContent(els[pos]));
  pos++;
 }
 if ((els.length > pos) &&
     XmlUtil.nodeMatches(els[pos], dtstampTag)) {
  pt.setDtstamp(XmlUtil.getElementContent(els[pos]));
  pos++;
 }
 if ((len > pos) &&
     XmlUtil.nodeMatches(els[pos], WebdavTags.status)) {
  pt.setStatus(XmlUtil.getElementContent(els[pos]));
  pos++;
 }
 return pt;
}

代码示例来源:origin: org.bedework/bw-caldav-util

private OrganizerType parseOrganizer(final Node nd) throws Throwable {
 OrganizerType o = new OrganizerType();
 Element[] els = XmlUtil.getElementsArray(nd);
 for (Element curnode: els) {
  if (XmlUtil.nodeMatches(curnode, hrefTag)) {
   if (o.getHref() != null) {
    throw badOrganizer();
   }
   o.setHref(XmlUtil.getElementContent(curnode));
   continue;
  }
  if (XmlUtil.nodeMatches(curnode, commonNameTag)) {
   if (o.getCommonName() != null) {
    throw badOrganizer();
   }
   o.setCommonName(XmlUtil.getElementContent(curnode));
   continue;
  }
  throw badOrganizer();
 }
 return o;
}

代码示例来源:origin: org.bedework/bw-caldav-util

private AccessType parseAccess(final Node nd) throws Throwable {
 AccessType a = new AccessType();
 Element[] els = XmlUtil.getElementsArray(nd);
 for (Element curnode: els) {
  if (XmlUtil.nodeMatches(curnode, readTag) ||
    XmlUtil.nodeMatches(curnode, readWriteTag)) {
   if ((a.getRead() != null) || (a.getReadWrite() != null)) {
    throw badAccess();
   }
   if (XmlUtil.nodeMatches(curnode, readTag)) {
    a.setRead(true);
   } else {
    a.setReadWrite(true);
   }
   continue;
  }
  throw badAccess();
 }
 if ((a.getRead() == null) && (a.getReadWrite() == null)) {
  throw badAccess();
 }
 return a;
}

代码示例来源:origin: org.bedework/bw-caldav-util

private ChangedByType parseChangedBy(final Element nd) throws Throwable {
 ChangedByType cb = new ChangedByType();
 Element[] els = XmlUtil.getElementsArray(nd);
 int pos;
 if (XmlUtil.nodeMatches(els[0], AppleServerTags.commonName)) {
  cb.setCommonName(XmlUtil.getElementContent(els[0]));
  pos = 1;
 } else {
  expect(els[0], AppleServerTags.firstName);
  cb.setFirstName(XmlUtil.getElementContent(els[0]));
  expect(els[1], AppleServerTags.lastName);
  cb.setLastName(XmlUtil.getElementContent(els[1]));
  pos = 2;
 }
 if (XmlUtil.nodeMatches(els[pos], AppleServerTags.dtstamp)) {
  cb.setDtstamp(XmlUtil.getElementContent(els[pos]));
  pos++;
 }
 cb.setHref(parseHref(els[pos]));
 return cb;
}

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com