gpt4 book ai didi

com.google.gdata.util.common.xml.XmlWriter.()方法的使用及代码示例

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

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

XmlWriter.<init>介绍

[英]Constructs an XmlWriter instance associated that will generate XML content to an underlying Writer.
[中]构造一个关联的XmlWriter实例,该实例将为底层编写器生成XML内容。

代码示例

代码示例来源:origin: com.google.gdata/gdata-java-client

public XmlWriter getRequestWriter() throws IOException {
 OutputStream requestStream = getRequestStream();
 Writer writer = new OutputStreamWriter(requestStream, "utf-8");
 return new XmlWriter(writer);
}

代码示例来源:origin: com.google.gdata/gdata-core-1.0

public XmlWriter getRequestWriter() throws IOException {
 OutputStream requestStream = getRequestStream();
 Writer writer = new OutputStreamWriter(requestStream, "utf-8");
 return new XmlWriter(writer);
}

代码示例来源:origin: com.mulesoft.google/google-api-gdata

public XmlWriter getRequestWriter() throws IOException {
 OutputStream requestStream = getRequestStream();
 Writer writer = new OutputStreamWriter(requestStream, "utf-8");
 return new XmlWriter(writer);
}

代码示例来源:origin: com.google.gdata/gdata-core-1.0

/**
 * If a derived class wishes to retrieve all unrecognized XML in a blob,
 * it calls this method. It must be called in the constructor, in
 * the parent element handler, or in {@link #processAttribute}.
 *
 * @param   xmlBlob
 *            Supplies the XML blob that stores the resulting XML.
 *
 * @param   mixedContent
 *            Specifies that the handler accepts mixed content XML.
 *
 * @param   fullTextIndex
 *            Flag indicating whether unrecognized XML should be processed
 *            for full-text indexing. If set, the resulting string ready for
 *            indexing is stored in {@link XmlBlob#fullText}.
 */
public void initializeXmlBlob(XmlBlob xmlBlob,
               boolean mixedContent,
               boolean fullTextIndex) throws IOException {
 assert okToInitializeXmlBlob;
 this.xmlBlob = xmlBlob;
 this.mixedContent = mixedContent;
 this.innerXmlStringWriter = new StringWriter();
 this.innerXml = new XmlWriter(innerXmlStringWriter);
 this.fullTextIndex = fullTextIndex;
 if (fullTextIndex) {
  this.fullTextIndexWriter = new StringWriter();
 }
}

代码示例来源:origin: com.mulesoft.google/google-api-gdata

/**
 * If a derived class wishes to retrieve all unrecognized XML in a blob,
 * it calls this method. It must be called in the constructor, in
 * the parent element handler, or in {@link #processAttribute}.
 *
 * @param   xmlBlob
 *            Supplies the XML blob that stores the resulting XML.
 *
 * @param   mixedContent
 *            Specifies that the handler accepts mixed content XML.
 *
 * @param   fullTextIndex
 *            Flag indicating whether unrecognized XML should be processed
 *            for full-text indexing. If set, the resulting string ready for
 *            indexing is stored in {@link XmlBlob#fullText}.
 */
public void initializeXmlBlob(XmlBlob xmlBlob,
               boolean mixedContent,
               boolean fullTextIndex) throws IOException {
 assert okToInitializeXmlBlob;
 this.xmlBlob = xmlBlob;
 this.mixedContent = mixedContent;
 this.innerXmlStringWriter = new StringWriter();
 this.innerXml = new XmlWriter(innerXmlStringWriter);
 this.fullTextIndex = fullTextIndex;
 if (fullTextIndex) {
  this.fullTextIndexWriter = new StringWriter();
 }
}

代码示例来源:origin: com.google.gdata/gdata-java-client

/**
 * If a derived class wishes to retrieve all unrecognized XML in a blob,
 * it calls this method. It must be called in the constructor, in
 * the parent element handler, or in {@link #processAttribute}.
 *
 * @param   xmlBlob
 *            Supplies the XML blob that stores the resulting XML.
 *
 * @param   mixedContent
 *            Specifies that the handler accepts mixed content XML.
 *
 * @param   fullTextIndex
 *            Flag indicating whether unrecognized XML should be processed
 *            for full-text indexing. If set, the resulting string ready for
 *            indexing is stored in {@link XmlBlob#fullText}.
 */
