List of usage examples for org.dom4j Element getStringValue
String getStringValue();
From source file:com.globalsight.cxe.adapter.msoffice.WordRepairer.java
License:Apache License
private static void forWtNotInWr(Element element) { @SuppressWarnings("unchecked") List<Element> wts = element.selectNodes("//w:t"); for (Element wt : wts) { Element parent = wt.getParent(); if (parent == null || "r".equals(parent.getName())) continue; @SuppressWarnings("unchecked") List<Element> es = parent.elements(); int wtIndex = -1; for (Element e : es) { wtIndex++;/*from www . j av a 2s . co m*/ if (wt.equals(e)) { break; } } for (int i = 1; i < es.size(); i++) { int prefix = wtIndex - i; int suffix = wtIndex + i; if (prefix < 0 && suffix > es.size() - 1) { break; } if (prefix > -1) { Element prefixElement = es.get(prefix); if ("r".equals(prefixElement.getName())) { @SuppressWarnings("unchecked") List<Element> preWts = prefixElement.elements("t"); if (preWts.size() > 0) { String text = wt.getStringValue(); Element preWt = preWts.get(preWts.size() - 1); preWt.setText(preWt.getStringValue() + text); parent.remove(wt); break; } } } if (suffix < es.size()) { Element sufixElement = es.get(prefix); if ("r".equals(sufixElement.getName())) { @SuppressWarnings("unchecked") List<Element> sufWts = sufixElement.elements("t"); if (sufWts.size() > 0) { String text = wt.getStringValue(); Element sufWt = sufWts.get(0); sufWt.setText(text + sufWt.getStringValue()); parent.remove(wt); break; } } } } } }
From source file:com.globalsight.cxe.adapter.msoffice.WordRepairer.java
License:Apache License
private static void forTextInWr(Element element) { @SuppressWarnings("unchecked") List<Node> ts = element.selectNodes("//w:r/text()"); for (Node t : ts) { if (t.getText().matches("[\n\r]*")) { continue; }//from w w w . j a v a 2s .c o m Element wr = t.getParent(); if (wr == null) { continue; } List<?> els = wr.content(); StringBuffer sb = new StringBuffer(); Element wt = null; List<DefaultText> texts = new ArrayList<DefaultText>(); for (Object el : els) { if (el instanceof DefaultText) { DefaultText text = (DefaultText) el; texts.add(text); sb.append(text.getStringValue()); } else if (el instanceof Element) { Element elm = (Element) el; if ("t".equals(elm.getName())) { wt = elm; sb.append(elm.getStringValue()); } } } if (wt == null) { wt = wr.addElement("w:t"); wt.addAttribute("xml:space", "preserve"); } wt.setText(sb.toString()); for (DefaultText text : texts) { wr.remove(text); } } }
From source file:com.globalsight.everest.edit.offline.page.terminology.HtmlTermHelp.java
License:Apache License
@Override public String getLanguage(Locale locale, String terminology, String xml) { ArrayList fieldList = new ArrayList(); ArrayList valueList = new ArrayList(); String htmlCotent = ""; if (xml == null || xml.trim().equals("")) { htmlCotent = "<SPAN class=\"vfieldlabel\"></SPAN><br/>" + "<SPAN class=\"vfieldvalue\"><P></P></SPAN>"; } else {/*from w ww . j a va 2 s. c om*/ try { xml = "<desc>" + xml + "</desc>"; Entry entry = new Entry(xml); Document dom = entry.getDom(); Element root = dom.getRootElement(); List descrip = root.selectNodes("//desc/descripGrp/descrip"); for (int i = 0; i < descrip.size(); i++) { Element content = (Element) descrip.get(i); String field = content.attributeValue("type"); String xmlContent = content.getStringValue(); htmlCotent = htmlCotent + "<SPAN class=\"vfieldlabel\">" + field + "</SPAN><br/>" + "<SPAN class=\"vfieldvalue\"><P>" + xmlContent + "</P></SPAN>"; } } catch (Exception e) { } } String lanString = "<DIV class=\"vlanguageGrp\">" + "<SPAN class=\"vfakeLanguageGrp\">" + "<SPAN class=\"vlanguagelabel\">Language</SPAN>" + "<SPAN class=\"vlanguage\" unselectable=\"on\" locale=\"" + locale.getDisplayLanguage(LOCALE) + "\">" + locale.getCountry().toUpperCase() + "</SPAN>" + "</SPAN>" + "<DIV class=\"vtermGrp\">" + "<DIV class=\"vfakeTermGrp\">" + "<SPAN class=\"vtermlabel\">Term</SPAN>" + "<SPAN class=\"vterm\">" + terminology + "</SPAN>" + "<DIV class=\"vfieldGrp\">" + htmlCotent + "</DIV></DIV></DIV></DIV>"; return lanString; /* return MessageFormat.format(LANGUAGE_GRP, locale .getDisplayLanguage(LOCALE), locale.getCountry().toUpperCase(), terminology, xmlContent, field); */ }
From source file:com.globalsight.everest.edit.offline.ttx.TTXParser.java
License:Apache License
/** * Parse extra info for uploading such as "pageId", "taskId" etc. * //from ww w . j av a 2 s. c o m * @param p_rawElement */ private void parseHeaderInfo(Element p_rawElement) { if (p_rawElement == null) { return; } Iterator utIt = p_rawElement.elementIterator(TTXConstants.UT); while (utIt.hasNext()) { Element utEle = (Element) utIt.next(); Attribute displayTextAtt = utEle.attribute(TTXConstants.UT_ATT_DISPLAYTEXT); if (displayTextAtt != null) { String attValue = displayTextAtt.getValue(); // ignore locked segment - UT gs:locked segment if (TTXConstants.GS_LOCKED_SEGMENT.equalsIgnoreCase(attValue)) { continue; } String utTextNodeValue = utEle.getStringValue(); int index = utTextNodeValue.lastIndexOf(":"); if (index == -1) { continue; } String utName = utTextNodeValue.substring(0, index).trim(); String utValue = utTextNodeValue.substring(index + 1).trim(); if (TTXConstants.GS_ENCODING.equalsIgnoreCase(attValue) || "Encoding".equalsIgnoreCase(utName)) { gs_Encoding = utValue; } else if (TTXConstants.GS_DOCUMENT_FORMAT.equalsIgnoreCase(attValue) || "Document Format".equalsIgnoreCase(utName)) { gs_DocumentFormat = utValue; } else if (TTXConstants.GS_PLACEHOLDER_FORMAT.equalsIgnoreCase(attValue) || "Placeholder Format".equalsIgnoreCase(utName)) { gs_PlaceholderFormat = utValue; } else if (TTXConstants.GS_SOURCE_LOCALE.equalsIgnoreCase(attValue) || "Source Locale".equalsIgnoreCase(utName)) { gs_SourceLocale = utValue; } else if (TTXConstants.GS_TARGET_LOCALE.equalsIgnoreCase(attValue) || "Target Locale".equalsIgnoreCase(utName)) { gs_TargetLocale = utValue; } else if (TTXConstants.GS_PAGEID.equalsIgnoreCase(attValue) || "Page ID".equalsIgnoreCase(utName)) { gs_PageID = utValue; } else if (TTXConstants.GS_WORKFLOW_ID.equalsIgnoreCase(attValue) || "Workflow ID".equalsIgnoreCase(utName)) { gs_WorkflowID = utValue; } else if (TTXConstants.GS_TASK_ID.equalsIgnoreCase(attValue) || "Task ID".equalsIgnoreCase(utName)) { gs_TaskID = utValue; } else if (TTXConstants.GS_EXACT_MATCH_WORD_COUNT.equalsIgnoreCase(attValue) || "Exact Match word count".equalsIgnoreCase(utName)) { gs_ExactMatchWordCount = utValue; } else if (TTXConstants.GS_FUZZY_MATCH_WORD_COUNT.equalsIgnoreCase(attValue) || "Fuzzy Match word count".equalsIgnoreCase(utName)) { gs_FuzzyMatchWordCount = utValue; } else if (TTXConstants.GS_EDIT_ALL.equalsIgnoreCase(attValue) || "Edit all".equalsIgnoreCase(utName)) { gs_EditAll = utValue; } else if (TTXConstants.GS_POPULATE_100_TARGET_SEGMENTS.equals(attValue) || "Populate 100% Target Segments".equalsIgnoreCase(utName)) { gs_Populate100TargetSegments = utValue; } } } }
From source file:com.haulmont.cuba.gui.xml.layout.loaders.SuggestionFieldQueryLoader.java
License:Apache License
protected void loadQuery(SuggestionField suggestionField, Element element) { Element queryElement = element.element("query"); if (queryElement != null) { final boolean escapeValue; String stringQuery = queryElement.getStringValue(); String searchFormat = queryElement.attributeValue("searchStringFormat"); String view = queryElement.attributeValue("view"); String escapeValueForLike = queryElement.attributeValue("escapeValueForLike"); if (StringUtils.isNotEmpty(escapeValueForLike)) { escapeValue = Boolean.valueOf(escapeValueForLike); } else {/*from w ww .j a v a 2 s .c o m*/ escapeValue = false; } String entityClassName = queryElement.attributeValue("entityClass"); if (StringUtils.isNotEmpty(entityClassName)) { suggestionField.setSearchExecutor((searchString, searchParams) -> { DataSupplier supplier = suggestionField.getFrame().getDsContext().getDataSupplier(); Class<Entity> entityClass = ReflectionHelper.getClass(entityClassName); if (escapeValue) { searchString = QueryUtils.escapeForLike(searchString); } searchString = applySearchFormat(searchString, searchFormat); LoadContext loadContext = LoadContext.create(entityClass); if (StringUtils.isNotEmpty(view)) { loadContext.setView(view); } loadContext.setQuery( LoadContext.createQuery(stringQuery).setParameter("searchString", searchString)); //noinspection unchecked return supplier.loadList(loadContext); }); } else { throw new GuiDevelopmentException( String.format("Field 'entityClass' is empty in component %s.", suggestionField.getId()), getContext().getFullFrameId()); } } }
From source file:com.haulmont.cuba.restapi.XMLConverter2.java
License:Apache License
@Override public QueryRequest parseQueryRequest(String content) throws IllegalArgumentException, ClassNotFoundException, ParseException { Document document = Dom4j.readDocument(content); Element rootElement = document.getRootElement(); QueryRequest queryRequest = new QueryRequest(); Element entityElem = rootElement.element("entity"); String entity = entityElem.getTextTrim(); queryRequest.setEntity(entity);/*from w w w .j a v a 2s .c o m*/ Element queryElem = rootElement.element("query"); String query = queryElem.getTextTrim(); queryRequest.setQuery(query); if (rootElement.element("view") != null) { Element viewElem = rootElement.element("view"); String view = viewElem.getTextTrim(); queryRequest.setViewName(view); } if (rootElement.element("max") != null) { Element maxElem = rootElement.element("max"); String maxString = maxElem.getTextTrim(); int max = Integer.parseInt(maxString); queryRequest.setMax(max); } if (rootElement.element("first") != null) { Element firstElem = rootElement.element("first"); String firstString = firstElem.getTextTrim(); int first = Integer.parseInt(firstString); queryRequest.setFirst(first); } if (rootElement.element("dynamicAttributes") != null) { Element dynamicAttributesElem = rootElement.element("dynamicAttributes"); String dynamicAttributesString = dynamicAttributesElem.getTextTrim(); Boolean dynamicAttributes = Boolean.valueOf(dynamicAttributesString); queryRequest.setDynamicAttributes(dynamicAttributes); } if (rootElement.element("params") != null) { Element paramsElem = rootElement.element("params"); List paramList = paramsElem.elements("param"); for (Object obj : paramList) { if (obj instanceof Element) { Element paramElem = (Element) obj; Element nameElem = paramElem.element("name"); String paramName = nameElem.getStringValue(); Element valueElem = paramElem.element("value"); String paramValue = valueElem.getStringValue(); Object value = null; if (paramElem.element("type") != null) { Element typeElem = paramElem.element("type"); String typeString = typeElem.getStringValue(); Class type = ClassUtils.forName(typeString, null); value = ParseUtils.toObject(type, paramValue, this); } else { value = ParseUtils.tryParse(paramValue); } queryRequest.getParams().put(paramName, value != null ? value : paramValue); } } } return queryRequest; }
From source file:com.ms.commons.test.datareader.impl.XmlReaderUtil.java
License:Open Source License
protected static MemoryField readField(Element fieldE) { String name = fieldE.attributeValue("name"); MemoryFieldType type = MemoryFieldType.make(fieldE.attributeValue("type")); Object value = null;// ww w. jav a2s. c o m switch (type) { case Date: String dateStr = fieldE.getStringValue(); if (StringUtils.isBlank(dateStr)) break; try { if (dateStr.length() == SHORT_DATE_LENGTH) { value = shortFormat.parse(dateStr); } else if (dateStr.length() == LONG_DATE_LENGTH) { value = longFormat.parse(dateStr); } } catch (ParseException e) { if (log.isDebugEnabled()) log.debug(""); } break; case Number: String number = fieldE.getStringValue(); if (NumberUtils.isNumber(number)) { value = NumberUtils.createInteger(number); } break; default: value = fieldE.getStringValue(); break; } return new MemoryField(name, type, value); }
From source file:com.taobao.android.builder.tasks.library.publish.UpdatePomTask.java
License:Apache License
private void updatePomXml(File xml) throws IOException, DocumentException { Map<String, DependencyExtraInfo> extraInfoMap = getExtraMap(); File backupFile = new File(xml.getParentFile(), "pom-backup.xml"); FileUtils.deleteQuietly(backupFile); FileUtils.moveFile(xml, backupFile); XMLWriter writer = null;// XML SAXReader reader = new SAXReader(); OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding("UTF-8");// XML?? FileOutputStream fos = new FileOutputStream(xml); try {/*from ww w. j av a2s . c o m*/ Document document = reader.read(backupFile);// ?XML Element dependencies = document.getRootElement().element("dependencies"); if ((null != dependencies) && null != dependencies.elements()) { List<Element> list = dependencies.elements(); for (Element element : list) { List<Element> itemList = element.elements(); String group = ""; String name = ""; String type; String scope; Element scopeEl = null; Element typeEl = null; for (Element element1 : itemList) { if ("groupId".equals(element1.getQName().getName())) { group = element1.getStringValue(); } else if ("artifactId".equals(element1.getQName().getName())) { name = element1.getStringValue(); } else if ("scope".equals(element1.getQName().getName())) { scope = element1.getStringValue(); scopeEl = element1; } else if ("type".equals(element1.getQName().getName())) { type = element1.getStringValue(); typeEl = element1; } } DependencyExtraInfo dependencyExtraInfo = extraInfoMap.get(group + ":" + name); if (null == dependencyExtraInfo) { continue; } //update scope if (StringUtils.isNotEmpty(dependencyExtraInfo.scope)) { if (null != scopeEl) { scopeEl.setText(dependencyExtraInfo.scope); } else { Element newEl = element.addElement("scope"); newEl.setText(dependencyExtraInfo.scope); } } if (StringUtils.isNotEmpty(dependencyExtraInfo.type)) { if (null != typeEl) { typeEl.setText(dependencyExtraInfo.type); } else { Element newEl = element.addElement("type"); newEl.setText(dependencyExtraInfo.type); } } } } writer = new XMLWriter(fos, format); writer.write(document); } finally { if (null != writer) { writer.close(); } IOUtils.closeQuietly(fos); } }
From source file:com.taobao.datax.engine.conf.ParseXMLUtil.java
License:Open Source License
/** * Parse dataX job configuration file.//from w w w . j ava 2s . co m * * @param filename * Job configure filename. * * @return a JobConf instance which describes this Job configuration file. * * */ @SuppressWarnings("unchecked") public static JobConf loadJobConfig(String filename) { JobConf job = new JobConf(); Document document; try { String xml = FileUtils.readFileToString(new File(filename), "UTF-8"); document = DocumentHelper.parseText(xml); } catch (DocumentException e) { LOG.error("DataX Can not find " + filename + " ."); throw new DataExchangeException(e.getCause()); } catch (IOException e) { LOG.error(String.format("DataX read config file %s failed .", filename)); throw new DataExchangeException(e.getCause()); } String xpath = "/jobs/job"; Element jobE = (Element) document.selectSingleNode(xpath); job.setId(jobE.attributeValue("id") == null ? "DataX_is_still_a_virgin" : jobE.attributeValue("id").trim()); JobPluginConf readerJobConf = new JobPluginConf(); Element readerE = (Element) document.selectSingleNode(xpath + "/loader"); if (null == readerE) readerE = (Element) document.selectSingleNode(xpath + "/reader"); String readerId = readerE.attributeValue("id"); readerJobConf.setId(readerId == null ? "virgin-reader" : readerId.trim()); Element readerPluinE = (Element) readerE.selectSingleNode("plugin"); readerJobConf.setName(readerPluinE.getStringValue().trim().replace("loader", "reader").toLowerCase()); Map<String, String> readerParamMap = new HashMap<String, String>(); /* * for historic reason, we need to check concurrency node first add by * bazhen.csy */ if (readerE.selectSingleNode("concurrency") != null) { Element readerConcurrencyE = (Element) readerE.selectSingleNode("concurrency"); readerParamMap.put("concurrency", StrUtils.replaceString(readerConcurrencyE.attributeValue("core"))); } List<Element> readerParamE = (List<Element>) readerE.selectNodes("param"); for (Element e : readerParamE) { readerParamMap.put(e.attributeValue("key").toLowerCase(), StrUtils.replaceString(e.attributeValue("value").trim())); } PluginParam readerPluginParam = new DefaultPluginParam(readerParamMap); // if (!readerPluginParam.hasValue("concurrency") // || readerPluginParam.getIntValue("concurrency", 1) < 0) { // throw new IllegalArgumentException( // "Reader option [concurrency] error !"); // } readerJobConf.setPluginParams(readerPluginParam); List<JobPluginConf> writerJobConfs = new ArrayList<JobPluginConf>(); List<Element> writerEs = (List<Element>) document.selectNodes(xpath + "/dumper"); if (null == writerEs || 0 == writerEs.size()) writerEs = (List<Element>) document.selectNodes(xpath + "/writer"); for (Element writerE : writerEs) { JobPluginConf writerPluginConf = new JobPluginConf(); String writerId = writerE.attributeValue("id"); writerPluginConf.setId(writerId == null ? "virgin-writer" : writerId.trim()); String destructLimit = writerE.attributeValue("destructlimit"); if (destructLimit != null) { writerPluginConf.setDestructLimit(Integer.valueOf(destructLimit)); } Element writerPluginE = (Element) writerE.selectSingleNode("plugin"); writerPluginConf .setName(writerPluginE.getStringValue().trim().replace("dumper", "writer").toLowerCase()); Map<String, String> writerParamMap = new HashMap<String, String>(); /* * for historic reason, we need to check concurrency node add by * bazhen.csy */ if (writerE.selectSingleNode("concurrency") != null) { Element writerConcurrencyE = (Element) writerE.selectSingleNode("concurrency"); writerParamMap.put("concurrency", StrUtils.replaceString(writerConcurrencyE.attributeValue("core"))); } List<Element> writerParamE = (List<Element>) writerE.selectNodes("param"); for (Element e : writerParamE) { writerParamMap.put(e.attributeValue("key").toLowerCase(), StrUtils.replaceString(e.attributeValue("value").trim())); } PluginParam writerPluginParam = new DefaultPluginParam(writerParamMap); writerPluginConf.setPluginParams(writerPluginParam); writerJobConfs.add(writerPluginConf); } job.setReaderConf(readerJobConf); job.setWriterConfs(writerJobConfs); return job; }
From source file:com.thesmartweb.vivliocrawlermaven.VivlioCrawlerMavenMain.java
/** * @param args the command line arguments *///from w w w . j a v a2 s . c o m public static void main(String[] args) { // TODO code application logic here try { OaiPmhServer server = new OaiPmhServer("http://vivliothmmy.ee.auth.gr/cgi/oai2"); RecordsList listRecords = server.listRecords("oai_dc");//we capture all the records in oai dc format List<VivlioCrawlerMavenMain> listtotal = new ArrayList<VivlioCrawlerMavenMain>(); //we capture all the names of the professors and former professor of ECE of AUTH from a txt file //change the directory to yours List<String> profs = Files.readAllLines(Paths.get( "/home/themis/NetBeansProjects/VivlioCrawlerMaven/src/main/java/com/thesmartweb/vivliocrawlermaven/profs.txt")); boolean more = true;//it is a flag used if we encounter more entries than the initial capture JSONArray array = new JSONArray();//it is going to be our final total json array JSONObject jsonObject = new JSONObject();//it is going to be our final total json object while (more) { for (Record rec : listRecords.asList()) { VivlioCrawlerMavenMain vc = new VivlioCrawlerMavenMain(); Element metadata = rec.getMetadata(); if (metadata != null) { //System.out.println(rec.getMetadataAsString()); List<Element> elements = metadata.elements(); //System.out.println(metadata.getStringValue()); for (Element element : elements) { String name = element.getName(); //we get the title, remove \r, \n and beginning and trailing whitespace if (name.equalsIgnoreCase("title")) { vc.title = element.getStringValue(); vc.title = vc.title.trim(); vc.title = vc.title.replaceAll("(\\r|\\n)", ""); if (!(vc.title.endsWith("."))) { vc.title = vc.title + ".";//we also add dot in the end for the titles to be uniformed } } if (name.equalsIgnoreCase("creator")) { vc.creators.add(element.getStringValue());//we capture the students' names } if (name.equalsIgnoreCase("subject")) { vc.subjects.add(element.getStringValue());//we capture the subjects } if (name.equalsIgnoreCase("description")) { vc.description = element.getStringValue();//we capture the abstract } if (name.equalsIgnoreCase("date")) { vc.datestring = element.getStringValue(); } if (name.equalsIgnoreCase("identifier")) { if (element.getStringValue().contains("http://")) { vc.thesisFiles.add(element.getStringValue());//we capture the url of the thesis whole file if (vc.thesisURL == null) { vc.thesisURL = element.getStringValue().substring(0, 32); } } //if the identifier contains the title then it must be the citation //out of the citation we need to extract the supevisor's name if (element.getStringValue().contains(vc.title.substring(0, 10))) { vc.citation = element.getStringValue(); vc.supervisor = element.getStringValue(); Iterator profsIterator = profs.iterator(); vc.supervisor = vc.supervisor.replace(vc.title, "");//we remove the title out of the citation //if we have two students we remove the first occurence of "" which stands for "and" if (vc.creators.size() == 2) { vc.supervisor = vc.supervisor.replaceFirst("", ""); } //we remove the students' names Iterator creatorsIterator = vc.creators.iterator(); while (creatorsIterator.hasNext()) { vc.supervisor = vc.supervisor.replace(creatorsIterator.next().toString(), ""); } boolean profFlag = false;//flag used that declares that we found the professor that was supervisor while (profsIterator.hasNext() && !profFlag) { String prof = profsIterator.next().toString(); //we split the professor's name to surname and name //because some entries have first the surname and others first the name String[] profSplitted = prof.split("\\s+"); String supervisorCleared = vc.supervisor; supervisorCleared = supervisorCleared.replaceAll("\\s+", "");//we clear the white space supervisorCleared = supervisorCleared.replaceAll("(\\r|\\n)", "");//we remove the \r\n //now we check if the citation includes any name of the professors from the txt if (supervisorCleared.contains(profSplitted[0]) && supervisorCleared.contains(profSplitted[1])) { vc.supervisor = prof; profFlag = true; } } //if we don't find the name of the supervisor, we have to perform string manipulation to extract it if (!profFlag) { vc.supervisor = vc.supervisor.trim(); //we remove the word "" which stands for "Thessaloniki" and "" which stands for Greece if (vc.supervisor.contains("")) { vc.supervisor = vc.supervisor.replaceFirst("", ""); } if (vc.supervisor.contains("")) { vc.supervisor = vc.supervisor.replaceFirst("", ""); } if (vc.supervisor.contains("")) { vc.supervisor = vc.supervisor.replaceFirst("", ""); } if (vc.supervisor.contains("")) { vc.supervisor = vc.supervisor.replaceFirst("", ""); } //we remove the year and then we should be left only with the supervisor's name vc.supervisor = vc.supervisor.replace("(", ""); vc.supervisor = vc.supervisor.trim(); vc.supervisor = vc.supervisor.replace(")", ""); vc.supervisor = vc.supervisor.trim(); vc.supervisor = vc.supervisor.replace(",", ""); vc.supervisor = vc.supervisor.trim(); vc.supervisor = vc.supervisor.replace(".", ""); vc.supervisor = vc.supervisor.trim(); vc.supervisor = vc.supervisor.replace(vc.datestring.substring(0, 4), ""); vc.supervisor = vc.supervisor.trim(); } //we put everything in a json object JSONObject obj = new JSONObject(); obj.put("title", vc.title); obj.put("description", vc.description); JSONArray creatorsArray = new JSONArray(); creatorsArray.add(vc.creators); obj.put("creators", creatorsArray); JSONArray subjectsArray = new JSONArray(); List<String> subjectsList = new ArrayList<String>(vc.subjects); subjectsArray.add(subjectsList); obj.put("subjects", subjectsArray); obj.put("datestring", vc.datestring); JSONArray thesisFilesArray = new JSONArray(); thesisFilesArray.add(vc.thesisFiles); obj.put("thesisFiles", thesisFilesArray); obj.put("thesisURL", vc.thesisURL); obj.put("supervisor", vc.supervisor); obj.put("citation", vc.citation); //if you are using JSON.simple do this array.add(obj); } } } listtotal.add(vc);//a list containing all the objects //it is not used for now, but created for potential extension of the work } } //the following if clause searches for new records if (listRecords.getResumptionToken() != null) { listRecords = server.listRecords(listRecords.getResumptionToken()); } else { more = false; } } //we print which records did not have a supervisor for (VivlioCrawlerMavenMain vctest : listtotal) { if (vctest.supervisor == null) { System.out.println(vctest.title); System.out.println(vctest.citation); } } //we create a pretty json with GSON and we write it into a file jsonObject.put("VivliothmmyOldArray", array); JsonParser parser = new JsonParser(); JsonObject json = parser.parse(jsonObject.toJSONString()).getAsJsonObject(); Gson gson = new GsonBuilder().setPrettyPrinting().create(); String prettyJson = gson.toJson(json); try { FileWriter file = new FileWriter( "/home/themis/NetBeansProjects/VivlioCrawlerMaven/src/main/java/com/thesmartweb/vivliocrawlermaven/VivliothmmyOldRecords.json"); file.write(prettyJson); file.flush(); file.close(); } catch (IOException e) { System.out.println("Exception: " + e); } //System.out.print(prettyJson); //int j=0; } catch (OAIException | IOException e) { System.out.println("Exception: " + e); } }