Skip to content

Commit

Permalink
Merge branch 'v1.5-dev' into v1.6-dev
Browse files Browse the repository at this point in the history
# Conflicts:
#	freeswitch-esl-example/pom.xml
#	freeswitch-esl-spring-boot-starter-example/pom.xml
#	freeswitch-esl-spring-boot-starter/pom.xml
#	freeswitch-esl/pom.xml
#	pom.xml
  • Loading branch information
zhouhailin committed May 30, 2021
2 parents 8f1dec3 + e8d1a9f commit 078935a
Showing 1 changed file with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,11 +1,41 @@
package link.thingscloud.freeswitch.esl.util;

import link.thingscloud.freeswitch.esl.transport.event.EslEvent;

import java.util.Map;

/**
* @author zhouhailin
* @version 1.5.0
* @version 1.5.1
*/
public class VariableUtil {

private static final String VARIABLE_PREFIX = "variable_";

public static String get(EslEvent event, String key) {
return event.getEventHeaders().get(key);
}

public static long getLongVar(EslEvent event, String key) {
return Long.parseLong(getVar(event.getEventHeaders(), key));
}

public static int getIntVar(EslEvent event, String key) {
return Integer.parseInt(getVar(event.getEventHeaders(), key));
}

public static String getVar(EslEvent event, String key) {
return getVar(event.getEventHeaders(), key);
}

public static String getVar(Map<String, String> eventHeaders, String key) {
if (key.startsWith(VARIABLE_PREFIX)) {
return eventHeaders.get(key);
}
return eventHeaders.get(VARIABLE_PREFIX + key);
}

private VariableUtil() {
}

}

0 comments on commit 078935a

Please sign in to comment.