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   */
20  package org.apache.mina.transport.serial;
21  
22  import org.apache.mina.core.session.AbstractIoSessionConfig;
23  import org.apache.mina.core.session.IoSessionConfig;
24  
25  /**
26   * The default configuration for a serial session {@link SerialSessionConfig}.
27   *
28   * @author <a href="http://mina.apache.org">Apache MINA Project</a>
29   */
30  class DefaultSerialSessionConfig extends AbstractIoSessionConfig implements SerialSessionConfig {
31  
32      private int receiveThreshold = -1;
33  
34      private int inputBufferSize = 8;
35  
36      private int outputBufferSize = 8;
37  
38      private boolean lowLatency = false;
39  
40      public DefaultSerialSessionConfig() {
41          // All default properties were configured above.
42      }
43  
44      /**
45       * {@inheritDoc}
46       */
47      @Override
48      public void setAll(IoSessionConfig config) {
49          super.setAll(config);
50          
51          if (config instanceof SerialSessionConfig) {
52              SerialSessionConfig./../org/apache/mina/transport/serial/SerialSessionConfig.html#SerialSessionConfig">SerialSessionConfig cfg = (SerialSessionConfig) config;
53              setInputBufferSize(cfg.getInputBufferSize());
54              setReceiveThreshold(cfg.getReceiveThreshold());
55          }
56      }
57  
58      /**
59       * {@inheritDoc}
60       */
61      @Override
62      public int getInputBufferSize() {
63          return inputBufferSize;
64      }
65  
66      /**
67       * {@inheritDoc}
68       */
69      @Override
70      public boolean isLowLatency() {
71          return lowLatency;
72      }
73  
74      /**
75       * {@inheritDoc}
76       */
77      @Override
78      public void setInputBufferSize(int bufferSize) {
79          inputBufferSize = bufferSize;
80      }
81  
82      /**
83       * {@inheritDoc}
84       */
85      @Override
86      public void setLowLatency(boolean lowLatency) {
87          this.lowLatency = lowLatency;
88      }
89  
90      /**
91       * {@inheritDoc}
92       */
93      @Override
94      public int getReceiveThreshold() {
95          return receiveThreshold;
96      }
97  
98      /**
99       * {@inheritDoc}
100      */
101     @Override
102     public void setReceiveThreshold(int bytes) {
103         receiveThreshold = bytes;
104     }
105 
106     /**
107      * {@inheritDoc}
108      */
109     @Override
110     public int getOutputBufferSize() {
111         return outputBufferSize;
112     }
113 
114     /**
115      * {@inheritDoc}
116      */
117     @Override
118     public void setOutputBufferSize(int bufferSize) {
119         outputBufferSize = bufferSize;
120 
121     }
122 }