private String generatePostToFeedHtml( final String shortMessage, final String originalMessage, final FeedType type) throws UnsupportedEncodingException { final StringBuilder sb = new StringBuilder(MAX_LENGTH + OFFSET); final String start = "<p style=\"white-space: normal;width:150px\"><img style=\"float:left;\" "; switch (type) { case error: sb.append(start) .append("src=\"") .append(ServerInfoImpl.getFullServerURL(this.getThreadLocalRequest())) .append("/resources/images/symbol-error.png\" width=\"35\" height=\"35\">"); break; case system: sb.append(start) .append("src=\"") .append(ServerInfoImpl.getFullServerURL(this.getThreadLocalRequest())) .append("/resources/images/logo.png\" width=\"40\" height=\"40\">"); break; case info: sb.append(start) .append("src=\"") .append(ServerInfoImpl.getFullServerURL(this.getThreadLocalRequest())) .append("/resources/images/info.png\" width=\"35\" height=\"35\">"); break; case data: sb.append(start) .append("src=\"") .append(ServerInfoImpl.getFullServerURL(this.getThreadLocalRequest())) .append("/resources/images/point_ok.png\" width=\"40\" height=\"40\">"); break; default: sb.append(start) .append("src=\"") .append(ServerInfoImpl.getFullServerURL(this.getThreadLocalRequest())) .append("/resources/images/logo.png\" width=\"40\" height=\"40\">"); } final String shortenedOriginal = originalMessage.length() > MAX_LENGTH ? originalMessage.substring(0, MAX_LENGTH) : originalMessage; sb.append("<a href=\"#\" onclick=\"window.open('feed.html?content=") .append(URLEncoder.encode(shortenedOriginal, Const.CONST_ENCODING)) .append("');\">") .append("<span>") .append(new Date()) .append("</span>") .append("<br /></a>") .append(shortMessage) .append("</p>"); return sb.toString(); }
private String valueToHtml(final Entity entity, final Entity point, final Value value) { final StringBuilder sb = new StringBuilder(SIZE); if (!(Double.compare(value.getDoubleValue(), Const.CONST_IGNORED_NUMBER_VALUE) == 0)) { sb.append("<img style=\"float:left\" src=\"") .append(ServerInfoImpl.getFullServerURL(this.getThreadLocalRequest())); switch (value.getAlertState()) { case LowAlert: sb.append("/resources/images/point_low.png\">"); break; case HighAlert: sb.append("/resources/images/point_high.png\">"); break; case IdleAlert: sb.append("/resources/images/point_idle.png\">"); break; case OK: sb.append("/resources/images/point_ok.png\">"); break; } } if (entity != null && point != null) { sb.append(" "); if (!(Double.compare(value.getDoubleValue(), Const.CONST_IGNORED_NUMBER_VALUE) == 0)) { sb.append("Alert Status:").append(value.getAlertState().name()); sb.append("<br>Value:").append(value.getDoubleValue()); } if (!Utils.isEmptyString(value.getNote())) { sb.append("<br>Note:").append(value.getNote()); } sb.append("<a href=\"#\" onclick=\"window.open('report.html?uuid=") .append(point.getKey()) .append("', 'Report',") .append("'height=800,width=800,toolbar=0,status=0,location=0' );\" >") .append(" [more]</a>"); } return sb.toString(); }