protected String interpolate(String string, Object... params) { return Interpolator.instance().interpolate(string, params); }
@Override public String getDescription() { return Interpolator.instance().interpolate(description); }
private Object interpolate(Object message) { return message!=null && message instanceof String ? Interpolator.instance().interpolate( (String) message ) : message; }
public String getViewId() { return Interpolator.instance().interpolate(viewId); }
@Override public String get(Object key) { if (key instanceof String) { String resourceKey = (String) key; String resource; try { resource = bundle.getString(resourceKey); } catch (MissingResourceException mre) { return resourceKey; } if (resource == null) { return resourceKey; } else { return Interpolator.instance().interpolate(resource); } } else { return null; } }
protected static String getDisplayMessage(Exception e, String message) { if ( Strings.isEmpty(message) && e.getMessage()!=null ) { return e.getMessage(); } else { return Interpolator.instance().interpolate(message, e); } }
public void interpolateAndRedirect(String url) { Map<String, Object> parameters = new HashMap<String, Object>(); int loc = url.indexOf('?'); if (loc>0) { StringTokenizer tokens = new StringTokenizer( url.substring(loc), "?=&" ); while ( tokens.hasMoreTokens() ) { String name = tokens.nextToken(); if (tokens.hasMoreTokens()) { String value = Interpolator.instance().interpolate( tokens.nextToken() ); parameters.put(name, value); } } url = url.substring(0, loc); } redirect(url, parameters, true, true); }
public void interpolate(Object... params) { if (!Strings.isEmpty(summaryTemplate)) { this.summary = Interpolator.instance().interpolate(summaryTemplate, params); } if (!Strings.isEmpty(detailTemplate)) { this.detail = Interpolator.instance().interpolate(detailTemplate, params); } }
/** * Gets a suggestion string of available constants from a class. * * @param className The class to examine * @return The suggestion string */ public static String getValidConstantsSuggestion(String className) { List<String> constants = getValidContants(className); StringBuffer buffer = new StringBuffer(); int i = 0; // Loop through the fields for (String field : constants) { buffer.append(i++ == 0 ? field : ", " + field); } return Interpolator.instance().interpolate("[#0]", buffer.toString()); }
public String renderDescription(String viewId) { return Interpolator.instance().interpolate( getDescription(viewId) ); }
public String renderDescription() { return Interpolator.instance().interpolate( getDescription() ); }
@SuppressWarnings("finally") private Object interpolate(Object object, Object... params) { if (object instanceof String) { try { object = Interpolator.instance().interpolate( (String) object, params ); } catch (Exception e) { log.error("exception interpolating string: " + object, e); } finally { return object; } } else { return object; } }
public StyleMap parseProperty(String key, String[] values) { String value = values[0]; if (!isBoolean(value)) { String message = Interpolator.instance().interpolate("#0 is not a boolean in #1", value, key); throw new ExcelWorkbookException(message); } StyleMap styleMap = new StyleMap(); styleMap.put(key, Boolean.parseBoolean(value)); return styleMap; } }
public StyleMap parseProperty(String key, String[] values) { String value = values[0]; if (!isNumeric(value)) { String message = Interpolator.instance().interpolate("#0 is not a number in #1", value, key); throw new ExcelWorkbookException(message); } StyleMap styleMap = new StyleMap(); styleMap.put(key, Integer.parseInt(value)); return styleMap; } }
public StyleMap parseProperty(String key, String[] values) { StyleMap styleMap = new StyleMap(); for (int i = 0; i < values.length; i++) { String value = values[i]; String indexedKey = CSSNames.COLUMN_WIDTHS + i; if (COLUMN_WIDTH_WILDCARD.equals(value)) { // Skip it, just moving along } else if (isNumeric(value)) { styleMap.put(indexedKey, Integer.parseInt(value)); } else { String message = Interpolator.instance().interpolate("Column widths must be numerical or *, not #0", value); throw new ExcelWorkbookException(message); } } return styleMap; } }
public Object getValue() { Object theValue = valueOf("value", value); if (theValue == null) { try { theValue = cmp2String(FacesContext.getCurrentInstance(), this); } catch (IOException e) { String message = Interpolator.instance().interpolate("Could not render cell #0", getId()); throw new ExcelWorkbookException(message, e); } } return theValue; }
/** * Moves the row pointer to the next row. Used internally when adding data * */ private void nextRow() { if (log.isTraceEnabled()) { log.trace("Moving from row #0 to #1", currentRowIndex, currentRowIndex + 1); } currentRowIndex++; if (currentRowIndex >= MAX_ROWS) { throw new ExcelWorkbookException(Interpolator.instance() .interpolate("Excel only supports {0} rows", MAX_ROWS)); } }
/** * Creates a JExcelAPI representation of a paper size * * @param paperSize The type of paper size to create * @return The paper size representation */ public static PaperSize createPaperSize(String paperSize) { if (log.isTraceEnabled()) { log.trace("Creating paper size for #0", paperSize); } try { return paperSize == null ? PaperSize.A4 : (PaperSize) getConstant(PAPER_SIZE_CLASS_NAME, paperSize.toUpperCase()); } catch (NoSuchFieldException e) { String message = Interpolator.instance().interpolate("Page size {0} not supported, try {1}", paperSize, getValidConstantsSuggestion(PAPER_SIZE_CLASS_NAME)); throw new ExcelWorkbookException(message, e); } }
/** * Creates a JExcelAPI representation of a page orientation * * @param orientation The type of orientation to create * @return The page orientation representation */ public static PageOrientation createPageOrientation(String orientation) { if (log.isTraceEnabled()) { log.trace("Creating page orientation for #0", orientation); } try { return orientation == null ? PageOrientation.LANDSCAPE : (PageOrientation) getConstant(PAGE_ORIENTATION_CLASS_NAME, orientation.toUpperCase()); } catch (NoSuchFieldException e) { String message = Interpolator.instance().interpolate("Page orientation {0} not supported, try {1}", orientation, getValidConstantsSuggestion(PAGE_ORIENTATION_CLASS_NAME)); throw new ExcelWorkbookException(message, e); } }
/** * Creates a JExcelAPI representation of a border * * @param border The requested border * @return border representation * @see <a * href="http://jexcelapi.sourceforge.net/resources/javadocs/2_6/docs/jxl/format/Border.html">Border</a> */ public static Border createBorder(String border) { if (log.isTraceEnabled()) { log.trace("Creating border for #0", border); } try { return border == null ? Border.ALL : (Border) getConstant(BORDER_CLASS_NAME, border.toUpperCase()); } catch (NoSuchFieldException e) { String message = Interpolator.instance().interpolate("Border {0} not supported, try {1}", border, getValidConstantsSuggestion(BORDER_CLASS_NAME)); throw new ExcelWorkbookException(message, e); } }