public void initializeXmlBlob(XmlBlob xmlBlob,
               boolean mixedContent,
               boolean fullTextIndex) throws IOException {
 assert okToInitializeXmlBlob;
 this.xmlBlob = xmlBlob;
 this.mixedContent = mixedContent;
 this.innerXmlStringWriter = new StringWriter();
 this.innerXml = new XmlWriter(innerXmlStringWriter);
 this.fullTextIndex = fullTextIndex;
 if (fullTextIndex) {
  this.fullTextIndexWriter = new StringWriter();
 }
}

代码示例来源:origin: com.mulesoft.google/google-api-gdata

/**
 * Returns an XmlWriter configured based upon request attributes.
 *
 * @param w The underlying writer to write to
 * @param outProps output properties
 * @param charset The writer's character encoding (determines which characters
 *     need to be escaped. Note that the writer must already be configured to
 *     use this character set. If the writer and the character set are out of
 *     sync, the generated XML may be overly escaped (not too bad) or
 *     malformed (pretty serious.)
 * @return An XmlWriter
 * @throws IOException If an error occurs creating the XmlWriter.
 */
protected XmlWriter getXmlWriter(Writer w, OutputProperties outProps, 
  String charset) throws IOException {
 EnumSet<WriterFlags> writerFlags = EnumSet.of(WriterFlags.WRITE_HEADER);
 if (usePrettyPrint(outProps)) {
  writerFlags.add(WriterFlags.PRETTY_PRINT);
 }
 return new XmlWriter(w, writerFlags, charset);
}

代码示例来源:origin: com.google.gdata/gdata-core-1.0

/**
 * Creates a new xml generator for generating xml output, using the
 * given namespace as the default namespace.
 */
public XmlGenerator(StreamProperties props, Writer w, Charset cs,
  boolean prettyPrint, XmlNamespace defaultNamespace) {
 EnumSet<WriterFlags> flags = EnumSet.of(WriterFlags.WRITE_HEADER);
 if (prettyPrint) {
  flags.add(WriterFlags.PRETTY_PRINT);
 }
 try {
  this.xw = new XmlWriter(w, flags, cs.name());
 } catch (IOException ioe) {
  throw new RuntimeException("Unable to create XML generator", ioe);
 }
 this.rootMetadata = props.getRootMetadata();
 this.defaultNamespace = defaultNamespace;
}

代码示例来源:origin: com.google.gdata/gdata-java-client

/**
 * Creates a new xml generator for generating xml output, using the
 * given namespace as the default namespace.
 */
public XmlGenerator(StreamProperties props, Writer w, Charset cs,
  boolean prettyPrint, XmlNamespace defaultNamespace) {
 EnumSet<WriterFlags> flags = EnumSet.of(WriterFlags.WRITE_HEADER);
 if (prettyPrint) {
  flags.add(WriterFlags.PRETTY_PRINT);
 }
 try {
  this.xw = new XmlWriter(w, flags, cs.name());
 } catch (IOException ioe) {
  throw new RuntimeException("Unable to create XML generator", ioe);
 }
 this.rootMetadata = props.getRootMetadata();
 this.defaultNamespace = defaultNamespace;
}

代码示例来源:origin: com.mulesoft.google/google-api-gdata

/**
 * Creates a new xml generator for generating xml output, using the
 * given namespace as the default namespace.
 */
public XmlGenerator(StreamProperties props, Writer w, Charset cs,
  boolean prettyPrint, XmlNamespace defaultNamespace) {
 EnumSet<WriterFlags> flags = EnumSet.of(WriterFlags.WRITE_HEADER);
 if (prettyPrint) {
  flags.add(WriterFlags.PRETTY_PRINT);
 }
 try {
  this.xw = new XmlWriter(w, flags, cs.name());
 } catch (IOException ioe) {
  throw new RuntimeException("Unable to create XML generator", ioe);
 }
 this.rootMetadata = props.getRootMetadata();
 this.defaultNamespace = defaultNamespace;
}

代码示例来源:origin: com.google.gdata/gdata-core-1.0

/**
 * Returns an XmlWriter configured based upon request attributes.
 *
 * @param w The underlying writer to write to
 * @param outProps output properties
 * @param charset The writer's character encoding (determines which characters
 *     need to be escaped. Note that the writer must already be configured to
 *     use this character set. If the writer and the character set are out of
 *     sync, the generated XML may be overly escaped (not too bad) or
 *     malformed (pretty serious.)
 * @return An XmlWriter
 * @throws IOException If an error occurs creating the XmlWriter.
 */
