/hazelcast/src/main/java/com/hazelcast/impl/ascii/rest/HttpDeleteCommandParser.java

https://bitbucket.org/gabral6_gmailcom/hazelcast · Java · 41 lines · 20 code · 6 blank · 15 comment · 2 complexity · ba4bf39d92613f7ba06e5fc66b2b7ef3 MD5 · raw file

  1. /*
  2. * Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.hazelcast.impl.ascii.rest;
  17. import com.hazelcast.impl.ascii.CommandParser;
  18. import com.hazelcast.impl.ascii.TextCommand;
  19. import com.hazelcast.impl.ascii.memcache.ErrorCommand;
  20. import com.hazelcast.nio.ascii.SocketTextReader;
  21. import java.util.StringTokenizer;
  22. import static com.hazelcast.impl.ascii.TextCommandConstants.TextCommandType.ERROR_CLIENT;
  23. public class HttpDeleteCommandParser implements CommandParser {
  24. public TextCommand parser(SocketTextReader socketTextReader, String cmd, int space) {
  25. StringTokenizer st = new StringTokenizer(cmd);
  26. st.nextToken();
  27. String uri = null;
  28. if (st.hasMoreTokens()) {
  29. uri = st.nextToken();
  30. } else {
  31. return new ErrorCommand(ERROR_CLIENT);
  32. }
  33. return new HttpDeleteCommand(uri);
  34. }
  35. }