use of com.google.cloud.documentai.v1beta2.Document in project pcgen by PCGen.
the class RoomBoardFactory method load.
public static RoomBoard load(File dataDir) {
//Create a new list for the room and board
PairList<RBCost> inns = new PairList<>();
PairList<RBCost> foods = new PairList<>();
PairList<RBCost> animals = new PairList<>();
File path = new File(dataDir, DIR_RNBPRICE);
if (path.isDirectory()) {
File[] dataFiles = path.listFiles(new XMLFilter());
SAXBuilder builder = new SAXBuilder();
for (int i = 0; i < dataFiles.length; i++) {
try {
Document methodSet = builder.build(dataFiles[i]);
DocType dt = methodSet.getDocType();
if (//$NON-NLS-1$
dt.getElementName().equals("RNBPRICE")) {
//Do work here
loadRBData(methodSet, inns, foods, animals);
}
methodSet = null;
dt = null;
} catch (Exception e) {
Logging.errorPrintLocalised("XML Error with file {0}", dataFiles[i].getName());
Logging.errorPrint(e.getMessage(), e);
}
}
} else {
//$NON-NLS-1$
Logging.errorPrintLocalised("in_plugin_overland_noDatafile", path.getPath());
}
return new RoomBoardImplementation(inns, foods, animals);
}
use of com.google.cloud.documentai.v1beta2.Document in project gocd by gocd.
the class XmlView method renderMergedOutputModel.
protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception {
Document document = (Document) model.get("document");
ServletOutputStream outputStream = response.getOutputStream();
try {
XmlUtils.writeXml(document, outputStream);
} finally {
IOUtils.closeQuietly(outputStream);
}
}
use of com.google.cloud.documentai.v1beta2.Document in project gocd by gocd.
the class GoControlLog method writeLogFile.
protected void writeLogFile(File file, Element element) throws IOException {
// Write the log file out, let jdom care about the encoding by using
// an OutputStream instead of a Writer.
OutputStream logStream = null;
try {
Format format = Format.getPrettyFormat();
XMLOutputter outputter = new XMLOutputter(format);
IO.mkdirFor(file);
file.setWritable(true);
logStream = new BufferedOutputStream(new FileOutputStream(file));
outputter.output(new Document(element), logStream);
} finally {
IO.close(logStream);
}
}
use of com.google.cloud.documentai.v1beta2.Document in project dq-easy-cloud by dq-open-cloud.
the class DqXMLUtils method getMapFromInputStream.
/**
* <p>
* 将xml流中的信息放入map中
* </p>
*
* @param inputStream
* : InputStream : xml输入流
* @param paramsMap
* : Map<String, Object> : xml结果容器
* @return Map<String, Object>
* @throws IOException
* @author daiqi 创建时间 2018年2月23日 下午12:49:06
*/
public static Map<String, Object> getMapFromInputStream(InputStream inputStream, Map<String, Object> paramsMap) throws IOException {
if (null == paramsMap) {
paramsMap = new HashMap<>();
}
SAXBuilder builder = new SAXBuilder();
try {
Document doc = builder.build(inputStream);
Element root = doc.getRootElement();
List<Element> list = root.getChildren();
Iterator<Element> it = list.iterator();
while (it.hasNext()) {
Element e = (Element) it.next();
String k = e.getName();
Object v = DqStringUtils.EMPTY;
List<Element> children = e.getChildren();
if (children.isEmpty()) {
v = e.getTextNormalize();
} else {
v = getChildren(children);
}
paramsMap.put(k, v);
}
} catch (JDOMException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
return paramsMap;
}
use of com.google.cloud.documentai.v1beta2.Document in project dq-easy-cloud by dq-open-cloud.
the class XmlUtilsTest method main.
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
SAXBuilder builder = new SAXBuilder();
// Document doc = builder.build(new File("src/test.xml"));
// Document doc = builder.build(new FileInputStream("src/test.xml"));
// Document doc = builder.build(new FileReader("src/test.xml"));
// Document doc = builder.build(new URL("http://localhost:8080/jdomTest/test.xml"));
Document doc = builder.build(DqSourceCodeRelativePath.RESOURCES + "\\test.xml");
readXmlFile(doc);
// addXmlElement(doc);
// updateXmlElement(doc);
// deleteXmlElement(doc);
}
Aggregations