View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.chemistry.opencmis.server.impl;
20  
21  import org.apache.chemistry.opencmis.commons.server.CallContext;
22  
23  import java.io.File;
24  
25  import java.math.BigInteger;
26  
27  import java.util.HashMap;
28  import java.util.Map;
29  
30  
31  /**
32   * Implementation of the {@link CallContext} interface.
33   */
34  public class CallContextImpl implements CallContext
35  {
36      private final String binding;
37      private final boolean objectInfoRequired;
38      private final Map<String, Object> parameter = new HashMap<String, Object>(  );
39  
40      public CallContextImpl( String binding, String repositoryId, boolean objectInfoRequired )
41      {
42          this.binding = binding;
43          this.objectInfoRequired = objectInfoRequired;
44          put( REPOSITORY_ID, repositoryId );
45      }
46  
47      public String getBinding(  )
48      {
49          return binding;
50      }
51  
52      public boolean isObjectInfoRequired(  )
53      {
54          return objectInfoRequired;
55      }
56  
57      public Object get( String key )
58      {
59          return parameter.get( key );
60      }
61  
62      public String getRepositoryId(  )
63      {
64          return (String) get( REPOSITORY_ID );
65      }
66  
67      public String getUsername(  )
68      {
69          return (String) get( USERNAME );
70      }
71  
72      public String getPassword(  )
73      {
74          return (String) get( PASSWORD );
75      }
76  
77      public String getLocale(  )
78      {
79          return (String) get( LOCALE );
80      }
81  
82      public BigInteger getOffset(  )
83      {
84          return (BigInteger) get( OFFSET );
85      }
86  
87      public BigInteger getLength(  )
88      {
89          return (BigInteger) get( LENGTH );
90      }
91  
92      public File getTempDirectory(  )
93      {
94          return (File) get( TEMP_DIR );
95      }
96  
97      public int getMemoryThreshold(  )
98      {
99          return (Integer) get( MEMORY_THRESHOLD );
100     }
101 
102     /**
103      * Adds a parameter.
104      */
105     public void put( String key, Object value )
106     {
107         parameter.put( key, value );
108     }
109 
110     /**
111      * Removes a parameter.
112      */
113     public Object remove( String key )
114     {
115         return parameter.remove( key );
116     }
117 }