
org.sakaiproject.chat2.model.ChatMessage Maven / Gradle / Ivy
The newest version!
/**********************************************************************************
* $URL: https://source.sakaiproject.org/svn/chat/tags/sakai-10.7/chat-api/api/src/java/org/sakaiproject/chat2/model/ChatMessage.java $
* $Id: ChatMessage.java 105079 2012-02-24 23:08:11Z [email protected] $
***********************************************************************************
*
* Copyright (c) 2007, 2008 The Sakai Foundation
*
* Licensed under the Educational Community License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.opensource.org/licenses/ECL-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**********************************************************************************/
package org.sakaiproject.chat2.model;
import java.util.Date;
import java.util.Stack;
import org.sakaiproject.component.cover.ServerConfigurationService;
import org.sakaiproject.entity.api.Entity;
import org.sakaiproject.entity.api.ResourceProperties;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
*
* @author andersjb
*
*/
public class ChatMessage implements Entity {
private String id;
private ChatChannel chatChannel;
private String owner;
private Date messageDate;
private String body;
private String migratedMessageId;
public ChatMessage() {
}
static String urlRegexp = "https?://[\\S]+";
static String bodyRegexp = ".*"+urlRegexp+".*";
static String parenRegexp = "[\\s+(]";
static String cleanRegexp = "\\s+";
static String firstRegexp = "^";
static String href_1 = "";
static String href_3 = " ";
/** Get body of chat message
**/
public String getBody() {
return body;
}
/** Set body of chat message, adding html anchor tags as appropriate
**/
public void setBody(String body) {
String formattedBody = body;
// create hyperlinks from urls
if ( formattedBody.matches(bodyRegexp) )
{
// split on spaces, parenthesis, and backslashes
String[] parts = formattedBody.split("[\\s()\\\\]");
for (int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy