Skip to main content
summaryrefslogtreecommitdiffstats
blob: e6a51c772e95b5042540467fe52d73abbcf09428 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.orcs.db.mocks;

import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.orcs.db.internal.proxy.DataHandler;
import org.eclipse.osee.orcs.db.internal.proxy.DataResource;

/**
 * @author Roberto E. Escobar
 */
public class MockDataHandler implements DataHandler {

   private DataResource resource;
   private long storageId;
   private byte[] content;
   private boolean acquire;
   private boolean save;
   private boolean delete;

   public MockDataHandler() {
      super();
      reset();
   }

   @SuppressWarnings("unused")
   @Override
   public byte[] acquire(DataResource resource) throws OseeCoreException {
      setAcquire(true);
      this.resource = resource;
      return content;
   }

   @SuppressWarnings("unused")
   @Override
   public void save(long storageId, DataResource resource, byte[] rawContent) throws OseeCoreException {
      setSave(true);
      this.storageId = storageId;
      this.resource = resource;
      this.content = rawContent;
   }

   @SuppressWarnings("unused")
   @Override
   public void delete(DataResource resource) throws OseeCoreException {
      setDelete(true);
      this.resource = resource;
   }

   public DataResource getResource() {
      return resource;
   }

   public long getStorageId() {
      return storageId;
   }

   public byte[] getContent() {
      return content;
   }

   public void setContent(byte[] content) {
      this.content = content;
   }

   public void setResource(DataResource resource) {
      this.resource = resource;
   }

   public void setStorageId(int storageId) {
      this.storageId = storageId;
   }

   public boolean isAcquire() {
      return acquire;
   }

   public boolean isSave() {
      return save;
   }

   public boolean isDelete() {
      return delete;
   }

   public void setAcquire(boolean acquire) {
      this.acquire = acquire;
   }

   public void setSave(boolean save) {
      this.save = save;
   }

   public void setDelete(boolean delete) {
      this.delete = delete;
   }

   public void reset() {
      setAcquire(false);
      setSave(false);
      setDelete(false);
      resource = null;
      content = null;
      storageId = -1;
   }
}

Back to the top