本文整理汇总了Java中com.amazon.speech.speechlet.Session.getAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Session.getAttribute方法的具体用法?Java Session.getAttribute怎么用?Java Session.getAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazon.speech.speechlet.Session
的用法示例。
在下文中一共展示了Session.getAttribute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleConfirmed
import com.amazon.speech.speechlet.Session; //导入方法依赖的package包/类
private SpeechletResponse handleConfirmed(IntentRequest request, Session session)
throws CalendarWriteException {
final String dateFormat = session.getAttribute(SESSION_DATE_FORMAT).toString();
final DateTimeFormatter parser = DateTimeFormat.forPattern(dateFormat);
final String title = collectSummary(request);
final String calendar = session.getAttribute(SESSION_CALENDAR) != null ? session.getAttribute(SESSION_CALENDAR).toString() : null;
final String from = session.getAttribute(SESSION_FROM).toString();
final String to = session.getAttribute(SESSION_TO).toString();
calendarService.createEvent(calendar, title,
parser.parseDateTime(from),
parser.parseDateTime(to));
SimpleCard card = new SimpleCard();
card.setTitle(messageService.de("event.new.card.title"));
card.setContent(messageService.de("event.new.card.content", title, from, to));
session.removeAttribute(BasicSpeechlet.KEY_DIALOG_TYPE);
return SpeechletResponse.newTellResponse(
speechService.speechNewEventSaved(request.getLocale()),
card);
}
示例2: handleWhoThereIntent
import com.amazon.speech.speechlet.Session; //导入方法依赖的package包/类
private SpeechletResponse handleWhoThereIntent(IntentRequest intentReq, Session session) {
SpeechletResponse response = null;
//check state
if(session.getAttribute(SESSION_KNOCK_STATE) != null
&& STATE_WAITING_WHO_DER.compareTo((Integer)session.getAttribute(SESSION_KNOCK_STATE)) == 0) {
response = newAskResponse("Doctor.", false," Doctor is here.",false);
//Update state
session.setAttribute(SESSION_KNOCK_STATE, STATE_WAITING_DR_WHO);
}
else {
response = newTellResponse("You have to say knock knock first.", false);
}
return response;
}
示例3: handleIntentRequest
import com.amazon.speech.speechlet.Session; //导入方法依赖的package包/类
@Override
public SpeechletResponse handleIntentRequest(Intent intent, Session session) {
Object sessionQuestion = session.getAttribute(SkillConfig.SessionAttributeYesNoQuestion);
SpeechletResponse response = SkillLogic.isAnswerToAnotherEncode(intent, session) ?
SkillResponses.getEncodeAskResponse(intent, session) :
SkillLogic.isAnswerToAnotherSpell(intent, session) ?
SkillResponses.getSpellAskResponse(intent, session) :
SkillLogic.isAnswerToAnotherExercise(intent, session) ?
SkillResponses.getExerciseAskResponse(intent, session) :
SkillLogic.isAnswerToAnotherTry(intent, session) ?
SkillResponses.getExerciseRepeatResponse(intent, session) :
SkillLogic.hasExercisePending(intent, session) ?
SkillResponses.getHelpDuringExercise(intent, session) :
SkillResponses.getHelpAboutAll(intent, session);
// reset session attribute if unchanged
if (sessionQuestion != null && sessionQuestion.toString().equals(session.getAttribute(SkillConfig.SessionAttributeYesNoQuestion)))
session.removeAttribute(SkillConfig.SessionAttributeYesNoQuestion);
return response;
}
示例4: handleDrWhoIntent
import com.amazon.speech.speechlet.Session; //导入方法依赖的package包/类
private SpeechletResponse handleDrWhoIntent(IntentRequest intentReq, Session session) {
SpeechletResponse response = null;
//check state
if(session.getAttribute(SESSION_KNOCK_STATE) != null
&& STATE_WAITING_DR_WHO.compareTo((Integer)session.getAttribute(SESSION_KNOCK_STATE)) == 0) {
response = newTellResponse(" Exactly. How did you know?", false);
//Clear final state
session.removeAttribute(SESSION_KNOCK_STATE);
}
else {
response = newTellResponse("You have to say knock knock first.", false);
}
return response;
}
示例5: responseNo
import com.amazon.speech.speechlet.Session; //导入方法依赖的package包/类
protected SpeechletResponse responseNo(Intent intent, Session session) {
String previousState = (String)session.getAttribute(Constants.ATTR_PREVIOUS_STATE);
session.setAttribute(Constants.ATTR_PREVIOUS_STATE, null);
if ("NATO".equals(previousState)) {
return responseText("Which train would you like status for?", false);
} else if ("TRAIN_QUERY".equals(previousState)) {
return responseText("See you!");
}
return responseText("");
}
示例6: handleIntentRequest
import com.amazon.speech.speechlet.Session; //导入方法依赖的package包/类
@Override
public SpeechletResponse handleIntentRequest(Intent intent, Session session) {
// keep in mind what question was denied
Object sessionQuestion = session.getAttribute(SkillConfig.SessionAttributeYesNoQuestion);
// "have another try?" on the same morse code was denied
SpeechletResponse response = SkillLogic.isAnswerToAnotherTry(intent, session) ?
// so finish the current exercise and play back the correct answer
SkillResponses.getExerciseFinalFalseResponse(intent, session) :
// "have another exercise?" with a new code was denied
SkillLogic.isAnswerToAnotherExercise(intent, session) ?
// this means leaving the app and say good bye
SkillResponses.getGoodBye(intent, session) :
// "have another encoding?" was denied
SkillLogic.isAnswerToAnotherEncode(intent, session) ?
// this means leaving the app and say good bye
SkillResponses.getGoodBye(intent, session) :
// "have another code spelled out?" was denied
SkillLogic.isAnswerToAnotherSpell(intent, session) ?
// this means leaving the app and say good bye
SkillResponses.getGoodBye(intent, session) :
// none of the above questions was answered, so No-intent is not expected in current context
// before giving the user a help check if there is an ongoing exercise
SkillLogic.hasExercisePending(intent, session) ?
// if so, play back help information dedicated to the exercise
SkillResponses.getHelpDuringExercise(intent, session) :
// otherwise: give general hints
SkillResponses.getHelpAboutAll(intent, session);
// reset session attribute if unchanged
if (sessionQuestion != null && sessionQuestion.toString().equals(session.getAttribute(SkillConfig.SessionAttributeYesNoQuestion)))
session.removeAttribute(SkillConfig.SessionAttributeYesNoQuestion);
return response;
}