• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java XMLWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.codehaus.plexus.util.xml.XMLWriter的典型用法代码示例。如果您正苦于以下问题:Java XMLWriter类的具体用法?Java XMLWriter怎么用?Java XMLWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



XMLWriter类属于org.codehaus.plexus.util.xml包,在下文中一共展示了XMLWriter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: writeEffectivePom

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
/**
 * org.apache.maven.plugins.help.EffectivePomMojo#writeEffectivePom
 */
private static void writeEffectivePom(MavenProject project, XMLWriter writer)
  throws MojoExecutionException {
  Model pom = project.getModel();
  cleanModel(pom);

  String effectivePom;

  StringWriter sWriter = new StringWriter();
  MavenXpp3Writer pomWriter = new MavenXpp3Writer();
  try {
    pomWriter.write(sWriter, pom);
  }
  catch (IOException e) {
    throw new MojoExecutionException("Cannot serialize POM to XML.", e);
  }

  effectivePom = addMavenNamespace(sWriter.toString(), true);

  writeComment(writer, "Effective POM for project \'" + project.getId() + "\'");

  writer.writeMarkup(effectivePom);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:MavenEffectivePomDumper.java


示例2: writeJobConfiguration

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
public static void writeJobConfiguration(XMLWriter writer, Schedule schedule, Configuration conf) {

    property(writer, WORKFLOW_NOMINAL_TIME, "${" + COORD_NOMINAL_TIME + "}");

    // Write the Hive metastore URI, if available. It may be null
    // in local or testing environments.
    if (conf.get(HIVE_METASTORE_URIS) != null) {
      property(writer, HIVE_METASTORE_URIS, conf.get(HIVE_METASTORE_URIS));
    }

    // Include the dataset inputs to make them visible to the workflow.
    for (String name: schedule.getViewTemplates().keySet()) {

      property(writer, "wf_" + toIdentifier(name), "${coord_" + toIdentifier(name) + "}");
    }
  }
 
开发者ID:rbrush,项目名称:kite-apps,代码行数:17,代码来源:OozieScheduling.java


示例3: patchGwtModule

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
/**
 * Patches the IDE GWT module by replacing inheritance of Full.gwt.xml by
 * Full-with-excludes.gwt.xml.
 */
private void patchGwtModule() throws XmlPullParserException, IOException {
  String gwtModuleFileRelPath = getGwtModule().replace('.', '/') + ".gwt.xml";
  Path gwtModuleFilePath = Paths.get(outputDirectory.getPath(), gwtModuleFileRelPath);

  Xpp3Dom module = Xpp3DomBuilder.build(Files.newInputStream(gwtModuleFilePath), UTF_8.name());

  for (int i = module.getChildCount() - 1; i >= 0; i--) {
    Xpp3Dom child = module.getChild(i);

    if ("inherits".equals(child.getName())) {
      String moduleName = child.getAttribute("name");

      if (moduleName.equals(fullIdeGwtModule)) {
        child.setAttribute("name", fullIdeGwtModule + FULL_IDE_GWT_MODULE_SUFFIX);
        break;
      }
    }
  }

  try (Writer writer = new StringWriter()) {
    XMLWriter xmlWriter = new PrettyPrintXMLWriter(writer);
    Xpp3DomWriter.write(xmlWriter, module);
    Files.write(gwtModuleFilePath, writer.toString().getBytes());
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:ProcessExcludesMojo.java


示例4: writeEffectivePom

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
/**
 * method from org.apache.maven.plugins.help.EffectivePomMojo Method for writing the effective pom
 * informations of the current build.
 *
 * @param project the project of the current build, not null.
 * @param writer the XML writer , not null, not null.
 * @throws MojoExecutionException if any
 */
private static void writeEffectivePom(MavenProject project, XMLWriter writer)
    throws MojoExecutionException {
  Model pom = project.getModel();
  cleanModel(pom);

  String effectivePom;

  StringWriter sWriter = new StringWriter();
  MavenXpp3Writer pomWriter = new MavenXpp3Writer();
  try {
    pomWriter.write(sWriter, pom);
  } catch (IOException e) {
    throw new MojoExecutionException("Cannot serialize POM to XML.", e);
  }

  effectivePom = addMavenNamespace(sWriter.toString(), true);

  writeComment(writer, "Effective POM for project \'" + project.getId() + "\'");

  writer.writeMarkup(effectivePom);
}
 
开发者ID:eclipse,项目名称:che,代码行数:30,代码来源:EffectivePomWriter.java


示例5: writeHeader

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
/**
 * method from org.apache.maven.plugins.help.AbstractEffectiveMojo Write comments in the Effective
 * POM/settings header.
 *
 * @param writer not null
 */
protected static void writeHeader(XMLWriter writer) {
  XmlWriterUtil.writeCommentLineBreak(writer);
  XmlWriterUtil.writeComment(writer, "    ");
  // Use ISO8601-format for date and time
  DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
  XmlWriterUtil.writeComment(
      writer,
      "Generated by Maven Help Plugin on "
          + dateFormat.format(new Date(System.currentTimeMillis())));
  XmlWriterUtil.writeComment(writer, "See: http://maven.apache.org/plugins/maven-help-plugin/");
  XmlWriterUtil.writeComment(writer, "    ");
  XmlWriterUtil.writeCommentLineBreak(writer);

  XmlWriterUtil.writeLineBreak(writer);
}
 
开发者ID:eclipse,项目名称:che,代码行数:22,代码来源:EffectivePomWriter.java


示例6: write

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
private void write(PlexusConfiguration c, XMLWriter w, int depth) throws IOException {
  int count = c.getChildCount();

  if (count == 0) {
    writeTag(c, w, depth);
  } else {
    w.startElement(c.getName());
    writeAttributes(c, w);

    for (int i = 0; i < count; i++) {
      PlexusConfiguration child = c.getChild(i);

      write(child, w, depth + 1);
    }

    w.endElement();
  }
}
 
开发者ID:orctom,项目名称:was-maven-plugin,代码行数:19,代码来源:AntXmlPlexusConfigurationWriter.java


示例7: writeDescriptor

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
public void writeDescriptor(OutputStream outputStream, PluginDescriptor pluginDescriptor) throws IOException {
  OutputStreamWriter writer = new OutputStreamWriter(outputStream, encoding);

  XMLWriter w = new PrettyPrintXMLWriter(writer, encoding, null);

  w.writeMarkup("\n<!-- Generated by takari-plugin-tools -->\n\n");
  w.startElement("plugin");
  element(w, "name", pluginDescriptor.getName());
  element(w, "description", pluginDescriptor.getDescription());
  element(w, "groupId", pluginDescriptor.getGroupId());
  element(w, "artifactId", pluginDescriptor.getArtifactId());
  element(w, "version", pluginDescriptor.getVersion());
  element(w, "goalPrefix", pluginDescriptor.getGoalPrefix());
  element(w, "isolatedRealm", String.valueOf(pluginDescriptor.isIsolatedRealm()));
  element(w, "inheritedByDefault", String.valueOf(pluginDescriptor.isInheritedByDefault()));
  writeMojos(w, pluginDescriptor);
  writeDependencies(w, pluginDescriptor);
  w.endElement();

  writer.flush();
}
 
开发者ID:takari,项目名称:takari-lifecycle,代码行数:22,代码来源:PluginDescriptorWriter.java


示例8: writeHeader

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
/**
 * Copy/pasted from org.apache.maven.plugins.help.AbstractEffectiveMojo#writeHeader
 */
protected static void writeHeader(XMLWriter writer) {
  XmlWriterUtil.writeCommentLineBreak(writer);
  XmlWriterUtil.writeComment(writer, " ");
  // Use ISO8601-format for date and time
  DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss");
  XmlWriterUtil.writeComment(writer, "Generated on " + dateFormat.format(new Date(System.currentTimeMillis())));
  XmlWriterUtil.writeComment(writer, " ");
  XmlWriterUtil.writeCommentLineBreak(writer);

  XmlWriterUtil.writeLineBreak(writer);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:MavenEffectivePomDumper.java


示例9: writeComment

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
/**
 * Copy/pasted from org.apache.maven.plugins.help.AbstractEffectiveMojo
 */
protected static void writeComment(XMLWriter writer, String comment) {
  XmlWriterUtil.writeCommentLineBreak(writer);
  XmlWriterUtil.writeComment(writer, " ");
  XmlWriterUtil.writeComment(writer, comment);
  XmlWriterUtil.writeComment(writer, " ");
  XmlWriterUtil.writeCommentLineBreak(writer);

  XmlWriterUtil.writeLineBreak(writer);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:MavenEffectivePomDumper.java


示例10: writeOozieActionBlock

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
@Override
public void writeOozieActionBlock(XMLWriter writer, Schedule schedule) {

  writer.startElement("spark");
  writer.addAttribute("xmlns", "uri:oozie:spark-action:0.1");
  element(writer, "job-tracker", "${jobTracker}");
  element(writer, "name-node", "${nameNode}");

  // TODO: the job-xml should probably be job-specific configuration.
  // element(writer, "job-xml", "${appConfigPath}");

  // Make the nominal time visible to the workflow action.
  writer.startElement("configuration");

  // Use the spark and hive sharelibs since many actions use both.
  property(writer, "oozie.action.sharelib.for.spark", "spark,hive2");
  property(writer, "kiteAppRoot", "${kiteAppRoot}");

  OozieScheduling.writeJobConfiguration(writer, schedule, context.getHadoopConf());

  writer.endElement(); // configuration

  element(writer, "master", "yarn-cluster");
  element(writer, "name", schedule.getName());
  element(writer, "class", SparkScheduledJobMain.class.getCanonicalName());

  JobConf jobConf = new JobConf();
  jobConf.setJarByClass(schedule.getJobClass());
  String containingJar = jobConf.getJar();

  String jarName = containingJar != null ?
      "${kiteAppRoot}/lib/" + new File(containingJar).getName() :
      "";

  element(writer, "jar",  jarName);
  element(writer, "spark-opts", getSparkConfString(schedule));
  element(writer, "arg", schedule.getName());

  writer.endElement(); // spark
}
 
开发者ID:rbrush,项目名称:kite-apps,代码行数:41,代码来源:SparkJobManager.java


示例11: element

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
public static void element(XMLWriter writer, String name, String attributeName,
                            String attributeValue) {

  writer.startElement(name);
  writer.addAttribute(attributeName, attributeValue);
  writer.endElement();
}
 
开发者ID:rbrush,项目名称:kite-apps,代码行数:8,代码来源:OozieScheduling.java


示例12: property

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
/**
 * Writes a Hadoop-style configuration property.
 */
public static void property(XMLWriter writer, String name, String value) {
  writer.startElement("property");

  element(writer, "name", name);
  element(writer, "value", value);

  writer.endElement();
}
 
开发者ID:rbrush,项目名称:kite-apps,代码行数:12,代码来源:OozieScheduling.java


示例13: createFullIdeModuleWithExcludes

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
/** Creates copy of the Full.gwt.xml with removed '<inherits>' for the excluded GWT modules. */
private void createFullIdeModuleWithExcludes(Set<String> modulesToExclude)
    throws XmlPullParserException, IOException {
  String fullIdeGwtModulePath = fullIdeGwtModule.replace('.', '/') + ".gwt.xml";
  String fullIdeGwtModuleContent =
      getFileContent(new ZipFile(fullIdeArtifact.getFile()), fullIdeGwtModulePath);

  InputStream in = new ByteArrayInputStream(fullIdeGwtModuleContent.getBytes(UTF_8.name()));
  Xpp3Dom module = Xpp3DomBuilder.build(in, UTF_8.name());

  for (int i = module.getChildCount() - 1; i >= 0; i--) {
    Xpp3Dom child = module.getChild(i);

    if ("inherits".equals(child.getName())) {
      String moduleName = child.getAttribute("name");

      if (modulesToExclude.contains(moduleName)) {
        module.removeChild(i);
      }
    }
  }

  String moduleRelPath =
      fullIdeGwtModulePath.replace(".gwt.xml", FULL_IDE_GWT_MODULE_SUFFIX + ".gwt.xml");

  Path modulePath = Paths.get(outputDirectory.getPath(), moduleRelPath);

  try (Writer writer = new StringWriter()) {
    XMLWriter xmlWriter = new PrettyPrintXMLWriter(writer);
    Xpp3DomWriter.write(xmlWriter, module);
    Files.write(modulePath, writer.toString().getBytes());
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:34,代码来源:ProcessExcludesMojo.java


示例14: writeComment

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
/**
 * method from org.apache.maven.plugins.help.AbstractEffectiveMojo Write comments in a normalize
 * way.
 *
 * @param writer not null
 * @param comment not null
 */
protected static void writeComment(XMLWriter writer, String comment) {
  XmlWriterUtil.writeCommentLineBreak(writer);
  XmlWriterUtil.writeComment(writer, " ");
  XmlWriterUtil.writeComment(writer, comment);
  XmlWriterUtil.writeComment(writer, " ");
  XmlWriterUtil.writeCommentLineBreak(writer);

  XmlWriterUtil.writeLineBreak(writer);
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:EffectivePomWriter.java


示例15: writeTag

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
private void writeTag(PlexusConfiguration c, XMLWriter w, int depth) throws IOException {
  w.startElement(c.getName());

  writeAttributes(c, w);

  String value = c.getValue(null);
  if (value != null) {
    w.writeText(value);
  }

  w.endElement();
}
 
开发者ID:orctom,项目名称:was-maven-plugin,代码行数:13,代码来源:AntXmlPlexusConfigurationWriter.java


示例16: writeAttributes

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
private void writeAttributes(PlexusConfiguration c, XMLWriter w) throws IOException {
  String[] names = c.getAttributeNames();

  for (int i = 0; i < names.length; i++) {
    w.addAttribute(names[i], c.getAttribute(names[i], null));
  }
}
 
开发者ID:orctom,项目名称:was-maven-plugin,代码行数:8,代码来源:AntXmlPlexusConfigurationWriter.java


示例17: addQNameAttribute

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
protected void addQNameAttribute(XMLWriter writer, String attributeName,
        QName attributeValue, Map namespaceMap) {
    if (attributeValue != null) {
        StringBuffer attributeStringValue = new StringBuffer();
        attributeStringValue.append(namespaceMap.get(attributeValue
                .getNamespaceURI()));
        attributeStringValue.append(":");
        attributeStringValue.append(attributeValue.getLocalPart());
        writer.addAttribute(attributeName, attributeStringValue.toString());
    }

}
 
开发者ID:hitakaken,项目名称:bigfoot-maven-plugins,代码行数:13,代码来源:AbstractDescriptorWriter.java


示例18: writeConnection

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
private void writeConnection(Map namespaceMap, XMLWriter writer,
        Connection connection) {
    writer.startElement("connection");
    if (connection.getConsumes() != null) {
        writer.startElement("consumer");
        addQNameAttribute(writer, "interface-name", connection
                .getConsumes().getInterfaceName(), namespaceMap);
        addQNameAttribute(writer, "service-name", connection.getConsumes()
                .getServiceName(), namespaceMap);
        addStringAttribute(writer, "endpoint-name", connection
                .getConsumes().getEndpointName());
        writer.endElement();
    }
    if (connection.getProvides() != null) {
        writer.startElement("provider");
        addQNameAttribute(writer, "interface-name", connection
                .getProvides().getInterfaceName(), namespaceMap);
        addQNameAttribute(writer, "service-name", connection.getProvides()
                .getServiceName(), namespaceMap);
        addStringAttribute(writer, "endpoint-name", connection
                .getProvides().getEndpointName());
        writer.endElement();
    }

    writer.endElement();

}
 
开发者ID:hitakaken,项目名称:bigfoot-maven-plugins,代码行数:28,代码来源:JbiServiceAssemblyDescriptorWriter.java


示例19: writeServiceUnit

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
private void writeServiceUnit(XMLWriter writer,
        DependencyInformation serviceUnitInfo) throws JbiPluginException {
    writer.startElement("service-unit");
    writer.startElement("identification");
    writer.startElement("name");
    writer.writeText(serviceUnitInfo.getName());
    writer.endElement();
    writer.startElement("description");
    if (serviceUnitInfo.getDescription() != null) {
        writer.writeText(serviceUnitInfo.getDescription());
    } else {
        writer.writeText(serviceUnitInfo.getName());
    }
    writer.endElement();
    writer.endElement();

    writer.startElement("target");
    writer.startElement("artifacts-zip");
    writer.writeText(serviceUnitInfo.getFilename());
    writer.endElement();

    writer.startElement("component-name");
    writer.writeText(serviceUnitInfo.getComponent());
    writer.endElement();

    writer.endElement();

    writer.endElement();
}
 
开发者ID:hitakaken,项目名称:bigfoot-maven-plugins,代码行数:30,代码来源:JbiServiceAssemblyDescriptorWriter.java


示例20: evaluateEffectivePom

import org.codehaus.plexus.util.xml.XMLWriter; //导入依赖的package包/类
public static String evaluateEffectivePom(final Maven3ServerEmbedderImpl embedder,
                                          @NotNull final File file,
                                          @NotNull List<String> activeProfiles)
  throws RemoteException, MavenServerProcessCanceledException {

  final MavenExecutionRequest
    request = embedder.createRequest(file, activeProfiles, Collections.<String>emptyList(), Collections.<String>emptyList());

  final StringWriter w = new StringWriter();

  embedder.executeWithMavenSession(request, new Runnable() {
    @Override
    public void run() {
      try {
        // copied from DefaultMavenProjectBuilder.buildWithDependencies
        ProjectBuilder builder = embedder.getComponent(ProjectBuilder.class);
        ProjectBuildingResult buildingResult = builder.build(new File(file.getPath()), request.getProjectBuildingRequest());

        MavenProject project = buildingResult.getProject();

        XMLWriter writer = new PrettyPrintXMLWriter(w, StringUtils.repeat(" ", XmlWriterUtil.DEFAULT_INDENTATION_SIZE));

        writeHeader(writer);

        writeEffectivePom(project, writer);
      }
      catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
  });

  return w.toString();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:35,代码来源:MavenEffectivePomDumper.java



注:本文中的org.codehaus.plexus.util.xml.XMLWriter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GuiBeacon类代码示例发布时间:2022-05-22
下一篇:
Java Format类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap