gpt4 book ai didi

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

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

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

XmlUtil.nodeMatches介绍

[英]See if node matches tag
[中]查看节点是否与标记匹配

代码示例

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

/**
 * @param el
 * @param tag
 * @throws Throwable
 */
public static void expect(final Element el,
             final QName tag) throws Throwable {
 if (!XmlUtil.nodeMatches(el, tag)) {
  throw new Exception("Expected " + tag);
 }
}

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

private void expect(final Element nd,
          final QName expected) throws Throwable {
 if (!XmlUtil.nodeMatches(nd, expected)) {
  throw badNotification(nd, expected);
 }
}

代码示例来源: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 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

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-util2-calendar

private void processComponent(final Element el,
               final BuildState bs) throws ParserException {
 try {
  bs.getContentHandler().startComponent(el.getLocalName().toUpperCase());
  for (Element e: XmlUtil.getElements(el)) {
   if (XmlUtil.nodeMatches(e, XcalTags.properties)) {
    processProperties(e, bs);
   } else if (XmlUtil.nodeMatches(e, XcalTags.components)) {
    for (Element ce: XmlUtil.getElements(e)) {
     processComponent(ce, bs);
    }
   } else {
    throw new ParserException("Unexpected element: found " + e, 0);
   }
  }
  bs.getContentHandler().endComponent(el.getLocalName().toUpperCase());
 } catch (SAXException e) {
  throw new ParserException(e.getMessage(), 0, e);
 }
}

代码示例来源: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

/** 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-util2-calendar

private void process(final Document doc,
           final BuildState bs) throws ParserException {
 // start = element icalendar { vcalendar+ }
 Element root = doc.getDocumentElement();
 if (!XmlUtil.nodeMatches(root, XcalTags.icalendar)) {
  // error
  throw new ParserException("Expected " + XcalTags.icalendar +
               " found " + root, 0);
 }
 for (Element el: getChildren(root)) {
  // Expect vcalendar
  if (!XmlUtil.nodeMatches(el, XcalTags.vcalendar)) {
   // error
   throw new ParserException("Expected " + XcalTags.vcalendar +
                " found " + el, 0);
  }
  bs.setCalendar(null);
  processVcalendar(el, bs);
  if (bs.getCalendar() != null) {
   bs.getCalendars().add(bs.getCalendar());
  }
 }
}

代码示例来源: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 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

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-util2-calendar

private void processProperty(final Element el,
               final BuildState bs) throws ParserException {
 try {
  bs.getContentHandler().startProperty(el.getLocalName());
  for (Element e: XmlUtil.getElements(el)) {
   if (XmlUtil.nodeMatches(e, XcalTags.parameters)) {
    for (Element par: XmlUtil.getElements(e)) {
     bs.getContentHandler().parameter(par.getLocalName(),
                XmlUtil.getElementContent(par));
    }
   }
   if (!processValue(e, bs)) {
    throw new ParserException("Bad property " + el, 0);
   }
  }
  bs.getContentHandler().endProperty(el.getLocalName());
 } catch (SAXException e) {
  throw new ParserException(e.getMessage(), 0, e);
 } catch (URISyntaxException e) {
  throw new ParserException(e.getMessage(), 0, e);
 }
}

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

private Privilege parsePrivilege(final Node nd,
                 final boolean denial) throws Throwable {
 Element el = XmlUtil.getOnlyElement(nd);
 int priv;
 findPriv: {
  // ENUM
  for (priv = 0; priv < privTags.length; priv++) {
   if (XmlUtil.nodeMatches(el, privTags[priv])) {
    break findPriv;
   }
  }
  throw exc("Bad privilege");
 }
 if (debug()) {
  debug("Add priv " + priv + " denied=" + denial);
 }
 return Privileges.makePriv(priv, denial);
}

代码示例来源: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 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 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;
}

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

/**
 * @param nd MUST be the cancelled xml element
 * @return populated SuggestNotificationType object
 * @throws WebdavException
 */
public EventregCancelledNotificationType parseEventCancelled(final Node nd) throws WebdavException {
 try {
  if (!XmlUtil.nodeMatches(nd, cancelledTag)) {
   throw new WebdavBadRequest("Expected " + cancelledTag);
  }
  final EventregCancelledNotificationType note = new EventregCancelledNotificationType();
  final Element[] els = XmlUtil.getElementsArray(nd);
  for (final Element curnode: els) {
   if (eventregBaseNode(note, curnode)) {
    continue;
   }
   throw new WebdavBadRequest("Unexpected element " + curnode);
  }
  return note;
 } catch (final SAXException e) {
  throw parseException(e);
 } catch (final WebdavException wde) {
  throw wde;
 } catch (final Throwable t) {
  throw new WebdavException(t);
 }
}

代码示例来源: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;
}

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