gpt4 book ai didi

org.apache.chemistry.opencmis.commons.impl.XMLUtils类的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 07:34:40 25 4
gpt4 key购买 nike

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

XMLUtils介绍

暂无

代码示例

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-client-impl

/**
 * Reads a type definition from a XML stream.
 * 
 * The stream must be UTF-8 encoded.
 */
public static TypeDefinition readFromXML(InputStream stream) throws XMLStreamException {
  if (stream == null) {
    throw new IllegalArgumentException("Input stream must be set!");
  }
  XMLStreamReader parser = XMLUtils.createParser(stream);
  if (!XMLUtils.findNextStartElemenet(parser)) {
    return null;
  }
  TypeDefinition typeDef = XMLConverter.convertTypeDefinition(parser);
  parser.close();
  return typeDef;
}

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-server-bindings

protected void writeAclXML(Acl acl, CmisVersion cmisVersion, OutputStream out) throws XMLStreamException {
    XMLStreamWriter writer = XMLUtils.createWriter(out);
    XMLUtils.startXmlDocument(writer);
    XMLConverter.writeAcl(writer, cmisVersion, true, acl);
    XMLUtils.endXmlDocument(writer);
  }
}

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-client-bindings

/**
 * Parses a collection tag.
 */
private static AtomElement parseCollection(XMLStreamReader parser) throws XMLStreamException {
  QName name = parser.getName();
  Map<String, String> result = new HashMap<String, String>();
  result.put("href", parser.getAttributeValue(null, "href"));
  XMLUtils.next(parser);
  while (true) {
    int event = parser.getEventType();
    if (event == XMLStreamConstants.START_ELEMENT) {
      QName tagName = parser.getName();
      if (XMLConstants.NAMESPACE_RESTATOM.equals(tagName.getNamespaceURI())
          && TAG_COLLECTION_TYPE.equals(tagName.getLocalPart())) {
        result.put("collectionType", XMLUtils.readText(parser, XMLConstraints.MAX_STRING_LENGTH));
      } else {
        XMLUtils.skip(parser);
      }
    } else if (event == XMLStreamConstants.END_ELEMENT) {
      break;
    } else {
      if (!XMLUtils.next(parser)) {
        break;
      }
    }
  }
  XMLUtils.next(parser);
  return new AtomElement(name, result);
}

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-android-client

/**
 * Writes a Boolean tag.
 */
public static void write(XmlSerializer writer, String prefix, String namespace, String tag, Boolean value)
    throws IOException {
  assert writer != null;
  if (value == null) {
    return;
  }
  write(writer, prefix, namespace, tag, value ? "true" : "false");
}

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-client-bindings

