@Test public void parse_withUntaggedResponse_shouldReturnNull() throws Exception { ImapResponse imapResponse = createImapResponse("* OK [READ-WRITE] Select completed."); SelectOrExamineResponse result = SelectOrExamineResponse.parse(imapResponse); assertNull(result); }
public static SelectOrExamineResponse parse(ImapResponse response) { if (!response.isTagged() || !equalsIgnoreCase(response.get(0), Responses.OK)) { return null; } if (!response.isList(1)) { return noOpenModeInResponse(); } ImapList responseTextList = response.getList(1); if (!responseTextList.isString(0)) { return noOpenModeInResponse(); } String responseCode = responseTextList.getString(0); if ("READ-ONLY".equalsIgnoreCase(responseCode)) { return new SelectOrExamineResponse(false); } else if ("READ-WRITE".equalsIgnoreCase(responseCode)) { return new SelectOrExamineResponse(true); } return noOpenModeInResponse(); }
SelectOrExamineResponse { public static SelectOrExamineResponse parse(ImapResponse response) { if (!response.isTagged() || !equalsIgnoreCase(response.get(0), Responses.OK)) { return null; } if (!response.isList(1)) { return noOpenModeInResponse(); } ImapList responseTextList = response.getList(1); if (!responseTextList.isString(0)) { return noOpenModeInResponse(); } String responseCode = responseTextList.getString(0); if ("READ-ONLY".equalsIgnoreCase(responseCode)) { return new SelectOrExamineResponse(false); } else if ("READ-WRITE".equalsIgnoreCase(responseCode)) { return new SelectOrExamineResponse(true); } return noOpenModeInResponse(); } }
SelectOrExamineResponse { public static SelectOrExamineResponse parse(ImapResponse response) { if (!response.isTagged() || !equalsIgnoreCase(response.get(0), Responses.OK)) { return null; } if (!response.isList(1)) { return noOpenModeInResponse(); } ImapList responseTextList = response.getList(1); if (!responseTextList.isString(0)) { return noOpenModeInResponse(); } String responseCode = responseTextList.getString(0); if ("READ-ONLY".equalsIgnoreCase(responseCode)) { return new SelectOrExamineResponse(false); } else if ("READ-WRITE".equalsIgnoreCase(responseCode)) { return new SelectOrExamineResponse(true); } return noOpenModeInResponse(); } private  SelectOrExamineResponse(Boolean readWriteMode); }
SelectOrExamineResponse { public static SelectOrExamineResponse parse(ImapResponse response) { if (!response.isTagged() || !equalsIgnoreCase(response.get(0), Responses.OK)) { return null; } if (!response.isList(1)) { return noOpenModeInResponse(); } ImapList responseTextList = response.getList(1); if (!responseTextList.isString(0)) { return noOpenModeInResponse(); } String responseCode = responseTextList.getString(0); if ("READ-ONLY".equalsIgnoreCase(responseCode)) { return new SelectOrExamineResponse(false); } else if ("READ-WRITE".equalsIgnoreCase(responseCode)) { return new SelectOrExamineResponse(true); } return noOpenModeInResponse(); } private  SelectOrExamineResponse(Boolean readWriteMode); static SelectOrExamineResponse parse(ImapResponse response); boolean hasOpenMode(); int getOpenMode(); }
SelectOrExamineResponse { public static SelectOrExamineResponse parse(ImapResponse response) { if (!response.isTagged() || !equalsIgnoreCase(response.get(0), Responses.OK)) { return null; } if (!response.isList(1)) { return noOpenModeInResponse(); } ImapList responseTextList = response.getList(1); if (!responseTextList.isString(0)) { return noOpenModeInResponse(); } String responseCode = responseTextList.getString(0); if ("READ-ONLY".equalsIgnoreCase(responseCode)) { return new SelectOrExamineResponse(false); } else if ("READ-WRITE".equalsIgnoreCase(responseCode)) { return new SelectOrExamineResponse(true); } return noOpenModeInResponse(); } private  SelectOrExamineResponse(Boolean readWriteMode); static SelectOrExamineResponse parse(ImapResponse response); boolean hasOpenMode(); int getOpenMode();  }