当前位置: 首页>>代码示例>>Java>>正文


Java InputSource.setCharacterStream方法代码示例

本文整理汇总了Java中org.xml.sax.InputSource.setCharacterStream方法的典型用法代码示例。如果您正苦于以下问题:Java InputSource.setCharacterStream方法的具体用法?Java InputSource.setCharacterStream怎么用?Java InputSource.setCharacterStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.xml.sax.InputSource的用法示例。


在下文中一共展示了InputSource.setCharacterStream方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCoTTypeMap

import org.xml.sax.InputSource; //导入方法依赖的package包/类
public static ArrayList<CoTTypeDef> getCoTTypeMap(InputStream mapInputStream) throws ParserConfigurationException, SAXException, IOException
{

	ArrayList<CoTTypeDef> types = null;

	String content = getStringFromFile(mapInputStream);


	DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
	DocumentBuilder db = dbf.newDocumentBuilder();
	InputSource source = new InputSource();
	source.setCharacterStream(new StringReader(content));
	Document doc = db.parse(source);
	NodeList nodeList = doc.getElementsByTagName("types");
	types = typeBreakdown(nodeList.item(0));
	return types;
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:18,代码来源:CoTUtilities.java

示例2: testJobTaskCountersXML

import org.xml.sax.InputSource; //导入方法依赖的package包/类
@Test
public void testJobTaskCountersXML() throws Exception {
  WebResource r = resource();
  Map<JobId, Job> jobsMap = appContext.getAllJobs();
  for (JobId id : jobsMap.keySet()) {
    String jobId = MRApps.toString(id);
    for (Task task : jobsMap.get(id).getTasks().values()) {

      String tid = MRApps.toString(task.getID());
      ClientResponse response = r.path("ws").path("v1").path("mapreduce")
          .path("jobs").path(jobId).path("tasks").path(tid).path("counters")
          .accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
      assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType());
      String xml = response.getEntity(String.class);
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      DocumentBuilder db = dbf.newDocumentBuilder();
      InputSource is = new InputSource();
      is.setCharacterStream(new StringReader(xml));
      Document dom = db.parse(is);
      NodeList info = dom.getElementsByTagName("jobTaskCounters");
      verifyAMTaskCountersXML(info, task);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestAMWebServicesTasks.java

示例3: verifyAppStateXML

import org.xml.sax.InputSource; //导入方法依赖的package包/类
protected static void verifyAppStateXML(ClientResponse response,
    RMAppState... appStates) throws ParserConfigurationException,
    IOException, SAXException {
  assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType());
  String xml = response.getEntity(String.class);
  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  DocumentBuilder db = dbf.newDocumentBuilder();
  InputSource is = new InputSource();
  is.setCharacterStream(new StringReader(xml));
  Document dom = db.parse(is);
  NodeList nodes = dom.getElementsByTagName("appstate");
  assertEquals("incorrect number of elements", 1, nodes.getLength());
  Element element = (Element) nodes.item(0);
  String state = WebServicesTestUtils.getXmlString(element, "state");
  boolean valid = false;
  for (RMAppState appState : appStates) {
    if (appState.toString().equals(state)) {
      valid = true;
    }
  }
  String msg = "app state incorrect, got " + state;
  assertTrue(msg, valid);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestRMWebServicesAppsModification.java

示例4: testJobTaskCountersXML

import org.xml.sax.InputSource; //导入方法依赖的package包/类
@Test
public void testJobTaskCountersXML() throws Exception {
  WebResource r = resource();
  Map<JobId, Job> jobsMap = appContext.getAllJobs();
  for (JobId id : jobsMap.keySet()) {
    String jobId = MRApps.toString(id);
    for (Task task : jobsMap.get(id).getTasks().values()) {

      String tid = MRApps.toString(task.getID());
      ClientResponse response = r.path("ws").path("v1").path("history")
          .path("mapreduce").path("jobs").path(jobId).path("tasks").path(tid)
          .path("counters").accept(MediaType.APPLICATION_XML)
          .get(ClientResponse.class);
      assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType());
      String xml = response.getEntity(String.class);
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      DocumentBuilder db = dbf.newDocumentBuilder();
      InputSource is = new InputSource();
      is.setCharacterStream(new StringReader(xml));
      Document dom = db.parse(is);
      NodeList info = dom.getElementsByTagName("jobTaskCounters");
      verifyHsTaskCountersXML(info, task);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:26,代码来源:TestHsWebServicesTasks.java

示例5: verifyHSInfoXML

import org.xml.sax.InputSource; //导入方法依赖的package包/类
public void verifyHSInfoXML(String xml, AppContext ctx)
    throws JSONException, Exception {
  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  DocumentBuilder db = dbf.newDocumentBuilder();
  InputSource is = new InputSource();
  is.setCharacterStream(new StringReader(xml));
  Document dom = db.parse(is);
  NodeList nodes = dom.getElementsByTagName("historyInfo");
  assertEquals("incorrect number of elements", 1, nodes.getLength());

  for (int i = 0; i < nodes.getLength(); i++) {
    Element element = (Element) nodes.item(i);
    verifyHsInfoGeneric(
        WebServicesTestUtils.getXmlString(element, "hadoopVersionBuiltOn"),
        WebServicesTestUtils.getXmlString(element, "hadoopBuildVersion"),
        WebServicesTestUtils.getXmlString(element, "hadoopVersion"),
        WebServicesTestUtils.getXmlLong(element, "startedOn"));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:20,代码来源:TestHsWebServices.java

示例6: testJobCountersXML

import org.xml.sax.InputSource; //导入方法依赖的package包/类
@Test
public void testJobCountersXML() throws Exception {
  WebResource r = resource();
  Map<JobId, Job> jobsMap = appContext.getAllJobs();
  for (JobId id : jobsMap.keySet()) {
    String jobId = MRApps.toString(id);

    ClientResponse response = r.path("ws").path("v1").path("mapreduce")
        .path("jobs").path(jobId).path("counters")
        .accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType());
    String xml = response.getEntity(String.class);
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    InputSource is = new InputSource();
    is.setCharacterStream(new StringReader(xml));
    Document dom = db.parse(is);
    NodeList info = dom.getElementsByTagName("jobCounters");
    verifyAMJobCountersXML(info, jobsMap.get(id));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:22,代码来源:TestAMWebServicesJobs.java

示例7: testNodeSingleAppsXML

import org.xml.sax.InputSource; //导入方法依赖的package包/类
@Test
public void testNodeSingleAppsXML() throws JSONException, Exception {
  WebResource r = resource();
  Application app = new MockApp(1);
  nmContext.getApplications().put(app.getAppId(), app);
  HashMap<String, String> hash = addAppContainers(app);
  Application app2 = new MockApp(2);
  nmContext.getApplications().put(app2.getAppId(), app2);
  addAppContainers(app2);

  ClientResponse response = r.path("ws").path("v1").path("node").path("apps")
      .path(app.getAppId().toString() + "/")
      .accept(MediaType.APPLICATION_XML).get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType());
  String xml = response.getEntity(String.class);
  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  DocumentBuilder db = dbf.newDocumentBuilder();
  InputSource is = new InputSource();
  is.setCharacterStream(new StringReader(xml));
  Document dom = db.parse(is);
  NodeList nodes = dom.getElementsByTagName("app");
  assertEquals("incorrect number of elements", 1, nodes.getLength());
  verifyNodeAppInfoXML(nodes, app, hash);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:TestNMWebServicesApps.java

示例8: testJobIdXML

import org.xml.sax.InputSource; //导入方法依赖的package包/类
@Test
public void testJobIdXML() throws Exception {
  WebResource r = resource();
  Map<JobId, Job> jobsMap = appContext.getAllJobs();
  for (JobId id : jobsMap.keySet()) {
    String jobId = MRApps.toString(id);

    ClientResponse response = r.path("ws").path("v1").path("mapreduce")
        .path("jobs").path(jobId).accept(MediaType.APPLICATION_XML)
        .get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType());
    String xml = response.getEntity(String.class);
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    DocumentBuilder db = dbf.newDocumentBuilder();
    InputSource is = new InputSource();
    is.setCharacterStream(new StringReader(xml));
    Document dom = db.parse(is);
    NodeList job = dom.getElementsByTagName("job");
    verifyAMJobXML(job, appContext);
  }

}
 
开发者ID:naver,项目名称:hadoop,代码行数:23,代码来源:TestAMWebServicesJobs.java

示例9: testJobsXML

import org.xml.sax.InputSource; //导入方法依赖的package包/类
@Test
public void testJobsXML() throws Exception {
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("mapreduce")
      .path("jobs").accept(MediaType.APPLICATION_XML)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType());
  String xml = response.getEntity(String.class);
  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  DocumentBuilder db = dbf.newDocumentBuilder();
  InputSource is = new InputSource();
  is.setCharacterStream(new StringReader(xml));
  Document dom = db.parse(is);
  NodeList jobs = dom.getElementsByTagName("jobs");
  assertEquals("incorrect number of elements", 1, jobs.getLength());
  NodeList job = dom.getElementsByTagName("job");
  assertEquals("incorrect number of elements", 1, job.getLength());
  verifyAMJobXML(job, appContext);

}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestAMWebServicesJobs.java

示例10: testNodes2XML

import org.xml.sax.InputSource; //导入方法依赖的package包/类
@Test
public void testNodes2XML() throws JSONException, Exception {
  rm.start();
  WebResource r = resource();
  rm.registerNode("h1:1234", 5120);
  rm.registerNode("h2:1235", 5121);
  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path("nodes").accept(MediaType.APPLICATION_XML)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType());
  String xml = response.getEntity(String.class);

  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  DocumentBuilder db = dbf.newDocumentBuilder();
  InputSource is = new InputSource();
  is.setCharacterStream(new StringReader(xml));
  Document dom = db.parse(is);
  NodeList nodesApps = dom.getElementsByTagName("nodes");
  assertEquals("incorrect number of elements", 1, nodesApps.getLength());
  NodeList nodes = dom.getElementsByTagName("node");
  assertEquals("incorrect number of elements", 2, nodes.getLength());
  rm.stop();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:TestRMWebServicesNodes.java

示例11: sourceToInputSource

import org.xml.sax.InputSource; //导入方法依赖的package包/类
/**
 * Attempt to obtain a SAX InputSource object from a Source
 * object.
 *
 * @param source Must be a non-null Source reference.
 *
 * @return An InputSource, or null if Source can not be converted.
 */
public static InputSource sourceToInputSource(Source source) {

    if (source instanceof SAXSource) {
        return ((SAXSource) source).getInputSource();
    } else if (source instanceof StreamSource) {
        StreamSource ss      = (StreamSource) source;
        InputSource  isource = new InputSource(ss.getSystemId());

        isource.setByteStream(ss.getInputStream());
        isource.setCharacterStream(ss.getReader());
        isource.setPublicId(ss.getPublicId());

        return isource;
    } else {
        return null;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:SAXSource.java

示例12: get_node_list

import org.xml.sax.InputSource; //导入方法依赖的package包/类
private static NodeList get_node_list(List<String> xml_lines, String addition) {
    StringBuilder sb = new StringBuilder();

    for(String line : xml_lines) { sb.append(line); }
    String xml_string = sb.toString();

    try {
        DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        InputSource is = new InputSource();
        is.setCharacterStream(new StringReader(xml_string));

        Document doc = db.parse(is);

        if(!addition.equals("")) {
            addition = addition + ":";
        }
        return doc.getElementsByTagName(addition + "infoTable");

    } catch (ParserConfigurationException | IOException | SAXException e) {
        e.printStackTrace();
    }

    return null;
}
 
开发者ID:bws0013,项目名称:read_13f,代码行数:25,代码来源:file_processor_new.java

示例13: toInputSource

import org.xml.sax.InputSource; //导入方法依赖的package包/类
private static InputSource toInputSource(StreamSource src) {
    InputSource is = new InputSource();
    is.setByteStream(src.getInputStream());
    is.setCharacterStream(src.getReader());
    is.setPublicId(src.getPublicId());
    is.setSystemId(src.getSystemId());
    return is;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:XmlUtil.java

示例14: testTaskAttemptsXML

import org.xml.sax.InputSource; //导入方法依赖的package包/类
@Test
public void testTaskAttemptsXML() throws JSONException, Exception {
  WebResource r = resource();
  Map<JobId, Job> jobsMap = appContext.getAllJobs();
  for (JobId id : jobsMap.keySet()) {
    String jobId = MRApps.toString(id);
    for (Task task : jobsMap.get(id).getTasks().values()) {

      String tid = MRApps.toString(task.getID());
      ClientResponse response = r.path("ws").path("v1").path("mapreduce")
          .path("jobs").path(jobId).path("tasks").path(tid).path("attempts")
          .accept(MediaType.APPLICATION_XML).get(ClientResponse.class);

      assertEquals(MediaType.APPLICATION_XML_TYPE, response.getType());
      String xml = response.getEntity(String.class);
      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      DocumentBuilder db = dbf.newDocumentBuilder();
      InputSource is = new InputSource();
      is.setCharacterStream(new StringReader(xml));
      Document dom = db.parse(is);
      NodeList attempts = dom.getElementsByTagName("taskAttempts");
      assertEquals("incorrect number of elements", 1, attempts.getLength());

      NodeList nodes = dom.getElementsByTagName("taskAttempt");
      verifyAMTaskAttemptsXML(nodes, task);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:TestAMWebServicesAttempts.java

示例15: getAdditionalSchemasFromXSDFolder

import org.xml.sax.InputSource; //导入方法依赖的package包/类
private void getAdditionalSchemasFromXSDFolder( FieldDefinition detailsDef )
{
	String directory = "src/main/resources/XSD-Add-on/";
	File dir = new File( directory );
	if( ! dir.exists() )
		return;
	if( ! dir.isDirectory() )
		return;

	System.out.println("Scanning directory " + dir.getAbsolutePath());
	// String directory="XSD Add-on/";
	try {
		// get a list of all xsd files in a directory.

		ArrayList<String> fileList = getXSDFiles(directory);


		for (String fileName : fileList)
		{
			String xsdContent = readXSD(directory + fileName);
			InputSource source = new InputSource();
			source.setCharacterStream(new StringReader(xsdContent));

			CoTDetailsDeff.parseXSD( source, detailsDef);
		}


	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:33,代码来源:CoTInboundAdapterDefinition.java


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