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:ca.hedlund.jiss.blocks.preprocessor.ListBlocksPreprocessor.java
@Override public boolean preprocessCommand(JissModel jissModel, String orig, StringBuffer cmd) { if (!orig.startsWith("::block list")) return false; final ScriptEngine se = jissModel.getScriptEngine(); final ScriptEngineFactory seFactory = se.getFactory(); final boolean incnl = !seFactory.getOutputStatement("").startsWith("println"); final List<String> blockInfoCmds = new ArrayList<String>(); blockInfoCmds.add(seFactory.getOutputStatement("Available blocks:" + (incnl ? "\\n" : ""))); final Matcher matcher = LIST_BLOCKS_PATTERN.matcher(orig); if (matcher.matches()) { final String blockNameRegex = matcher.group(1); final BlockManager bm = new BlockManager(); for (String blockName : bm.getBlocks()) { boolean printBlock = true; if (blockNameRegex != null) { printBlock = blockName.matches(blockNameRegex); }/* w w w .j a v a 2s .c om*/ if (printBlock) { blockInfoCmds.add(seFactory.getOutputStatement(blockName) + (incnl ? "\\n" : "")); } } } final String program = seFactory.getProgram(blockInfoCmds.toArray(new String[0])); cmd.setLength(0); cmd.append(StringEscapeUtils.unescapeJava(program)); return false; }
From source file:com.test.shopping.view.ProductDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { /*// w ww . ja v a 2 s. c o m * Inflate the layout based on the current product details. * Fetch the product associated with the current position in product id list */ ProductDataModel product = CacheUtil.getInstance(getActivity()).getProduct(mPosition); ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.product_detail, container, false); TextView productName = (TextView) rootView.findViewById(R.id.product_name); productName.setText(StringEscapeUtils.unescapeJava(product.getProductName())); String longDes = product.getLongDescription(); TextView longDescLabel = (TextView) rootView.findViewById(R.id.long_description_label); TextView longDesc = (TextView) rootView.findViewById(R.id.long_description); if (longDes != null && longDes.length() > 0) { longDesc.setText(Jsoup.clean(longDes, Whitelist.simpleText())); longDesc.setVisibility(View.VISIBLE); longDescLabel.setVisibility(View.VISIBLE); } else { longDesc.setVisibility(View.INVISIBLE); longDescLabel.setVisibility(View.INVISIBLE); } TextView price = (TextView) rootView.findViewById(R.id.price); price.setText(product.getPrice()); ImageView imageView = (ImageView) rootView.findViewById(R.id.image); ImageLoader loader = ConnectionUtil.getInstance(sContext).getImageLoader(); loader.get(product.getProductImage(), ImageLoader.getImageListener(imageView, R.mipmap.ic_launcher, R.mipmap.ic_launcher)); TextView ratingCountView = (TextView) rootView.findViewById(R.id.rating_count); ratingCountView.setText("(" + String.valueOf(product.getReviewCount() + ")")); RatingBar bar = (RatingBar) rootView.findViewById(R.id.ratingBar); bar.setRating((int) product.getReviewRating()); bar.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); TextView inStock = (TextView) rootView.findViewById(R.id.inStock); if (product.isInStock()) { inStock.setTextColor(getResources().getColor(android.R.color.holo_green_dark)); inStock.setText(R.string.in_stock_label); } else { inStock.setTextColor(getResources().getColor(android.R.color.holo_red_dark)); inStock.setText(R.string.out_of_stock_label); } return rootView; }
From source file:com.fecresgam.dbsd.translator.dto.CommonTable.java
/** * Creates a new Common Table./* w w w. j a v a 2 s . c om*/ * * @param name such information. * @param type such information. * @param description such information. * @param columns such information. * @param constraints such information. * @param dataRows such information. */ public CommonTable(final String name, final TableType type, final String description, final List<Column> columns, final List<Constraint> constraints, final List<List<Data>> dataRows) { final CollectionUtils collectionUtils = CollectionUtils.getInstance(); this.name = name; this.type = type; this.description = StringEscapeUtils.unescapeJava(description); this.orderedColumns = columns; this.orderedConstraints = constraints; // put intos maps this.columns = collectionUtils.putIntoMap(columns); this.constraints = collectionUtils.putIntoMap(constraints); this.dataRows = dataRows; }
From source file:ca.hedlund.jiss.preprocessor.LangPreprocessor.java
private void printCurrentLang(JissModel model, StringBuffer cmd) { final List<String> cmds = new ArrayList<String>(); final ScriptEngineFactory factory = model.getScriptEngine().getFactory(); final String engineInfo = factory.getLanguageName() + " " + factory.getLanguageVersion() + ":" + factory.getEngineName() + " " + factory.getEngineVersion(); cmds.add(createPrintCmd(model, engineInfo)); final String prog = StringEscapeUtils.unescapeJava(factory.getProgram(cmds.toArray(new String[0]))); cmd.append(prog);/*from w w w . j av a2 s. c o m*/ }
From source file:mServer.crawler.sender.MediathekSrf.java
@Override public void addToList() { // data-teaser-title="1 gegen 100" // data-teaser-url="/sendungen/1gegen100" final String muster = "{\"id\":\""; MSStringBuilder seite = new MSStringBuilder(Const.STRING_BUFFER_START_BUFFER); listeThemen.clear();/*from w w w .jav a 2 s . c o m*/ meldungStart(); GetUrl getUrlIo = new GetUrl(getWartenSeiteLaden()); seite = getUrlIo.getUri_Utf(SENDERNAME, SRF_TOPIC_PAGE_URL, seite, ""); int pos = 0; int pos1; String thema, id; while ((pos = seite.indexOf(muster, pos)) != -1) { pos += muster.length(); if ((pos1 = seite.indexOf("\"", pos)) != -1) { id = seite.substring(pos, pos1); if (id.length() < 10) { //{"id":"A","title":"A","contai.... continue; } if (!id.isEmpty()) { thema = seite.extract("\"title\":\"", "\"", pos1); thema = StringEscapeUtils.unescapeJava(thema).trim(); listeThemen.addUrl(new String[] { id, thema }); } } } if (Config.getStop() || listeThemen.isEmpty()) { meldungThreadUndFertig(); } else { meldungAddMax(listeThemen.size()); for (int t = 0; t < getMaxThreadLaufen(); ++t) { Thread th = new ThemaLaden(); th.setName(SENDERNAME + t); th.start(); } } }
From source file:de.fraunhofer.sciencedataamanager.beans.DataExportInstanceEdit.java
/** * The method is executed during first execution of the page and loads the * initial data from database./*from w w w . java 2 s . c om*/ * * @param event from the JSF Framework */ public void onLoad(ComponentSystemEvent event) { try { dataExportInstanceID = Integer.parseInt(FacesContext.getCurrentInstance().getExternalContext() .getRequestParameterMap().get("DataExportInstanceID")); DataExportInstanceDataManager dataExportInstanceDataProvider = new DataExportInstanceDataManager( applicationConfiguration); DataExportInstance dataExportInstance = dataExportInstanceDataProvider .getDataExportInstanceByID(dataExportInstanceID); this.setDataExportInstanceName(dataExportInstance.getName()); this.setDataExportFilePostfix(dataExportInstance.getExportFilePostfix()); this.setDataExportFilePrefix(dataExportInstance.getExportFilePrefix()); this.setResponseContentType(dataExportInstance.getResponseContentType()); this.setDataExportInstanceGroovyCode( StringEscapeUtils.unescapeJava(dataExportInstance.getGroovyCode())); } catch (Exception ex) { Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, null, ex); this.applicationConfiguration.getLoggingManager().logException(ex); } }
From source file:ca.hedlund.jiss.preprocessor.LangPreprocessor.java
private void printLangs(JissModel model, StringBuffer cmd) { final ScriptEngineManager manager = new ScriptEngineManager(JissModel.class.getClassLoader()); final List<String> cmds = new ArrayList<String>(); for (ScriptEngineFactory factory : manager.getEngineFactories()) { final String engineInfo = factory.getLanguageName() + " " + factory.getLanguageVersion() + ":" + factory.getEngineName() + " " + factory.getEngineVersion(); cmds.add(createPrintCmd(model, engineInfo)); }/*from ww w .ja v a 2s .co m*/ final ScriptEngineFactory factory = model.getScriptEngine().getFactory(); final String prog = StringEscapeUtils.unescapeJava(factory.getProgram(cmds.toArray(new String[0]))); cmd.append(prog); }
From source file:brut.androlib.meta.YamlStringEscapeUtils.java
/** * <p>Unescapes any Java literals found in the <code>String</code>. * For example, it will turn a sequence of <code>'\'</code> and * <code>'n'</code> into a newline character, unless the <code>'\'</code> * is preceded by another <code>'\'</code>.</p> * * @param str the <code>String</code> to unescape, may be null * @return a new unescaped <code>String</code>, <code>null</code> if null string input *///www. java 2 s.com public static String unescapeString(String str) { return StringEscapeUtils.unescapeJava(str); }
From source file:com.datastax.loader.parser.AbstractParser.java
public String unescape(String instr) { return StringEscapeUtils.unescapeJava(instr); }
From source file:de.fraunhofer.sciencedataamanager.business.DataExportExecutionManager.java
/** * * @param searchDefintion the search definition to be exportet. * @param dataExportInstanceID the id of the data export instance. * @param outputStream the output stream. * @throws Exception during export./*from w w w . jav a 2 s. c o m*/ */ public void export(SearchDefinition searchDefintion, int dataExportInstanceID, ExternalContext externalContext) throws Exception { //In the first step, the method gets all search definition execution and loops afterwards through each of the object. SearchDefinitonExecutionDataManager searchDefinitonExecutionDataManager = new SearchDefinitonExecutionDataManager( applicationConfiguration); LinkedList<SearchDefinitonExecution> searchDefinitonExecutionList = searchDefinitonExecutionDataManager .getSearchDefinitionExecutionForSearchDefinition(searchDefintion); Map<String, Map<String, List<Object>>> allConnectorsToExport = new HashMap<String, Map<String, List<Object>>>(); int i = 0; //get the downloaded data for each system instance for (SearchDefinitonExecution currentSearchDefinitonExecution : searchDefinitonExecutionList) { ScientificPaperMetaInformationDataManager scientificPaperMetaInformationDataManager = new ScientificPaperMetaInformationDataManager( applicationConfiguration); Map<String, List<Object>> dataToExport = scientificPaperMetaInformationDataManager .getScientificMetaInformationBySearchDefinitionAsMap(currentSearchDefinitonExecution); allConnectorsToExport.put(currentSearchDefinitonExecution.getSystemInstance().getName(), dataToExport); i++; } //select instance modul, compile it and write data to the outputstream DataExportInstanceDataManager dataExportInstanceDataManager = new DataExportInstanceDataManager( applicationConfiguration); DataExportInstance dataExportInstance = dataExportInstanceDataManager .getDataExportInstanceByID(dataExportInstanceID); String excelExportDefaultFilename = dataExportInstance.getExportFilePrefix() + new SimpleDateFormat("yyyyMMddhhmm").format(new Date()) + dataExportInstance.getExportFilePostfix(); externalContext.setResponseContentType(dataExportInstance.getResponseContentType()); externalContext.setResponseHeader("Content-Disposition", "attachment; filename=\"" + excelExportDefaultFilename + "\""); GroovyClassLoader gcl = new GroovyClassLoader(); Class parsedGroocyClass = gcl .parseClass(StringEscapeUtils.unescapeJava(dataExportInstance.getGroovyCode())); Object groovyClassInstance = parsedGroocyClass.newInstance(); //ExcelDataExport currentDataExportInstance = new ExcelDataExport(); IExportScientificPaperMetaInformation currentDataExportInstance = (IExportScientificPaperMetaInformation) groovyClassInstance; currentDataExportInstance.export(allConnectorsToExport, externalContext.getResponseOutputStream()); }