1 /***
2 * Copyright 2003-2010 Terracotta, Inc.
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
17 package net.sf.ehcache.transaction.xa.commands;
18
19 import net.sf.ehcache.Element;
20
21 /***
22 * Represents a {@link net.sf.ehcache.store.Store#put(net.sf.ehcache.Element)} put} operation to be executed on a {@link net.sf.ehcache.store.Store}.
23 * @author Alex Snaps
24 */
25 public class StorePutCommand extends AbstractStoreCommand {
26
27 /***
28 * Create a StorePutCommand
29 *
30 * @param oldElement the element in the underlying store at the time this command is created
31 * @param newElement the new element to put in the underlying store
32 */
33 public StorePutCommand(final Element oldElement, final Element newElement) {
34 super(oldElement, newElement);
35 }
36
37 /***
38 * {@inheritDoc}
39 */
40 public boolean isPut(Object key) {
41 return getObjectKey().equals(key);
42 }
43
44 /***
45 * {@inheritDoc}
46 */
47 public boolean isRemove(Object key) {
48 return false;
49 }
50
51
52 /***
53 * Getter to the Element instance to be put in the Store
54 *
55 * @return the element instance
56 */
57 public Element getElement() {
58 return getNewElement();
59 }
60
61 /***
62 * {@inheritDoc}
63 */
64 public Object getObjectKey() {
65 return getNewElement().getObjectKey();
66 }
67
68
69 }