QName childName = parser.getName();
XMLUtils.next(parser);
        result = new AtomElement(childName, parseFeed(parser));
      } else {
        XMLUtils.skip(parser);
      XMLUtils.skip(parser);
    if (!XMLUtils.next(parser)) {
      break;
XMLUtils.next(parser);

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-client-bindings

XMLStreamWriter writer = XMLUtils.createWriter(out);
XMLUtils.startXmlDocument(writer);
XMLUtils.write(writer, XMLConstants.PREFIX_ATOM, XMLConstants.NAMESPACE_ATOM, TAG_ATOM_ID,
    "urn:uuid:00000000-0000-0000-0000-00000000000");
XMLUtils.write(writer, XMLConstants.PREFIX_ATOM, XMLConstants.NAMESPACE_ATOM, TAG_ATOM_TITLE, getTitle());
XMLUtils.write(writer, XMLConstants.PREFIX_ATOM, XMLConstants.NAMESPACE_ATOM, TAG_ATOM_UPDATED,
    new GregorianCalendar(DateTimeHelper.GMT));
  writer.writeStartElement(XMLConstants.PREFIX_RESTATOM, TAG_CONTENT, XMLConstants.NAMESPACE_RESTATOM);
  XMLUtils.write(writer, XMLConstants.PREFIX_RESTATOM, XMLConstants.NAMESPACE_RESTATOM,
      TAG_CONTENT_MEDIATYPE, contentStream.getMimeType());
    XMLUtils.write(writer, XMLConstants.PREFIX_APACHE_CHEMISTY, XMLConstants.NAMESPACE_APACHE_CHEMISTRY,
        TAG_CONTENT_FILENAME, contentStream.getFileName());
XMLUtils.endXmlDocument(writer);

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-commons-impl

/**
 * Skips a tag or subtree.
 */
public static void skip(XMLStreamReader parser) throws XMLStreamException {
  assert parser != null;
  int level = 1;
  while (next(parser)) {
    int event = parser.getEventType();
    if (event == XMLStreamConstants.START_ELEMENT) {
      level++;
    } else if (event == XMLStreamConstants.END_ELEMENT) {
      level--;
      if (level == 0) {
        break;
      }
    }
  }
  next(parser);
}

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-client-bindings

XMLStreamReader parser = XMLUtils.createParser(stream);
    if (!XMLUtils.next(parser)) {
      break;

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-client-bindings

/**
 * Parses a link tag.
 */
private static AtomElement parseLink(XMLStreamReader parser) throws XMLStreamException {
  QName name = parser.getName();
  AtomLink result = new AtomLink();
  // save attributes
  for (int i = 0; i < parser.getAttributeCount(); i++) {
    if (LINK_REL.equals(parser.getAttributeLocalName(i))) {
      result.setRel(parser.getAttributeValue(i));
    } else if (LINK_HREF.equals(parser.getAttributeLocalName(i))) {
      result.setHref(parser.getAttributeValue(i));
    } else if (LINK_TYPE.equals(parser.getAttributeLocalName(i))) {
      result.setType(parser.getAttributeValue(i));
    }
  }
  // skip enclosed tags, if any
  XMLUtils.skip(parser);
  return new AtomElement(name, result);
}

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-commons-impl

protected String readText(final XMLStreamReader parser) throws XMLStreamException {
  assert parser != null;
  return XMLUtils.readText(parser, XMLConstraints.MAX_STRING_LENGTH);
}

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-server-bindings

/**
   * Returns the stack trace as DOM node.
   */
  public static Node getStacktraceAsNode(Throwable t) {
    try {
      String st = getStacktraceAsString(t);
      if (st != null) {
        Document doc = XMLUtils.newDomDocument();

        Element node = doc.createElementNS("http://chemistry.apache.org/opencmis/exception", "stacktrace");
        doc.appendChild(node);

        node.appendChild(doc.createTextNode(st));

        return node;
      }
    } catch (Exception e) {
      assert false;
    }

    return null;
  }
}

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-server-bindings

XMLStreamWriter writer = XMLUtils.createWriter(bufferStream);
  while (XMLUtils.next(parser)) {
    int event = parser.getEventType();
    if (event == XMLStreamConstants.START_ELEMENT) {
XMLUtils.next(parser);

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-server-bindings

/**
 * Starts the document and sets the namespaces.
 */
public void startDocument(OutputStream out, Map<String, String> namespaces) throws XMLStreamException {
  // create a writer
  writer = XMLUtils.createWriter(out);
  // start the document
  writer.writeStartDocument(IOUtils.UTF8, "1.0");
  setNamespaces(namespaces);
}

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-commons-impl

/**
 * Writes a Boolean tag.
 */
public static void write(XMLStreamWriter writer, String prefix, String namespace, String tag, Boolean value)
    throws XMLStreamException {
  assert writer != null;
  if (value == null) {
    return;
  }
  write(writer, prefix, namespace, tag, value ? "true" : "false");
}

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-commons-impl

public T walk(XMLStreamReader parser) throws XMLStreamException {
  assert parser != null;
  final T result = prepareTarget(parser, parser.getName());
  next(parser);
  // walk through all tags
  while (true) {
    int event = parser.getEventType();
    if (event == XMLStreamConstants.START_ELEMENT) {
      QName name = parser.getName();
      if (!read(parser, name, result)) {
        if (result instanceof ExtensionsData) {
          handleExtension(parser, (ExtensionsData) result);
        } else {
          skip(parser);
        }
      }
    } else if (event == XMLStreamConstants.END_ELEMENT) {
      break;
    } else {
      if (!next(parser)) {
        break;
      }
    }
  }
  next(parser);
  return result;
}

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-android-client

XmlSerializer writer = XMLUtils.createWriter(out);
XMLUtils.startXmlDocument(writer);
    XMLUtils.write(writer, XMLConstants.PREFIX_APACHE_CHEMISTY, XMLConstants.NAMESPACE_APACHE_CHEMISTRY,
        TAG_CONTENT_FILENAME, contentStream.getFileName());
XMLUtils.endXmlDocument(writer);

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-android-client

/**
 * Skips a tag or subtree.
 */
public static void skip(XmlPullParser parser) throws XmlPullParserException {
  assert parser != null;
  int level = 1;
  while (next(parser)) {
    int event = parser.getEventType();
    if (event == XmlPullParser.START_TAG) {
      level++;
    } else if (event == XmlPullParser.END_TAG) {
      level--;
      if (level == 0) {
        break;
      }
    }
  }
  next(parser);
}

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-android-client

XmlPullParser parser = XMLUtils.createParser(stream);
    if (!XMLUtils.next(parser)) {
      break;

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-client-bindings

/**
 * Parses a workspace element.
 */
private static AtomElement parseWorkspaceElement(XMLStreamReader parser) throws XMLStreamException {
  QName name = parser.getName();
  if (XMLConstants.NAMESPACE_RESTATOM.equals(name.getNamespaceURI())) {
    if (TAG_REPOSITORY_INFO.equals(name.getLocalPart())) {
      return new AtomElement(name, XMLConverter.convertRepositoryInfo(parser));
    } else if (TAG_URI_TEMPLATE.equals(name.getLocalPart())) {
      return parseTemplate(parser);
    }
  } else if (XMLConstants.NAMESPACE_ATOM.equals(name.getNamespaceURI())) {
    if (TAG_LINK.equals(name.getLocalPart())) {
      return parseLink(parser);
    }
  } else if (XMLConstants.NAMESPACE_APP.equals(name.getNamespaceURI())) {
    if (TAG_COLLECTION.equals(name.getLocalPart())) {
      return parseCollection(parser);
    }
  }
  // we don't know it - skip it
  XMLUtils.skip(parser);
  return null;
}

代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-android-client

protected String readText(final XmlPullParser parser) throws XmlPullParserException {
  return XMLUtils.readText(parser, XMLConstraints.MAX_STRING_LENGTH);
}

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