PageRenderTime 17ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/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
17package com.hazelcast.impl.ascii.rest;
18
19import com.hazelcast.impl.ascii.CommandParser;
20import com.hazelcast.impl.ascii.TextCommand;
21import com.hazelcast.impl.ascii.memcache.ErrorCommand;
22import com.hazelcast.nio.ascii.SocketTextReader;
23
24import java.util.StringTokenizer;
25
26import static com.hazelcast.impl.ascii.TextCommandConstants.TextCommandType.ERROR_CLIENT;
27
28public class HttpDeleteCommandParser implements CommandParser {
29
30    public TextCommand parser(SocketTextReader socketTextReader, String cmd, int space) {
31        StringTokenizer st = new StringTokenizer(cmd);
32        st.nextToken();
33        String uri = null;
34        if (st.hasMoreTokens()) {
35            uri = st.nextToken();
36        } else {
37            return new ErrorCommand(ERROR_CLIENT);
38        }
39        return new HttpDeleteCommand(uri);
40    }
41}