Search in sources :

Example 76 with Document

use of de.micromata.opengis.kml.v_2_2_0.Document in project google-cloud-java by GoogleCloudPlatform.

the class LanguageServiceClientTest method analyzeSentimentTest.

@Test
@SuppressWarnings("all")
public void analyzeSentimentTest() {
    String language = "language-1613589672";
    AnalyzeSentimentResponse expectedResponse = AnalyzeSentimentResponse.newBuilder().setLanguage(language).build();
    mockLanguageService.addResponse(expectedResponse);
    Document document = Document.newBuilder().build();
    AnalyzeSentimentResponse actualResponse = client.analyzeSentiment(document);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockLanguageService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    AnalyzeSentimentRequest actualRequest = (AnalyzeSentimentRequest) actualRequests.get(0);
    Assert.assertEquals(document, actualRequest.getDocument());
}
Also used : AnalyzeSentimentResponse(com.google.cloud.language.v1.AnalyzeSentimentResponse) Document(com.google.cloud.language.v1.Document) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) AnalyzeSentimentRequest(com.google.cloud.language.v1.AnalyzeSentimentRequest) Test(org.junit.Test)

Example 77 with Document

use of de.micromata.opengis.kml.v_2_2_0.Document in project google-cloud-java by GoogleCloudPlatform.

the class LanguageServiceClientTest method analyzeSyntaxTest.

@Test
@SuppressWarnings("all")
public void analyzeSyntaxTest() {
    String language = "language-1613589672";
    AnalyzeSyntaxResponse expectedResponse = AnalyzeSyntaxResponse.newBuilder().setLanguage(language).build();
    mockLanguageService.addResponse(expectedResponse);
    Document document = Document.newBuilder().build();
    EncodingType encodingType = EncodingType.NONE;
    AnalyzeSyntaxResponse actualResponse = client.analyzeSyntax(document, encodingType);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockLanguageService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    AnalyzeSyntaxRequest actualRequest = (AnalyzeSyntaxRequest) actualRequests.get(0);
    Assert.assertEquals(document, actualRequest.getDocument());
    Assert.assertEquals(encodingType, actualRequest.getEncodingType());
}
Also used : AnalyzeSyntaxRequest(com.google.cloud.language.v1.AnalyzeSyntaxRequest) EncodingType(com.google.cloud.language.v1.EncodingType) Document(com.google.cloud.language.v1.Document) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) AnalyzeSyntaxResponse(com.google.cloud.language.v1.AnalyzeSyntaxResponse) Test(org.junit.Test)

Example 78 with Document

use of de.micromata.opengis.kml.v_2_2_0.Document in project JMRI by JMRI.

the class XmlFile method newDocument.

/**
     * Create the Document object to store a particular root Element.
     *
     * @param root Root element of the final document
     * @param dtd  name of an external DTD
     * @return new Document, with root installed
     */
public static Document newDocument(Element root, String dtd) {
    Document doc = new Document(root);
    doc.setDocType(new DocType(root.getName(), dtd));
    addDefaultInfo(root);
    return doc;
}
Also used : Document(org.jdom2.Document) DocType(org.jdom2.DocType)

Example 79 with Document

use of de.micromata.opengis.kml.v_2_2_0.Document in project JMRI by JMRI.

the class XmlFile method newDocument.

/**
     * Create the Document object to store a particular root Element, without a
     * DocType DTD (e.g. for using a schema)
     *
     * @param root Root element of the final document
     * @return new Document, with root installed
     */
public static Document newDocument(Element root) {
    Document doc = new Document(root);
    addDefaultInfo(root);
    return doc;
}
Also used : Document(org.jdom2.Document)

Example 80 with Document

use of de.micromata.opengis.kml.v_2_2_0.Document in project JMRI by JMRI.

the class LocationManagerXml method writeFile.

@Override
public void writeFile(String name) throws java.io.FileNotFoundException, java.io.IOException {
    log.debug("writeFile {}", name);
    // This is taken in large part from "Java and XML" page 368
    File file = findFile(name);
    if (file == null) {
        file = new File(name);
    }
    // create root element
    // NOI18N
    Element root = new Element("operations-config");
    // NOI18N
    Document doc = newDocument(root, dtdLocation + "operations-locations.dtd");
    // add XSLT processing instruction
    java.util.Map<String, String> m = new java.util.HashMap<String, String>();
    // NOI18N
    m.put("type", "text/xsl");
    // NOI18N
    m.put("href", xsltLocation + "operations-locations.xsl");
    // NOI18N
    ProcessingInstruction p = new ProcessingInstruction("xml-stylesheet", m);
    doc.addContent(0, p);
    LocationManager.instance().store(root);
    ScheduleManager.instance().store(root);
    writeXML(file, doc);
    // done - location file now stored, so can't be dirty
    setDirty(false);
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document) File(java.io.File) ProcessingInstruction(org.jdom2.ProcessingInstruction)

Aggregations

Document (org.jdom2.Document)86 Element (org.jdom2.Element)57 File (java.io.File)29 Test (org.junit.Test)24 DocType (org.jdom2.DocType)23 SAXBuilder (org.jdom2.input.SAXBuilder)20 IOException (java.io.IOException)16 XMLOutputter (org.jdom2.output.XMLOutputter)14 ProcessingInstruction (org.jdom2.ProcessingInstruction)13 XmlFile (jmri.jmrit.XmlFile)11 Document (com.google.cloud.language.v1beta2.Document)10 ApiException (com.google.api.gax.grpc.ApiException)9 Document (com.google.cloud.language.v1.Document)9 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)9 StatusRuntimeException (io.grpc.StatusRuntimeException)9 EncodingType (com.google.cloud.language.v1beta2.EncodingType)8 FileOutputStream (java.io.FileOutputStream)7 EncodingType (com.google.cloud.language.v1.EncodingType)6 FileNotFoundException (java.io.FileNotFoundException)6 JDOMException (org.jdom2.JDOMException)6