-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v1.5-dev' into v1.6-dev
# 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
Showing
1 changed file
with
31 additions
and
1 deletion.
There are no files selected for viewing
32 changes: 31 additions & 1 deletion
32
freeswitch-esl/src/main/java/link/thingscloud/freeswitch/esl/util/VariableUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { | ||
} | ||
|
||
} |