protected XmlWriter getXmlWriter(Writer w, OutputProperties outProps, 
  String charset) throws IOException {
 EnumSet<WriterFlags> writerFlags = EnumSet.of(WriterFlags.WRITE_HEADER);
 if (usePrettyPrint(outProps)) {
  writerFlags.add(WriterFlags.PRETTY_PRINT);
 }
 return new XmlWriter(w, writerFlags, charset);
}

代码示例来源:origin: com.google.gdata/gdata-java-client

/**
 * Returns an XmlWriter configured based upon request attributes.
 *
 * @param w The underlying writer to write to
 * @param outProps output properties
 * @param charset The writer's character encoding (determines which characters
 *     need to be escaped. Note that the writer must already be configured to
 *     use this character set. If the writer and the character set are out of
 *     sync, the generated XML may be overly escaped (not too bad) or
 *     malformed (pretty serious.)
 * @return An XmlWriter
 * @throws IOException If an error occurs creating the XmlWriter.
 */
protected XmlWriter getXmlWriter(Writer w, OutputProperties outProps, 
  String charset) throws IOException {
 EnumSet<WriterFlags> writerFlags = EnumSet.of(WriterFlags.WRITE_HEADER);
 if (usePrettyPrint(outProps)) {
  writerFlags.add(WriterFlags.PRETTY_PRINT);
 }
 return new XmlWriter(w, writerFlags, charset);
}

代码示例来源:origin: com.google.gdata/gdata-java-client

/**
 * @return a plain-text representation of this text construct,
 * or {@code null} in case of error
 */
@Override
public String getPlainText() {
 try {
  StringWriter sw = new StringWriter();
  XmlWriter xw = new XmlWriter(sw);
  xw.innerXml(xhtml.getBlob());
  return HtmlToText.htmlToPlainText(sw.toString());
 } catch (IOException e) {
  // IOException isn't very meaningful to callers, so it's better to
  // return null in this case.
  return null;
 }
}

代码示例来源:origin: com.google.gdata/gdata-core-1.0

/**
 * @return a plain-text representation of this text construct,
 *         or {@code null} if there is no text content available.
 */
@Override
public String getPlainText() {
 if (xhtml == null) {
  return null;
 }
 try {
  StringWriter sw = new StringWriter();
  XmlWriter xw = new XmlWriter(sw);
  xw.innerXml(xhtml.getBlob());
  return HtmlToText.htmlToPlainText(sw.toString());
 } catch (IOException e) {
  // IOException isn't very meaningful to callers, so it's better to
  // return null in this case.
  return null;
 }
}

代码示例来源:origin: com.mulesoft.google/google-api-gdata

/**
 * @return a plain-text representation of this text construct,
 *         or {@code null} if there is no text content available.
 */
@Override
public String getPlainText() {
 if (xhtml == null) {
  return null;
 }
 try {
  StringWriter sw = new StringWriter();
  XmlWriter xw = new XmlWriter(sw);
  xw.innerXml(xhtml.getBlob());
  return HtmlToText.htmlToPlainText(sw.toString());
 } catch (IOException e) {
  // IOException isn't very meaningful to callers, so it's better to
  // return null in this case.
  return null;
 }
}

代码示例来源:origin: wso2-attic/esb-connectors

/**
 * Generates a SOAP envelope based on XML Serialization provided by GData(BaseEntry) API generate method.
 * 
 * @param baseEntry the object to be serialized.
 * @param contactsService Contacts Service object.
 * @return A SOAP Envelope containing the XML generated from the object.
 * @throws IOException On failure to initialize XML Writer.
 * @throws XMLStreamException On failure to convert XML String to OM Element.
 */
protected final SOAPEnvelope getGDataSOAPEnvelope(final BaseEntry< ? > baseEntry,
    final ContactsService contactsService) throws IOException, XMLStreamException {

  Writer stringWriter = new StringWriter();
  XmlWriter xmlWriter = new XmlWriter(stringWriter);
  
  baseEntry.generate(xmlWriter, contactsService.getExtensionProfile());
  
  return TransportUtils.createSOAPEnvelope(AXIOMUtil.stringToOM(stringWriter.toString()));
}

代码示例来源:origin: wso2-attic/esb-connectors

