source: nutchez-0.1/tomcat/webapps/examples/WEB-INF/classes/sessions/DummyCart.java @ 67

Last change on this file since 67 was 66, checked in by waue, 16 years ago

NutchEz - an easy way to nutch

File size: 1.8 KB
Line 
1/*
2* Licensed to the Apache Software Foundation (ASF) under one or more
3* contributor license agreements.  See the NOTICE file distributed with
4* this work for additional information regarding copyright ownership.
5* The ASF licenses this file to You under the Apache License, Version 2.0
6* (the "License"); you may not use this file except in compliance with
7* the License.  You may obtain a copy of the License at
8*
9*     http://www.apache.org/licenses/LICENSE-2.0
10*
11* Unless required by applicable law or agreed to in writing, software
12* distributed under the License is distributed on an "AS IS" BASIS,
13* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14* See the License for the specific language governing permissions and
15* limitations under the License.
16*/
17package sessions;
18
19import java.util.Vector;
20
21public class DummyCart {
22    Vector<String> v = new Vector<String>();
23    String submit = null;
24    String item = null;
25   
26    private void addItem(String name) {
27        v.addElement(name);
28    }
29
30    private void removeItem(String name) {
31        v.removeElement(name);
32    }
33
34    public void setItem(String name) {
35        item = name;
36    }
37   
38    public void setSubmit(String s) {
39        submit = s;
40    }
41
42    public String[] getItems() {
43        String[] s = new String[v.size()];
44        v.copyInto(s);
45        return s;
46    }
47   
48    public void processRequest() {
49        // null value for submit - user hit enter instead of clicking on
50        // "add" or "remove"
51        if (submit == null || submit.equals("add"))
52            addItem(item);
53        else if (submit.equals("remove")) 
54            removeItem(item);
55       
56        // reset at the end of the request
57        reset();
58    }
59
60    // reset
61    private void reset() {
62        submit = null;
63        item = null;
64    }
65}
Note: See TracBrowser for help on using the repository browser.