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
32          SerialSessionConfig {
33  
34      private int receiveThreshold = -1;
35  
36      private int inputBufferSize = 8;
37  
38      private int outputBufferSize = 8;
39  
40      private boolean lowLatency = false;
41  
42      public DefaultSerialSessionConfig() {
43          // All default properties were configured above.
44      }
45  
46      /**
47       * {@inheritDoc}
48       */
49      @Override
50      protected void doSetAll(IoSessionConfig config) {
51          if (config instanceof SerialSessionConfig) {
52              SerialSessionConfig cfg = (SerialSessionConfig) config;
53              setInputBufferSize(cfg.getInputBufferSize());
54              setReceiveThreshold(cfg.getReceiveThreshold());
55          }
56      }
57  
58      /**
59       * {@inheritDoc}
60       */
61      public int getInputBufferSize() {
62          return inputBufferSize;
63      }
64  
65      /**
66       * {@inheritDoc}
67       */
68      public boolean isLowLatency() {
69          return lowLatency;
70      }
71  
72      /**
73       * {@inheritDoc}
74       */
75      public void setInputBufferSize(int bufferSize) {
76          inputBufferSize = bufferSize;
77      }
78  
79      /**
80       * {@inheritDoc}
81       */
82      public void setLowLatency(boolean lowLatency) {
83          this.lowLatency = lowLatency;
84      }
85  
86      /**
87       * {@inheritDoc}
88       */
89      public int getReceiveThreshold() {
90          return receiveThreshold;
91      }
92  
93      /**
94       * {@inheritDoc}
95       */
96      public void setReceiveThreshold(int bytes) {
97          receiveThreshold = bytes;
98      }
99  
100     /**
101      * {@inheritDoc}
102      */
103     public int getOutputBufferSize() {
104         return outputBufferSize;
105     }
106 
107     /**
108      * {@inheritDoc}
109      */
110     public void setOutputBufferSize(int bufferSize) {
111         outputBufferSize = bufferSize;
112 
113     }
114 }