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