List of usage examples for org.apache.commons.lang3 StringEscapeUtils unescapeJava
public static final String unescapeJava(final String input)
Unescapes any Java literals found in the String .
From source file:com.mirth.connect.server.attachments.RegexAttachmentHandler.java
@Override public void setProperties(AttachmentHandlerProperties attachmentProperties) { String regex = attachmentProperties.getProperties().get("regex.pattern"); mimeType = attachmentProperties.getProperties().get("regex.mimetype"); int count = 0; while (attachmentProperties.getProperties().containsKey("regex.replaceKey" + count)) { replacements.put(/* w w w . ja va 2 s . c o m*/ StringEscapeUtils .unescapeJava(attachmentProperties.getProperties().get("regex.replaceKey" + count)), StringEscapeUtils .unescapeJava(attachmentProperties.getProperties().get("regex.replaceValue" + count))); count++; } if (StringUtils.isNotEmpty(regex)) { pattern = Pattern.compile(regex); } else { pattern = null; } }
From source file:ambroafb.general.GeneralConfig.java
/** * ? ?? ?? ? /*from ww w . j a v a2 s .co m*/ * * @param key * @return */ public String getTitleFor(String key) { if (bundle.containsKey(key)) { return StringEscapeUtils.unescapeJava(bundle.getString(key)); } return key; }
From source file:de.fraunhofer.sciencedataamanager.beans.SystemInstanceEdit.java
/** * This method is executed after the page is loaded. * * @param event informations about the page load. *//*from www . j a va2s .c o m*/ public void onLoad(ComponentSystemEvent event) { try { if (!FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap() .get("SystemInstanceID").matches("\\d+")) { return; } systemInstanceID = Integer.parseInt(FacesContext.getCurrentInstance().getExternalContext() .getRequestParameterMap().get("SystemInstanceID")); SystemInstanceDataManager systemInstanceDataProvider = new SystemInstanceDataManager( applicationConfiguration); SystemInstance systemInstance = systemInstanceDataProvider.getSystemInstanceByID(systemInstanceID); SearchFieldMappingManager searchFieldMappingManager = new SearchFieldMappingManager( applicationConfiguration); this.setSearchMetaFields(searchFieldMappingManager.getFieldMappings()); this.setSystemInstanceName(systemInstance.getName()); this.setSystemInstanceGroovyCode(StringEscapeUtils.unescapeJava(systemInstance.getGroovyCode())); this.setSearchFieldMappings(systemInstance.getSearchFieldMappings()); } catch (Exception ex) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex); this.applicationConfiguration.getLoggingManager().logException(ex); } }
From source file:com.truven.runtime.DataTablesParser.java
/** * Characters of the data table./*from w w w .j a v a2 s . c o m*/ * * @param ch * the ch * @param start * the start * @param length * the length * @throws SAXException * the SAX exception * @Override characters in DefaultHandler Object. endElement @see * org.xml.sax.helpers.DefaultHandler#characters(char[], int, int) */ @Override public final void characters(final char[] ch, final int start, final int length) throws SAXException { String value = new String(ch, start, length); value = StringEscapeUtils.unescapeJava(value); if (buffer == null) { buffer = new StringBuffer(); } buffer.append(value); if (isValue) { testDataTable.setValue(rowIndex, columnIndex, buffer.toString().trim()); } }
From source file:de.citec.sc.corpus.CorpusLoader.java
private List<Document> getCONLLDocs(String dataset) { String file = datasetsPath + "dataset/conll/dataset.tsv"; List<String> list = readFileAsList(new File(file)); List<Annotation> goldSet = new ArrayList<Annotation>(); String s = ""; List<Document> docs = new ArrayList<Document>(); String docName = ""; for (String l : list) { if (l.startsWith("-DOCSTART-")) { if (!s.equals("")) { //write out Document d1 = new Document(s, docName); List<Annotation> annotations = new ArrayList<>(); for (Annotation ann : goldSet) { annotations.add(ann.clone()); }//from w w w . ja va 2 s .co m d1.setGoldStandard(annotations); if (dataset.equals("training")) { if (!d1.getDocumentName().contains("testa") && !d1.getDocumentName().contains("testb")) { if (!d1.getGoldStandard().isEmpty()) { docs.add(d1); } } } else if (dataset.equals("testa")) { if (d1.getDocumentName().contains("testa")) { if (!d1.getGoldStandard().isEmpty()) { docs.add(d1); } } } else if (dataset.equals("testb")) { if (d1.getDocumentName().contains("testb")) { if (!d1.getGoldStandard().isEmpty()) { docs.add(d1); } } } goldSet.clear(); s = ""; } docName = l; } else { String[] content = l.split("\t"); if (content.length == 6) { //do B I I //European B European Commission European_Commission if (content[1].equals("B")) { int startIndex = s.length(); int endIndex = s.length() + content[2].length(); String label = content[2]; String uri = content[4].replace("http://en.wikipedia.org/wiki/", ""); label = StringEscapeUtils.unescapeJava(label); try { label = URLDecoder.decode(label, "UTF-8"); } catch (Exception e) { } uri = StringEscapeUtils.unescapeJava(uri); try { uri = URLDecoder.decode(uri, "UTF-8"); } catch (Exception e) { } Annotation a1 = new Annotation(label, uri, startIndex, endIndex, new VariableID("A" + goldSet.size())); goldSet.add(a1); s += content[0] + " "; } else { s += content[0] + " "; } } if (content.length == 4) { //get string s += content[0] + " "; } if (content.length == 1) { if (l.equals("")) { s += "\n"; } else { s += content[0] + " "; } } } } if (goldSet.size() > 0 && !s.equals("")) { //last doc Document d1 = new Document(s, docName); List<Annotation> annotations = new ArrayList<>(); for (Annotation ann : goldSet) { annotations.add(ann.clone()); } d1.setGoldStandard(annotations); if (dataset.equals("training")) { if (!d1.getDocumentName().contains("testa") && !d1.getDocumentName().contains("testb")) { if (!d1.getGoldStandard().isEmpty()) { docs.add(d1); } } } else if (dataset.equals("testa")) { if (d1.getDocumentName().contains("testa")) { if (!d1.getGoldStandard().isEmpty()) { docs.add(d1); } } } else if (dataset.equals("testb")) { if (d1.getDocumentName().contains("testb")) { if (!d1.getGoldStandard().isEmpty()) { docs.add(d1); } } } //docs.add(d1); goldSet.clear(); s = ""; } return docs; }
From source file:de.fraunhofer.sciencedataamanager.beans.SystemInstanceManagement.java
/** * Returns the system instance./* w ww . ja v a 2 s . c o m*/ * * @return the system instance. */ public SystemInstance getSystemInstanceByID() { try { if (selectedItem == null || "".equals(selectedItem)) { return null; } int id = Integer.parseInt(selectedItem); for (SystemInstance currentSystemIntance : loadedSystemInstances) { if (currentSystemIntance.getID() == id) { currentSystemIntance .setGroovyCode(StringEscapeUtils.unescapeJava(currentSystemIntance.getGroovyCode())); return currentSystemIntance; } } } catch (Exception ex) { FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("The following error occured: " + ex.toString())); Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex); this.applicationConfiguration.getLoggingManager().logException(ex); } return null; }
From source file:de.fraunhofer.sciencedataamanager.business.SearchExecutionManager.java
/** * Executes the search definition./*www . j a v a 2s . c o m*/ * * @param searchDefinitionID the search definition to be executed. * @throws Exception */ public void execute(int searchDefinitionID) throws Exception { //get all search definitions and loop through each of them. this.applicationConfiguration.getLoggingManager() .log("Prepare execution by getting all required data from database.", LogLevel.DEBUG); LinkedList<SearchDefinitonExecution> searchDefinitonExecutionList = new LinkedList<SearchDefinitonExecution>(); SearchDefinitionDataManager searchDefinitionDataProvider = new SearchDefinitionDataManager( applicationConfiguration); SearchDefinition searchDefinition = searchDefinitionDataProvider .getSearchDefinitionByID(searchDefinitionID); SearchExecutionDataManager searchExecutionDataProvider = new SearchExecutionDataManager( applicationConfiguration); SearchExecution searchExecution = searchExecutionDataProvider .getSystemInstanceBySearchDefinition(searchDefinition); //construct search definition execution run object and set current timestamp SearchDefinitionExecutionRun searchDefinitionExecutionRun = new SearchDefinitionExecutionRun(); searchDefinitionExecutionRun .setDescription(searchDefinition.getName() + " - " + Calendar.getInstance().getTime().toString()); searchDefinitionExecutionRun .setStartExecutionTimestamp(new java.sql.Timestamp(Calendar.getInstance().getTime().getTime())); searchDefinitionExecutionRun.setSearchExecution(searchExecution); searchDefinitionExecutionRun.setSearchDefinitionExecutionList(searchDefinitonExecutionList); SearchDefinitonExecutionRunDataManager searchDefinitonExecutionRunDataManager = new SearchDefinitonExecutionRunDataManager( applicationConfiguration); searchDefinitionExecutionRun = searchDefinitonExecutionRunDataManager .insertSearchDefinitionExecutionRunLastID(searchDefinitionExecutionRun); this.applicationConfiguration.getLoggingManager() .log("System is now accessing each data source through connector.", LogLevel.DEBUG); //loop through each system instance and compile connector code. for (SystemInstance connectorLoop : searchExecution.getSystemInstances()) { this.applicationConfiguration.getLoggingManager() .log("Preparing connector " + connectorLoop.getName() + "for execution!", LogLevel.DEBUG); SearchDefinitonExecution searchDefinitonExecution = null; try { //get groovy code and compile it GroovyClassLoader gcl = new GroovyClassLoader(); Class parsedGroocyClass = gcl .parseClass(StringEscapeUtils.unescapeJava(connectorLoop.getGroovyCode())); Class[] constructorParameterConnector = new Class[1]; constructorParameterConnector[0] = this.applicationConfiguration.getClass(); //Object groovyClassInstance = parsedGroocyClass.newInstance(constructorParameterConnector); Object groovyClassInstance = null; Constructor connectorConstructor = parsedGroocyClass .getDeclaredConstructor(constructorParameterConnector); if (connectorConstructor != null) { groovyClassInstance = connectorConstructor.newInstance(this.applicationConfiguration); } else { groovyClassInstance = parsedGroocyClass.newInstance(); } currentExecutedConnector = (ICloudPaperConnector) groovyClassInstance; //currentExecutedConnector = new ElsevierScienceDirectConnectorBufferAbstract(this.applicationConfiguration); //currentExecutedConnector = new WebOfScienceLightConnector(this.applicationConfiguration); searchExecution.getSearchDefiniton().setSystemInstance(connectorLoop); this.applicationConfiguration.getLoggingManager() .log("Crawling started for connector: " + connectorLoop.getName(), LogLevel.DEBUG); //execute search method and wait for return searchDefinitonExecution = currentExecutedConnector .getCloudPapers(searchExecution.getSearchDefiniton()); this.applicationConfiguration.getLoggingManager() .log("Crawling stopped for connector: " + connectorLoop.getName(), LogLevel.DEBUG); //set search result searchDefinitonExecution.setSearchState("Success"); searchDefinitonExecution.setSearch_Definiton_ID(searchDefinitionID); searchDefinitonExecution.setSystemInstance(connectorLoop); searchDefinitionExecutionRun.getSearchDefinitionExecutionList().add(searchDefinitonExecution); this.applicationConfiguration.getLoggingManager().log( "Connector search finished. Deconstruct connector: " + connectorLoop.getName(), LogLevel.DEBUG); } catch (Exception ex) { searchDefinitonExecution = new SearchDefinitonExecution(); searchDefinitonExecution.setSearch_Definiton_ID(searchDefinitionID); searchDefinitonExecution.setSystemInstance(connectorLoop); searchDefinitonExecution.setSearchState("Failure"); searchDefinitonExecution.setMessage(ex.toString()); searchDefinitonExecution.setFinishedExecutionTimestamp( new java.sql.Timestamp(Calendar.getInstance().getTime().getTime())); searchDefinitionExecutionRun.getSearchDefinitionExecutionList().add(searchDefinitonExecution); this.applicationConfiguration.getLoggingManager().logException(ex); continue; } } //write crawled data to the db this.applicationConfiguration.getLoggingManager().log("Start writing data to local database.", LogLevel.DEBUG); searchDefinitionExecutionRun .setFinishedExecutionTimestamp(new java.sql.Timestamp(Calendar.getInstance().getTime().getTime())); searchDefinitonExecutionRunDataManager.updateSearchDefinitionExecutionRun(searchDefinitionExecutionRun); for (SearchDefinitonExecution searchDefinitonExecution : searchDefinitionExecutionRun .getSearchDefinitionExecutionList()) { for (ScientificPaperMetaInformationParseException scientificPaperMetaInformationParseException : searchDefinitonExecution .getScientificPaperMetaInformationParseException()) { this.applicationConfiguration.getLoggingManager() .logException(scientificPaperMetaInformationParseException.getParseException()); } } this.applicationConfiguration.getLoggingManager().log("Stopped writing data to local database.", LogLevel.DEBUG); }
From source file:de.citec.sc.templates.PageRankTemplate.java
private void loadPageRanks() { pageRankMap = new ConcurrentHashMap<>(19500000); // String path = "dbpediaFiles/pageranks.ttl"; String path = "pagerank.csv"; System.out.print("Loading pagerank scores to memory ..."); try (Stream<String> stream = Files.lines(Paths.get(path))) { stream.parallel().forEach(item -> { String line = item.toString(); String[] data = line.split("\t"); String uri = data[1]; Double v = Double.parseDouble(data[2]); if (!(uri.contains("Category:") || uri.contains("(disambiguation)"))) { uri = StringEscapeUtils.unescapeJava(uri); try { uri = URLDecoder.decode(uri, "UTF-8"); } catch (Exception e) { }//from ww w . j a va 2 s . c o m pageRankMap.put(uri, v); } }); } catch (IOException e) { e.printStackTrace(); } System.out.println(" DONE"); System.out.println(pageRankMap.get("Germany")); System.out.println(pageRankMap.get("History_of_Germany")); System.out.println(pageRankMap.get("German_language")); int z = 1; }
From source file:controllers.ClimateServiceController.java
public Result savePage() { JsonNode json = request().body().asJson(); if (json == null) { System.out.println("Climate service not saved, expecting Json data"); return badRequest("Climate service not saved, expecting Json data"); }/*w ww . ja v a 2 s .co m*/ // Parse JSON file String temp = json.findPath("pageString").asText(); // Remove delete button from preview page String result = temp.replaceAll( "<td><button type=\\\\\"button\\\\\" class=\\\\\"btn btn-danger\\\\\" onclick=\\\\\"Javascript:deleteRow\\(this\\)\\\\\">delete</button></td>", ""); result = StringEscapeUtils.unescapeJava(result); result = result.substring(1, result.length() - 1); System.out.println(result); String str1 = Constants.htmlHead; String str2 = Constants.htmlTail; result = str1 + result + str2; String timeStamp = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss").format(new Date()); String location = "climateServicePageRepository/" + timeStamp + ".txt"; File theDir = new File("climateServicePageRepository"); // if the directory does not exist, create it if (!theDir.exists()) { System.out.println("creating directory: climateServicePageRepository"); boolean create = false; try { theDir.mkdir(); create = true; } catch (SecurityException se) { // handle it } if (create) { System.out.println("DIR created"); } } else { System.out.println("No"); } try { File file = new File(location); BufferedWriter output = new BufferedWriter(new FileWriter(file)); output.write(result); output.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return ok(result); }
From source file:evaluation.simulator.core.statistics.plotEngine.PlotScript.java
public void writePlotScriptToDisk() { String oParams = Simulator.settings.getProperty("OVERWRITABLE_PARAMETERS"); if (oParams == null) { oParams = ""; }/* w w w . ja v a2 s . com*/ if (!oParams.equals("")) { this.setOverwritableParameter(oParams); } String noParams = Simulator.settings.getProperty("NONE_OVERWRITABLE_PARAMETERS"); if (!noParams.equals("")) { this.setNoneOverwritableParameter(noParams); } this.plotScript = StringEscapeUtils.unescapeJava(this.plotScript); Util.writeToFile(this.plotScript, Paths.SIM_OUTPUT_FOLDER_PATH + this.plotScriptFileName); }