/**
 * Generates a SOAP envelope based on XML Serialization provided by GData(BaseFeed) API generate method.
 * 
 * @param baseFeed The object to be serialized.
 * @param contactsService Contact Service object.
 * @return a SOAP envelope containing the serialized XML.
 * @throws IOException Thrown on failure to initialize the XML writer.
 * @throws XMLStreamException On failure to convert the XML String to OMElement.
 */
public final SOAPEnvelope getGDataSOAPEnvelope(final BaseFeed< ? , ? > baseFeed,
    final ContactsService contactsService) throws IOException, XMLStreamException {

  Writer stringWriter = new StringWriter();
  XmlWriter xmlWriter = new XmlWriter(stringWriter);
  
  baseFeed.generate(xmlWriter, contactsService.getExtensionProfile());
  
  return TransportUtils.createSOAPEnvelope(AXIOMUtil.stringToOM(stringWriter.toString()));
}

代码示例来源:origin: com.google.gdata/gdata-java-client

/**
 * Reverses {@link #generateCumulativeXmlBlob(ExtensionProfile)}. This
 * operation overwrites the current contents of this extension point.
 */
public void parseCumulativeXmlBlob(XmlBlob blob,
  ExtensionProfile extProfile, 
  Class<? extends ExtensionPoint> extendedClass)
  throws IOException, ParseException {
 this.xmlBlob = new XmlBlob();
 nonRepeatingExtensionMap.clear();
 repeatingExtensionMap.clear();
 // Prepare a fake XML document from the blob.
 StringWriter sw = new StringWriter();
 XmlWriter w = new XmlWriter(sw);
 XmlBlob.startElement(w, null, "CUMULATIVE_BLOB", blob, null, null);
 XmlBlob.endElement(w, null, "CUMULATIVE_BLOB", blob);
 // Now parse it.
 StringReader sr = new StringReader(sw.toString());
 XmlParser parser = new XmlParser();
 parser.parse(sr, new CumulativeBlobHandler(extProfile, extendedClass), "",
   "CUMULATIVE_BLOB");
}

代码示例来源:origin: com.google.gdata/gdata-core-1.0

/**
 * Reverses {@link #generateCumulativeXmlBlob(ExtensionProfile)}. This
 * operation overwrites the current contents of this extension point.
 */
public void parseCumulativeXmlBlob(XmlBlob blob,
  ExtensionProfile extProfile, 
  Class<? extends ExtensionPoint> extendedClass)
  throws IOException, ParseException {
 this.xmlBlob = new XmlBlob();
 nonRepeatingExtensionMap.clear();
 repeatingExtensionMap.clear();
 // Prepare a fake XML document from the blob.
 StringWriter sw = new StringWriter();
 XmlWriter w = new XmlWriter(sw);
 XmlBlob.startElement(w, null, "CUMULATIVE_BLOB", blob, null, null);
 XmlBlob.endElement(w, null, "CUMULATIVE_BLOB", blob);
 // Now parse it.
 StringReader sr = new StringReader(sw.toString());
 XmlParser parser = new XmlParser();
 parser.parse(sr, new CumulativeBlobHandler(extProfile, extendedClass), "",
   "CUMULATIVE_BLOB");
}

代码示例来源:origin: com.mulesoft.google/google-api-gdata

/**
 * Reverses {@link #generateCumulativeXmlBlob(ExtensionProfile)}. This
 * operation overwrites the current contents of this extension point.
 */
public void parseCumulativeXmlBlob(XmlBlob blob,
  ExtensionProfile extProfile, 
  Class<? extends ExtensionPoint> extendedClass)
  throws IOException, ParseException {
 this.xmlBlob = new XmlBlob();
 nonRepeatingExtensionMap.clear();
 repeatingExtensionMap.clear();
 // Prepare a fake XML document from the blob.
 StringWriter sw = new StringWriter();
 XmlWriter w = new XmlWriter(sw);
 XmlBlob.startElement(w, null, "CUMULATIVE_BLOB", blob, null, null);
 XmlBlob.endElement(w, null, "CUMULATIVE_BLOB", blob);
 // Now parse it.
 StringReader sr = new StringReader(sw.toString());
 XmlParser parser = new XmlParser();
 parser.parse(sr, new CumulativeBlobHandler(extProfile, extendedClass), "",
   "CUMULATIVE_BLOB");
}

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