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 The Apache MINA Project (dev@mina.apache.org)
29   * @version $Rev: 529576 $, $Date: 2007-04-17 14:25:07 +0200 (mar., 17 avr. 2007) $
30   */
31  class DefaultSerialSessionConfig extends AbstractIoSessionConfig implements SerialSessionConfig {
32  
33      private int receiveThreshold = -1;
34      private int inputBufferSize = 8;
35      private boolean lowLatency = false;
36  
37      public DefaultSerialSessionConfig() {
38          // All default properties were configured above.
39      }
40  
41      @Override
42      protected void doSetAll(IoSessionConfig config) {
43          if (config instanceof SerialSessionConfig) {
44              SerialSessionConfig cfg = (SerialSessionConfig) config;
45              setInputBufferSize(cfg.getInputBufferSize());
46              setReceiveThreshold(cfg.getReceiveThreshold());
47          }
48      }
49  
50      public int getInputBufferSize() {
51          return inputBufferSize;
52      }
53  
54      public boolean isLowLatency() {
55          return lowLatency;
56      }
57  
58      public void setInputBufferSize(int bufferSize) {
59          inputBufferSize = bufferSize;
60      }
61  
62      public void setLowLatency(boolean lowLatency) {
63          this.lowLatency = lowLatency;
64      }
65  
66      public int getReceiveThreshold() {
67          return receiveThreshold;
68      }
69  
70      public void setReceiveThreshold(int bytes) {
71          receiveThreshold = bytes;
72      }
73  }