use of com.google.cloud.language.v1beta2.Document in project JMRI by JMRI.
the class TrainManagerXml 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-trains.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-trains.xsl");
// NOI18N
ProcessingInstruction p = new ProcessingInstruction("xml-stylesheet", m);
doc.addContent(0, p);
TrainManager.instance().store(root);
TrainScheduleManager.instance().store(root);
AutomationManager.instance().store(root);
writeXML(file, doc);
// done - train file now stored, so can't be dirty
setDirty(false);
}
use of com.google.cloud.language.v1beta2.Document in project JMRI by JMRI.
the class VSDecoderPreferences method save.
public void save() {
if (prefFile == null) {
return;
}
XmlFile xf = new XmlFile() {
};
// odd syntax is due to XmlFile being abstract
xf.makeBackupFile(prefFile);
File file = new File(prefFile);
try {
//The file does not exist, create it before writing
File parentDir = file.getParentFile();
if (!parentDir.exists()) {
if (// make directory, check result
!parentDir.mkdir()) {
log.error("failed to make parent directory");
}
}
if (// create file, check result
!file.createNewFile()) {
log.error("createNewFile failed");
}
} catch (Exception exp) {
log.error("Exception while writing the new VSDecoder preferences file, may not be complete: " + exp);
}
try {
Element root = new Element("vsdecoder-preferences");
//Document doc = XmlFile.newDocument(root, XmlFile.dtdLocation+"vsdecoder-preferences.dtd");
Document doc = XmlFile.newDocument(root);
// add XSLT processing instruction
// <?xml-stylesheet type="text/xsl" href="XSLT/throttle.xsl"?>
/*TODO java.util.Map<String,String> m = new java.util.HashMap<String,String>();
m.put("type", "text/xsl");
m.put("href", jmri.jmrit.XmlFile.xsltLocation+"throttles-preferences.xsl");
ProcessingInstruction p = new ProcessingInstruction("xml-stylesheet", m);
doc.addContent(0,p);*/
root.setContent(store());
xf.writeXML(file, doc);
} catch (Exception ex) {
// TODO fix null value for Attribute
log.warn("Exception in storing vsdecoder preferences xml: " + ex);
}
}
use of com.google.cloud.language.v1beta2.Document in project jPOS by jpos.
the class Q2Test method testDecrypt.
@Test
public void testDecrypt() throws Throwable {
String[] args = new String[2];
args[0] = "testString";
args[1] = "testString";
m_q2 = new Q2(args);
Document doc = mock(Document.class);
Element element = mock(Element.class);
given(doc.getRootElement()).willReturn(element);
given(element.getName()).willReturn("testString");
Document result = m_q2.decrypt(doc);
assertSame("result", doc, result);
}
use of com.google.cloud.language.v1beta2.Document in project scylla by bptlab.
the class SimulationConfigurationPane method updateModel.
private boolean updateModel() throws JDOMException, IOException {
Document doc;
SAXBuilder builder = new SAXBuilder();
doc = builder.build(bpmnPath);
Element modelRoot = doc.getRootElement();
try {
creator.setModel(modelRoot, false);
} catch (NoProcessSpecifiedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NotAuthorizedToOverrideException e) {
if (showModelOverrideConfirmationDialog(e) == 0) {
try {
creator.setModel(modelRoot, true);
} catch (NoProcessSpecifiedException | NotAuthorizedToOverrideException e1) {
e1.printStackTrace();
}
} else
return false;
}
// Reimport updated creator elements
startEventPanel.setStartEvent(creator.getStartEvent());
taskPanel.clear();
gatewayPanel.clear();
importCreatorElements();
button_openPM.setEnabled(false);
panelStarteventExpand.setContent(startEventPanel);
panelTasksExpand.setContent(taskPanel);
panelGatewaysExpand.setContent(gatewayPanel);
gatewayPanel.forAll((gateway) -> {
if (gateway instanceof ExclusiveGatewayPanel) {
((ExclusiveGatewayPanel) gateway).initBranches();
}
});
return true;
}
use of com.google.cloud.language.v1beta2.Document in project scylla by bptlab.
the class GlobalConfigurationCreator method createFromFile.
/**
* Creates a new GCCreator from an existing GC xml file
* @param path to xml file
* @return new GCCreator
* @throws JDOMException when errors occur in parsing
* @throws IOException when an I/O error prevents a document from being fully parsed
*/
public static GlobalConfigurationCreator createFromFile(String path) throws JDOMException, IOException {
SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(path);
Element r = doc.getRootElement();
// }
return new GlobalConfigurationCreator(r, doc);
}
Aggregations