當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。